X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Ftoken.c;h=68ed3a7c5dc8a53dfa3489fb0fe6a82f2f133bef;hp=96ddcaae2445e81ca9eed8265aca604ba3af2d49;hb=bb9d41081432d335dcb0b3ad8c9d7dd9c6790b6f;hpb=f958640f07ddce6100e7eed1504ecaf05f6c1f02 diff --git a/src/token.c b/src/token.c index 96ddcaa..68ed3a7 100644 --- a/src/token.c +++ b/src/token.c @@ -5,8 +5,8 @@ OPD *opdtok(const char *str) { OPD *opd = malloc(sizeof(OPD)); - char *p, *q, *sepp; - int sepc = ','; + char *p, *q, *r, *sepp; + int sepc = ',', len; bool quoting = false; opd->opdc = 0; @@ -31,7 +31,7 @@ OPD *opdtok(const char *str) if(quoting == true) { /* 閉じ「'」がないまま文字列が終了した場合 */ if(*q == '\0') { - setcerr(123, str); /* illegal string */ + setcerr(123, str); /* unclosed quote */ break; } q++; @@ -39,12 +39,17 @@ OPD *opdtok(const char *str) sepp = q + strcspn(q, ", "); sepc = *sepp; *sepp = '\0'; - if(strlen(p) == 0) { + if(*p == '\0') { setcerr(121, NULL); /* cannot get operand token */ break; } - if(strlen(p) > OPDSIZE + 2) { /* OPDSIZE + 「'」2文字分 */ - setcerr(118, p); /* operand length is too long */ + len = strlen(r = p); + while(*r != '\0' && (r = strstr(r, "''")) != NULL) { + len--; + r += 2; + }; + if(len > OPDSIZE + 2) { /* OPDSIZE + 「'」2文字分 */ + setcerr(118, NULL); /* operand length is too long */ break; } opd->opdv[(++opd->opdc)-1] = strdup(p);