3048a9a9659555b11f06f0016dcf34d4ddde5212 tdreszer Mon Mar 28 17:10:46 2011 -0700 Fixed bug that Kate found. diff --git src/lib/common.c src/lib/common.c index 5aefdb6..cb96a41 100644 --- src/lib/common.c +++ src/lib/common.c @@ -1001,48 +1001,52 @@ return NULL; } *val++ = 0; slPairAdd(&list, name, cloneString(val)); } freez(&ss); slReverse(&list); return list; } char *slPairListToString(struct slPair *list) // Returns an allocated string of pairs in form of // name1=val1 name2=val2 ... // Will wrap vals in quotes if contain spaces: name3="val 3" { -// Don't rely on dyString. Do the accounting ourselves +// Don't rely on dyString. We can do the accounting ourselves. int count = 0; struct slPair *pair = list; for(;pair != NULL; pair = pair->next) { + if (pair->name == NULL || pair->val == NULL) + continue; count += strlen(pair->name); count += strlen((char *)(pair->val)); count += 2; // = and ' ' delimit if (hasWhiteSpace((char *)(pair->val))) count += 2; // " and " } if (count == 0) return NULL; char *str = needMem(count+5); // A bit of slop char *s = str; for(pair = list;pair != NULL; pair = pair->next) { + if (pair->name == NULL || pair->val == NULL) + continue; if (hasWhiteSpace((char *)(pair->val))) sprintf(s,"%s=\"%s\" ",pair->name,(char *)(pair->val)); else sprintf(s,"%s=%s ",pair->name,(char *)(pair->val)); s += strlen(s); } str[strlen(str) - 1] = '\0'; // For sweetness, remove the trailing space. return str; } int slPairCmpCase(const void *va, const void *vb) /* Compare two slPairs, ignore case. */ { const struct slPair *a = *((struct slPair **)va); const struct slPair *b = *((struct slPair **)vb);