diff lib/lib.c @ 1345:b7598d21ca10 draft

Forgot to check in strstart().
author Rob Landley <rob@landley.net>
date Mon, 09 Jun 2014 07:12:49 -0500
parents 313980d3d78c
children 46f068aaa480
line wrap: on
line diff
--- a/lib/lib.c	Mon Jun 09 07:07:33 2014 -0500
+++ b/lib/lib.c	Mon Jun 09 07:12:49 2014 -0500
@@ -280,6 +280,16 @@
   return off-haystack;
 }
 
+// If *a starts with b, advance *a past it and return 1, else return 0;
+int strstart(char **a, char *b)
+{
+  int len = strlen(b), i = !strncmp(*a, b, len);
+
+  if (i) *a += len;
+
+  return i;
+}
+
 // Return how long the file at fd is, if there's any way to determine it.
 off_t fdlength(int fd)
 {