X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Ftoken.c;h=ec86ac5be48e7028a49cafc5588d973fb2eab350;hp=2757a7b46ded91501641176b3f3dfc4f9325946e;hb=b0f981469cdea23225ca5c3ef0ca6759d6a92b43;hpb=4ccd4a89af90a1848ddec70414d06bb89a06c9c6 diff --git a/src/token.c b/src/token.c index 2757a7b..ec86ac5 100644 --- a/src/token.c +++ b/src/token.c @@ -6,7 +6,7 @@ OPD *opdtok(const char *str) { OPD *opd = malloc(sizeof(OPD)); char *p, *q, *sepp; - int sepc = ',', len = 0; + int sepc = ',', qcnt = 0; bool quoting = false; opd->opdc = 0; @@ -17,7 +17,7 @@ OPD *opdtok(const char *str) do { /* オペランド数が多すぎる場合はエラー */ if(opd->opdc >= OPDSIZE) { - setcerr(117, str); /* operand is too many */ + setcerr(117, NULL); /* operand is too many */ break; } /* 先頭が「=」の場合の処理 */ @@ -32,7 +32,7 @@ OPD *opdtok(const char *str) } /* 「'」の分、文字列の長さを小さくする */ if(*(q+1) != '\'') { - len--; + qcnt++; } } if(quoting == true) { @@ -50,13 +50,13 @@ OPD *opdtok(const char *str) setcerr(121, NULL); /* cannot get operand token */ break; } - len += strlen(p); - if(len > OPDSIZE) { + if(strlen(p) - qcnt > OPDSIZE) { setcerr(118, NULL); /* operand length is too long */ break; } opd->opdv[(++opd->opdc)-1] = strdup(p); p = q = sepp + 1; + qcnt = 0; } } while(sepc == ','); return opd;