オペランドの最大長をOPDSIZE-1(=39)からOPDSIZE(=40)に修正
authorj8takagi <j8takagi@nifty.com>
Thu, 28 Jan 2010 03:01:49 +0000 (12:01 +0900)
committerj8takagi <j8takagi@nifty.com>
Thu, 28 Jan 2010 03:01:49 +0000 (12:01 +0900)
src/token.c
test/unit/opdtok/0.txt
test/unit/opdtok/Makefile
test/unit/opdtok/opdtok.c

index c46c9f2..fcb1aeb 100644 (file)
@@ -38,7 +38,7 @@ OPD *opdtok(const char *str)
                 setcerr(121, NULL);    /* cannot get operand token */
                 break;
             }
-            if(strlen(p) > OPDSIZE + 1) {
+            if(strlen(p) > OPDSIZE + 2) {
                 setcerr(118, p);    /* operand length is too long */
                 break;
             }
index 1dcf923..7bb505e 100644 (file)
@@ -40,98 +40,98 @@ OPDC[0]:'aaa'',''bbb'
 OPDC:1
 OPDC[0]:'aaa,bbb'
 
-0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9
+1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0
 OPDC:40
-OPDC[0]:0
-OPDC[1]:1
-OPDC[2]:2
-OPDC[3]:3
-OPDC[4]:4
-OPDC[5]:5
-OPDC[6]:6
-OPDC[7]:7
-OPDC[8]:8
-OPDC[9]:9
-OPDC[10]:0
-OPDC[11]:1
-OPDC[12]:2
-OPDC[13]:3
-OPDC[14]:4
-OPDC[15]:5
-OPDC[16]:6
-OPDC[17]:7
-OPDC[18]:8
-OPDC[19]:9
-OPDC[20]:0
-OPDC[21]:1
-OPDC[22]:2
-OPDC[23]:3
-OPDC[24]:4
-OPDC[25]:5
-OPDC[26]:6
-OPDC[27]:7
-OPDC[28]:8
-OPDC[29]:9
-OPDC[30]:0
-OPDC[31]:1
-OPDC[32]:2
-OPDC[33]:3
-OPDC[34]:4
-OPDC[35]:5
-OPDC[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]:3
-OPDC[34]:4
-OPDC[35]:5
-OPDC[36]:6
-OPDC[37]:7
-OPDC[38]:8
-OPDC[39]:9
+OPDC[0]:1
+OPDC[1]:2
+OPDC[2]:3
+OPDC[3]:4
+OPDC[4]:5
+OPDC[5]:6
+OPDC[6]:7
+OPDC[7]:8
+OPDC[8]:9
+OPDC[9]:0
+OPDC[10]:1
+OPDC[11]:2
+OPDC[12]:3
+OPDC[13]:4
+OPDC[14]:5
+OPDC[15]:6
+OPDC[16]:7
+OPDC[17]:8
+OPDC[18]:9
+OPDC[19]:0
+OPDC[20]:1
+OPDC[21]:2
+OPDC[22]:3
+OPDC[23]:4
+OPDC[24]:5
+OPDC[25]:6
+OPDC[26]:7
+OPDC[27]:8
+OPDC[28]:9
+OPDC[29]:0
+OPDC[30]:1
+OPDC[31]:2
+OPDC[32]:3
+OPDC[33]:4
+OPDC[34]:5
+OPDC[35]:6
+OPDC[36]:7
+OPDC[37]:8
+OPDC[38]:9
+OPDC[39]:0
 Error - 117: operand is too many
 
-'01234567890123456789012345678901234567'
+'1234567890123456789012345678901234567890'
 OPDC:1
-OPDC[0]:'01234567890123456789012345678901234567'
+OPDC[0]:'1234567890123456789012345678901234567890'
 
-'012345678901234567890123456789012345678'
+'12345678901234567890123456789012345678901'
 OPDC:0
-Error - 118: '012345678901234567890123456789012345678': operand length is too long
+Error - 118: '12345678901234567890123456789012345678901': operand length is too long
 
index eb78a08..5225297 100644 (file)
@@ -1,3 +1,3 @@
-UNITNAME = opdtok
 UCLASS = AS
-include ../Test.mk
+TESTSRCFILE = opdtok.c
+include ../TEST.mk
index dc5021e..d65a420 100644 (file)
@@ -7,12 +7,12 @@ int main(){
     char *str[] = {
         "", "GR0,GR1", "GR0,A", "GR1,12", "GR0,0,GR1",
         "\'aaa\',0", "\'aaa\',\'bbb\'", "\'aaa\'\',\'\'bbb\'", "\'aaa,bbb\'",
-        "0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9",
-        "0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0",
-        "\'01234567890123456789012345678901234567\'",
-        "\'012345678901234567890123456789012345678\'"
+        "1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0",
+        "1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1",
+        "\'1234567890123456789012345678901234567890\'",
+        "\'12345678901234567890123456789012345678901\'",
     };
-    for(i = 0; i < sizeof str / sizeof str[0]; i++) {
+    for(i = 0; i < ARRAYSIZE(str); i++) {
         printf("%s\n", str[i]);
         opd = opdtok(str[i]);
         printf("OPDC:%d\n", opd->opdc);
@@ -23,7 +23,7 @@ int main(){
             printf("Error - %d: %s\n", cerrno, cerrmsg);
             freecerr();
         }
-        printf("\n");        
+        printf("\n");
     }
     return 0;
 }