Merge branch 'master' into cmd-casl
authorj8takagi <j8takagi@nifty.com>
Wed, 10 Feb 2010 14:33:04 +0000 (23:33 +0900)
committerj8takagi <j8takagi@nifty.com>
Wed, 10 Feb 2010 14:33:04 +0000 (23:33 +0900)
src/token.c
test/integration/casl2/quoteend_err/0.txt

index 68ed3a7..54ebf3f 100644 (file)
@@ -5,7 +5,7 @@
 OPD *opdtok(const char *str)
 {
     OPD *opd = malloc(sizeof(OPD));
-    char *p, *q, *r, *sepp;
+    char *p, *q, *sepp;
     int sepc = ',', len;
     bool quoting = false;
 
@@ -15,6 +15,7 @@ OPD *opdtok(const char *str)
     }
     p = q = strdup(str);
     do {
+        len = 0;
         /* オペランド数が多すぎる場合はエラー */
         if(opd->opdc >= OPDSIZE) {
             setcerr(117, str);    /* operand is too many */
@@ -24,9 +25,16 @@ OPD *opdtok(const char *str)
         if(*q == '=') {
             q++;
         }
-        /* 「'」で囲まれた文字列の処理。「''」は無視 */
-        if(*q == '\'' && *(q+1) != '\'' && !(p < q && *(q-1) == '\'')) {
-            quoting = !quoting;
+        /* 「'」の場合 */
+        if(*q == '\'') {
+            /* 「''」以外の場合はquote値を反転 */
+            if(*(q+1) != '\'' && !(p < q && *(q-1) == '\'')) {
+                quoting = !quoting;
+            }
+            /* 「'」の分、文字列の長さを小さくする */
+            if(*(q+1) != '\'') {
+                len--;
+            }
         }
         if(quoting == true) {
             /* 閉じ「'」がないまま文字列が終了した場合 */
@@ -43,12 +51,8 @@ OPD *opdtok(const char *str)
                 setcerr(121, NULL);    /* cannot get operand token */
                 break;
             }
-            len = strlen(r = p);
-            while(*r != '\0' && (r = strstr(r, "''")) != NULL) {
-                len--;
-                r += 2;
-            };
-            if(len > OPDSIZE + 2) {    /* OPDSIZE + 「'」2文字分 */
+            len += strlen(p);
+            if(len > OPDSIZE) {
                 setcerr(118, NULL);    /* operand length is too long */
                 break;
             }
index fa671ad..8c19446 100644 (file)
@@ -1,6 +1,6 @@
 ../../../../casl2 -td ../../../../as/ERR/quoteend_err.casl
 
 Assemble ../../../../as/ERR/quoteend_err.casl (0)
-Assemble error - 123: 'Hello, World!: illegal string
+Assemble error - 123: 'Hello, World!: unclosed quote
  ../../../../as/ERR/quoteend_err.casl:4: BUF      DC     'Hello, World!