ba63ca047c08a7a20146f2c3216aa3330ece39b2 max Thu Dec 18 06:26:04 2014 -0800 changes after code review, refs #14545 diff --git src/lib/common.c src/lib/common.c index 95b281d..a84f414 100644 --- src/lib/common.c +++ src/lib/common.c @@ -2249,30 +2249,41 @@ } char *cloneFirstWord(char *line) /* Clone first word in line */ { char *startFirstWord = skipLeadingSpaces(line); if (startFirstWord == NULL) return NULL; char *endFirstWord = skipToSpaces(startFirstWord); if (endFirstWord == NULL) return cloneString(startFirstWord); else return cloneStringZ(startFirstWord, endFirstWord - startFirstWord); } +char *cloneNotFirstWord(char *s) +/* return part of string after first space, not changing s. Result has to be freed. */ +{ +if (s==NULL) + return ""; +char* spcPos = stringIn(" ", s); +if (spcPos==NULL) + return cloneString(s); +return cloneString(spcPos+1); +} + 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 *s = line; char *word = NULL, *wordEnd = NULL; for (;;) { s = skipLeadingSpaces(s); if (s == NULL || s[0] == 0) break; word = s; s = wordEnd = skipToSpaces(s); if (s == NULL)