src/lib/localmem.c 1.13
1.13 2009/12/03 20:04:29 kent
Adding lmCloneSomeWord.
Index: src/lib/localmem.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/localmem.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -b -B -U 4 -r1.12 -r1.13
--- src/lib/localmem.c 1 Dec 2009 23:10:44 -0000 1.12
+++ src/lib/localmem.c 3 Dec 2009 20:04:29 -0000 1.13
@@ -132,8 +132,25 @@
else
return lmCloneStringZ(lm, startFirstWord, endFirstWord - startFirstWord);
}
+char *lmCloneSomeWord(struct lm *lm, char *line, int wordIx)
+/* Return a clone of the given space-delimited word within line. Returns NULL if
+ * not that many words in line. */
+{
+if (wordIx < 0)
+ return NULL;
+int i;
+for (i=0; i<wordIx; ++i)
+ {
+ line = skipLeadingSpaces(line);
+ line = skipToSpaces(line);
+ if (line == NULL)
+ return NULL;
+ }
+return lmCloneFirstWord(lm, line);
+}
+
struct slName *lmSlName(struct lm *lm, char *name)
/* Return slName in memory. */
{