src/lib/localmem.c 1.12

1.12 2009/12/01 23:10:44 kent
Adding lmCloneFirstWord
Index: src/lib/localmem.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/localmem.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -b -B -U 4 -r1.11 -r1.12
--- src/lib/localmem.c	20 Nov 2009 20:26:27 -0000	1.11
+++ src/lib/localmem.c	1 Dec 2009 23:10:44 -0000	1.12
@@ -119,8 +119,22 @@
 else
     return lmCloneStringZ(lm, string, strlen(string));
 }
 
+char *lmCloneFirstWord(struct lm *lm, char *line)
+/* Clone first word in line */
+{
+char *startFirstWord = skipLeadingSpaces(line);
+if (startFirstWord == NULL)
+    return NULL;
+char *endFirstWord = skipToSpaces(startFirstWord);
+if (endFirstWord == NULL)
+    return lmCloneString(lm, startFirstWord);
+else
+    return lmCloneStringZ(lm, startFirstWord, endFirstWord - startFirstWord);
+}
+    
+
 struct slName *lmSlName(struct lm *lm, char *name)
 /* Return slName in memory. */
 {
 struct slName *n;