]> Nishi Git Mirror - dataworks.git/commitdiff
ignore emtpy string
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 23 May 2024 10:26:29 +0000 (10:26 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 23 May 2024 10:26:29 +0000 (10:26 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@89 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Library/parser.c

index 1bb468c5126c287b8dedd6ba8a5fd5350dee1dbc..8a4151f14d9a10b2c0feeffb535005b52000beb0 100644 (file)
@@ -118,24 +118,26 @@ struct __dw_token* __dw_parser_parse(const char* str) {
                                                comma = __dw_strcat(tmp, cbuf);
                                                free(tmp);
                                        } else if(c == 0 || c == ',') {
-                                               j = 0;
-                                               if(token->token != NULL) {
-                                                       for(j = 0; token->token[j] != NULL; j++)
-                                                               ;
-                                               }
-                                               struct __dw_token** newtokens = malloc(sizeof(*newtokens) * (j + 2));
-                                               if(token->token != NULL) {
-                                                       for(j = 0; token->token[j] != NULL; j++) {
-                                                               newtokens[j] = token->token[j];
+                                               if(strlen(comma) > 0){
+                                                       j = 0;
+                                                       if(token->token != NULL) {
+                                                               for(j = 0; token->token[j] != NULL; j++)
+                                                                       ;
+                                                       }
+                                                       struct __dw_token** newtokens = malloc(sizeof(*newtokens) * (j + 2));
+                                                       if(token->token != NULL) {
+                                                               for(j = 0; token->token[j] != NULL; j++) {
+                                                                       newtokens[j] = token->token[j];
+                                                               }
+                                                               free(token->token);
                                                        }
-                                                       free(token->token);
+                                                       token->token = newtokens;
+                                                       token->token[j] = __dw_parser_parse(comma);
+                                                       token->token[j + 1] = NULL;
+                                                       free(comma);
+                                                       comma = malloc(1);
+                                                       comma[0] = 0;
                                                }
-                                               token->token = newtokens;
-                                               token->token[j] = __dw_parser_parse(comma);
-                                               token->token[j + 1] = NULL;
-                                               free(comma);
-                                               comma = malloc(1);
-                                               comma[0] = 0;
                                                if(c == 0) break;
                                        } else {
                                                cbuf[0] = c;