Browse code

core: ut - fixed str_casesearch() - fixed str_casesearch() behaviour on text and needle were equal

Boris Korzun authored on 25/05/2021 14:00:19 • Daniel-Constantin Mierla committed on 25/05/2021 17:11:35
Showing 1 changed files
... ...
@@ -353,7 +353,7 @@ char *stre_search_strz(char *vstart, char *vend, char *needlez)
353 353
 char *str_casesearch(str *text, str *needle)
354 354
 {
355 355
 	int i,j;
356
-	for(i=0;i<text->len-needle->len;i++) {
356
+	for(i=0;i<=text->len-needle->len;i++) {
357 357
 		for(j=0;j<needle->len;j++) {
358 358
 			if ( !((text->s[i+j]==needle->s[j]) ||
359 359
 					( isalpha((int)text->s[i+j])
... ...
@@ -363,7 +363,7 @@ char *str_casesearch(str *text, str *needle)
363 363
 		if (j==needle->len)
364 364
 			return text->s+i;
365 365
 	}
366
-	return 0;
366
+	return NULL;
367 367
 }
368 368
 
369 369
 /**