From: nishi Date: Thu, 23 May 2024 10:26:29 +0000 (+0000) Subject: ignore emtpy string X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=b0af6b058cb157a8f79c79c4cb5abb8b65c39591;p=dataworks.git ignore emtpy string git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@89 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Library/parser.c b/Library/parser.c index 1bb468c..8a4151f 100644 --- a/Library/parser.c +++ b/Library/parser.c @@ -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;