c879f6e8ca6a8a231bd5e7ee73ffa81bf65c128c tdreszer Mon Apr 4 12:09:47 2011 -0700 Fixed bug in slPairListFromString caused by leading white-space diff --git src/lib/common.c src/lib/common.c index ac59b99..b3d235c 100644 --- src/lib/common.c +++ src/lib/common.c @@ -998,32 +998,32 @@ int count = countChars(str, '=') + 1; // Should have 1 more token than '=': {"name 1"},{val1 name2},{"val 2"} if (count < 2) { warn("slPairListFromString() No pairs found in string meant to contain name=value pairs [%s]\n", str); return NULL; } char *strClone = cloneString(str); char **tokens = needMem(sizeof(char *) * count); count = chopByChar(strClone, '=',tokens,count); int ix; struct slPair *list = NULL; for (ix=1; ix < count;ix++) // starting at 1 and looking back to 0 { // name comes from prev token! - char *name = tokens[ix -1]; - char *val = tokens[ix]; + char *name = skipLeadingSpaces(tokens[ix - 1]); // Could be multiple spaces delimiting one pair from next + char *val = tokens[ix]; // should be immediately after '=' // Parse of val and set up ptr for next name char *next = NULL; if (respectQuotes && val[0] == '"') next = skipBeyondDelimit(tokens[ix] + 1,'"'); else next = skipToSpaces(tokens[ix]); if (next != NULL) { *next++ = '\0'; tokens[ix] = next; // set up for next round. } else if (ix + 1 != count) // Last token should have no 'next'. { warn("slPairListFromString() Error parsing string meant to contain name=value pairs: [%s]\n", str);