Browse code

core: helper function to search a token before an end pointer

Daniel-Constantin Mierla authored on 28/10/2020 07:26:06
Showing 2 changed files
... ...
@@ -296,6 +296,29 @@ char *str_search(str *text, str *needle)
296 296
     return NULL;
297 297
 }
298 298
 
299
+/**
300
+ * @brief search for occurence of needlez starting from vstart and before vend
301
+ * @return pointer to start of needle in text or NULL if the needle
302
+ *	is not found
303
+ */
304
+char *stre_search_strz(char *vstart, char *vend, char *needlez)
305
+{
306
+    str text;
307
+    str needle;
308
+
309
+	if(vend <= vstart) {
310
+		return NULL;
311
+	}
312
+
313
+	text.s = vstart;
314
+	text.len = vend - vstart;
315
+
316
+	needle.s = needlez;
317
+	needle.len = strlen(needlez);
318
+
319
+    return str_search(&text, &needle);
320
+}
321
+
299 322
 /**
300 323
  * @brief case insensitive search for occurence of needle in text
301 324
  * @return pointer to start of needle in text or NULL if the needle
... ...
@@ -1057,6 +1057,8 @@ char* get_abs_pathname(str* base, str* file);
1057 1057
  */
1058 1058
 char *str_search(str *text, str *needle);
1059 1059
 
1060
+char *stre_search_strz(char *vstart, char *vend, char *needlez);
1061
+
1060 1062
 char *str_casesearch(str *text, str *needle);
1061 1063
 
1062 1064
 char *strz_casesearch_strz(char *textz, char *needlez);