Commit 9712fe1a 9712fe1a79215e5b34bf639628a1359ea5b37feb by Sergey Poznyakoff

(i_ascii_casemap_contains): Reimplemented via mu_strcasestr()

1 parent fb9b2300
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
28 #include <regex.h> 28 #include <regex.h>
29 29
30 typedef struct { 30 typedef struct {
31 char *name; 31 const char *name;
32 int required; 32 int required;
33 sieve_comparator_t comp[MU_SIEVE_MATCH_LAST]; 33 sieve_comparator_t comp[MU_SIEVE_MATCH_LAST];
34 } sieve_comparator_record_t; 34 } sieve_comparator_record_t;
...@@ -413,84 +413,10 @@ i_ascii_casemap_is (const char *pattern, const char *text) ...@@ -413,84 +413,10 @@ i_ascii_casemap_is (const char *pattern, const char *text)
413 return strcasecmp (pattern, text) == 0; 413 return strcasecmp (pattern, text) == 0;
414 } 414 }
415 415
416 /* Based on strstr from GNU libc (Stephen R. van den Berg,
417 berg@pool.informatik.rwth-aachen.de) */
418
419 static int 416 static int
420 i_ascii_casemap_contains (const char *pattern, const char *text) 417 i_ascii_casemap_contains (const char *pattern, const char *text)
421 { 418 {
422 register const unsigned char *haystack, *needle; 419 return mu_strcasestr (text, pattern) != NULL;
423 register unsigned int b, c;
424
425 #define U(c) toupper (c)
426
427 haystack = (const unsigned char *)text;
428
429 if ((b = U (*(needle = (const unsigned char*)pattern))))
430 {
431 haystack--;
432 do
433 {
434 if (!(c = *++haystack))
435 goto ret0;
436 }
437 while (U (c) != b);
438
439 if (!(c = *++needle))
440 goto foundneedle;
441
442 c = U (c);
443 ++needle;
444 goto jin;
445
446 for (;;)
447 {
448 register unsigned int a;
449 register const unsigned char *rhaystack, *rneedle;
450
451 do
452 {
453 if (!(a = *++haystack))
454 goto ret0;
455 if (U (a) == b)
456 break;
457 if (!(a = *++haystack))
458 goto ret0;
459 shloop: ;
460 }
461 while (U (a) != b);
462
463 jin: if (!(a = *++haystack))
464 goto ret0;
465
466 if (U (a) != c)
467 goto shloop;
468
469 if (U (*(rhaystack = haystack-- + 1)) ==
470 (a = U (*(rneedle = needle))))
471 do
472 {
473 if (!a)
474 goto foundneedle;
475 if (U (*++rhaystack) != (a = U (*++needle)))
476 break;
477 if (!a)
478 goto foundneedle;
479 }
480 while (U (*++rhaystack) == (a = U (*++needle)));
481
482 needle = rneedle;
483
484 if (!a)
485 break;
486 }
487 }
488 foundneedle:
489 return 1;
490 ret0:
491 return 0;
492
493 #undef U
494 } 420 }
495 421
496 static int 422 static int
......