diff src/c/urweb.c @ 1390:65fbb250b875

More string processing
author Adam Chlipala <adam@chlipala.net>
date Thu, 13 Jan 2011 10:02:50 -0500
parents 9a721f0722d3
children e305ffee2b5b
line wrap: on
line diff
--- a/src/c/urweb.c	Tue Jan 11 18:04:52 2011 -0500
+++ b/src/c/urweb.c	Thu Jan 13 10:02:50 2011 -0500
@@ -2194,6 +2194,17 @@
   }
 }
 
+uw_Basis_int *uw_Basis_strsindex(uw_context ctx, const char *haystack, const char *needle) {
+  uw_Basis_string r = strstr(haystack, needle);
+  if (r == NULL)
+    return NULL;
+  else {
+    uw_Basis_int *nr = uw_malloc(ctx, sizeof(uw_Basis_int));
+    *nr = r - haystack;
+    return nr;
+  }
+}
+
 uw_Basis_string uw_Basis_strcat(uw_context ctx, uw_Basis_string s1, uw_Basis_string s2) {
   int len = uw_Basis_strlen(ctx, s1) + uw_Basis_strlen(ctx, s2) + 1;
   char *s;