From bb9d41081432d335dcb0b3ad8c9d7dd9c6790b6f Mon Sep 17 00:00:00 2001 From: j8takagi Date: Tue, 9 Feb 2010 09:00:58 +0900 Subject: [PATCH] =?utf8?q?=E6=96=87=E5=AD=97=E5=AE=9A=E6=95=B0=E3=81=AE?= =?utf8?q?=E9=95=B7=E3=81=95=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B?= =?utf8?q?=E3=81=A8=E3=81=8D=E3=81=AB=E3=80=8C''=E3=80=8D=E3=82=921?= =?utf8?q?=E6=96=87=E5=AD=97=E3=81=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?utf8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/casl2.c | 2 +- src/token.c | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/casl2.c b/src/casl2.c index 8e0b94a..8ae3495 100644 --- a/src/casl2.c +++ b/src/casl2.c @@ -52,7 +52,7 @@ CERRARRAY cerr[] = { { 120, "GR0 in operand x" }, { 121, "cannot get operand token" }, { 122, "cannot create hash table" }, - { 123, "illegal string" }, + { 123, "unclosed quote" }, { 124, "more than one character in literal" }, { 125, "not GR in operand x" }, { 201, "execute - out of COMET II memory" }, 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); -- 2.18.0