changeset 7503:f0888351bd46

accept empty strings too for STRING_LIST (example: "-xyz 1,2.5,,4," )
author arpi
date Thu, 26 Sep 2002 00:28:32 +0000
parents 6a2b6f3d619c
children 568a1a0b4bec
files cfgparser.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cfgparser.c	Wed Sep 25 23:45:34 2002 +0000
+++ b/cfgparser.c	Thu Sep 26 00:28:32 2002 +0000
@@ -612,7 +612,7 @@
 			    last_ptr = ptr;
 			    ptr = strchr(ptr,LIST_SEPARATOR);
 			    if(!ptr) {
-			      if(strlen(last_ptr) > 0)
+//			      if(strlen(last_ptr) > 0)
 				n++;
 			      break;
 			    }
@@ -630,11 +630,13 @@
 			  res = malloc((n+1)*sizeof(char*));
 			  ptr = param;
 			  n = 0;
-			  while(ptr[0] != '\0') {
+//			  while(ptr[0] != '\0') {
+			  while(1) {
 			    last_ptr = ptr;
 			    ptr = strchr(ptr,LIST_SEPARATOR);
 			     if(!ptr) {
-			       if(strlen(last_ptr) > 0) {
+			       //if(strlen(last_ptr) > 0) 
+			       {
 				 res[n] = strdup(last_ptr);
 				 n++;
 			       }
@@ -642,7 +644,7 @@
 			     }
 			     len = ptr - last_ptr;
 			     res[n] = (char*)malloc(len + 1);
-			     strncpy(res[n],last_ptr,len);
+			     if(len) strncpy(res[n],last_ptr,len);
 			     res[n][len] = '\0';
 			     ptr++;
 			     n++;