comparison 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
comparison
equal deleted inserted replaced
1389:9a721f0722d3 1390:65fbb250b875
2192 *nr = r - s; 2192 *nr = r - s;
2193 return nr; 2193 return nr;
2194 } 2194 }
2195 } 2195 }
2196 2196
2197 uw_Basis_int *uw_Basis_strsindex(uw_context ctx, const char *haystack, const char *needle) {
2198 uw_Basis_string r = strstr(haystack, needle);
2199 if (r == NULL)
2200 return NULL;
2201 else {
2202 uw_Basis_int *nr = uw_malloc(ctx, sizeof(uw_Basis_int));
2203 *nr = r - haystack;
2204 return nr;
2205 }
2206 }
2207
2197 uw_Basis_string uw_Basis_strcat(uw_context ctx, uw_Basis_string s1, uw_Basis_string s2) { 2208 uw_Basis_string uw_Basis_strcat(uw_context ctx, uw_Basis_string s1, uw_Basis_string s2) {
2198 int len = uw_Basis_strlen(ctx, s1) + uw_Basis_strlen(ctx, s2) + 1; 2209 int len = uw_Basis_strlen(ctx, s1) + uw_Basis_strlen(ctx, s2) + 1;
2199 char *s; 2210 char *s;
2200 2211
2201 uw_check_heap(ctx, len); 2212 uw_check_heap(ctx, len);