4356ea5fdabe10d696e8009c166e0c86113036f9 tdreszer Wed Mar 23 15:10:57 2011 -0700 Little more robust handling of one case of respect quotes. diff --git src/lib/common.c src/lib/common.c index 9ba7c4d..5aefdb6 100644 --- src/lib/common.c +++ src/lib/common.c @@ -741,38 +741,44 @@ el = slNameNew(s); else { el = slNameNewN(s, e-s); e += 1; } slAddHead(&list, el); s = e; } slReverse(&list); return list; } struct slName *slNameListOfUniqueWords(char *text,boolean respectQuotes) // Return list of unique words found by parsing string delimited by whitespace. -// If respectQuotes then ["Lucy and Ricky" 'Fred and Ethyl'] are 2 words +// If respectQuotes then ["Lucy and Ricky" 'Fred and Ethyl'] will yield 2 slNames no quotes { struct slName *list = NULL; char *word = NULL; while (text != NULL) { if (respectQuotes) + { word = nextWordRespectingQuotes(&text); + if (word[0] == '"') + stripChar(word, '"'); + else if (word[0] == '\'') + stripChar(word, '\''); + } else word = nextWord(&text); if (word) slNameStore(&list, word); } slReverse(&list); return list; } struct slName *slNameListFromStringArray(char *stringArray[], int arraySize) /* Return list of slNames from an array of strings of length arraySize. * If a string in the array is NULL, the array will be treated as * NULL-terminated (shorter than arraySize). */ {