changeset 853:b2140d41785a

Cleanup some parsing logic.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Oct 2014 02:11:44 +0300
parents ff13d79c75e0
children ca5b4696be21
files tools/gfxconv.c
diffstat 1 files changed, 9 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/tools/gfxconv.c	Thu Oct 23 02:09:52 2014 +0300
+++ b/tools/gfxconv.c	Thu Oct 23 02:11:44 2014 +0300
@@ -423,24 +423,22 @@
 
 BOOL dmParseMapOptionString(char *opt, void *values, int *nvalues, const int nmax, const BOOL requireIndex, const char *msg)
 {
-    char *end, *start = opt;
+    char *start = opt;
 
     *nvalues = 0;
-    while (*nvalues < nmax && *start && (end = strchr(start, ',')) != NULL)
+    while (*start && *nvalues < nmax)
     {
+        char *end = strchr(start, ',');
+
         if (!dmParseMapOptionItem(start, end, values, *nvalues, nmax, requireIndex, msg))
             return FALSE;
 
+        (*nvalues)++;
+
+        if (!end)
+            break;
+
         start = end + 1;
-        (*nvalues)++;
-    }
-    
-    if (*start && *nvalues < nmax)
-    {
-        if (!dmParseMapOptionItem(start, NULL, values, *nvalues, nmax, requireIndex, msg))
-            return FALSE;
-
-        (*nvalues)++;
     }
 
     return TRUE;