66f0203f3aa1b55db4179d8bd08aecdf72a0ac1d tdreszer Wed Mar 23 14:51:55 2011 -0700 Added respect for quotes in a couple of places. diff --git src/inc/common.h src/inc/common.h index f13bd49..fecb6b8 100644 --- src/inc/common.h +++ src/inc/common.h @@ -562,32 +562,33 @@ struct slName *slNameAddTail(struct slName **pList, char *name); /* Add name to end of list (not efficient for long lists), * and return it. */ struct slName *slNameCloneList(struct slName *list); /* Return clone of list. */ struct slName *slNameListFromString(char *s, char delimiter); /* Return list of slNames gotten from parsing delimited string. * The final delimiter is optional. a,b,c and a,b,c, are equivalent * for comma-delimited lists. */ #define slNameListFromComma(s) slNameListFromString(s, ',') /* Parse out comma-separated list. */ -struct slName *slNameListOfUniqueWords(char *text); +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 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. */ char *slNameListToString(struct slName *list, char delimiter); /* Return string created by joining all names with the delimiter. */ struct slName *slNameLoadReal(char *fileName); /* load file lines that are not blank or start with a '#' into a slName * list */ struct slName *slNameIntersection(struct slName *a, struct slName *b); /* return intersection of two slName lists. */ @@ -713,31 +714,31 @@ * number depending on the alphabetical order of the two * strings. * This is basically a strcmp that can handle NULLs in * the input. If used in a sort the NULLs will end * up before any of the cases with data. */ #define sameOk(a,b) (differentStringNullOk(a,b) == 0) /* returns TRUE if two strings same, NULLs OK */ #define sameString(a,b) (strcmp(a,b)==0) /* Returns TRUE if two strings same. */ #define sameStringN(a,b,c) (strncmp(a,b,c)==0) /* Returns TRUE if two strings start with the same c characters. */ -#define isEmpty(string) (string == NULL || string[0] == 0) +#define isEmpty(string) ((string) == NULL || (string)[0] == 0) #define isNotEmpty(string) (! isEmpty(string)) int cmpStringsWithEmbeddedNumbers(const char *a, const char *b); /* Compare strings such as gene names that may have embedded numbers, * so that bmp4a comes before bmp14a */ int cmpWordsWithEmbeddedNumbers(const char *a, const char *b); /* Case insensitive version of cmpStringsWithEmbeddedNumbers. */ boolean startsWith(const char *start, const char *string); /* Returns TRUE if string begins with start. */ boolean startsWithWord(char *firstWord, char *line); /* Return TRUE if first white-space-delimited word in line * is same as firstWord. Comparison is case sensitive. */ @@ -927,30 +928,33 @@ /* Return TRUE if there is white space in string. */ char *firstWordInLine(char *line); /* Returns first word in line if any (white space separated). * Puts 0 in place of white space after word. */ char *lastWordInLine(char *line); /* Returns last word in line if any (white space separated). * Returns NULL if string is empty. Removes any terminating white space * from line. */ char *nextWord(char **pLine); /* Return next word in *pLine and advance *pLine to next * word. Returns NULL when no more words. */ +char *nextWordRespectingQuotes(char **pLine); +// return next word but respects single or double quotes surrounding sets of words. + char *cloneFirstWord(char *line); /* Clone first word in line */ char *nextTabWord(char **pLine); /* Return next tab-separated word. */ char *cloneFirstWordByDelimiter(char *line,char delimit); /* Returns a cloned first word, not harming the memory passed in Delimiter of ' ' will delimit by isspace() */ #define cloneFirstWordInLine(line) cloneFirstWordByDelimiter((line),' ') #define cloneFirstWordByTab(line) cloneFirstWordByDelimiter((line),'\t') /* Returns a cloned first word, not harming the memory passed in */ char *cloneNextWordByDelimiter(char **line,char delimit); /* Returns a cloned first word, advancing the line pointer