/[mailutils]/mailutils/libsieve/comparator.c
ViewVC logotype

Diff of /mailutils/libsieve/comparator.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by gray, Sat Mar 29 17:00:38 2003 UTC revision 1.14 by gray, Sat Jul 26 11:08:06 2003 UTC
# Line 28  Line 28 
28  #include <regex.h>  #include <regex.h>
29    
30  typedef struct {  typedef struct {
31    char *name;    const char *name;
32    int required;    int required;
33    sieve_comparator_t comp[MU_SIEVE_MATCH_LAST];    sieve_comparator_t comp[MU_SIEVE_MATCH_LAST];
34  } sieve_comparator_record_t;  } sieve_comparator_record_t;
# Line 413  i_ascii_casemap_is (const char *pattern, Line 413  i_ascii_casemap_is (const char *pattern,
413    return strcasecmp (pattern, text) == 0;    return strcasecmp (pattern, text) == 0;
414  }  }
415    
 /* Based on strstr from GNU libc (Stephen R. van den Berg,  
    berg@pool.informatik.rwth-aachen.de) */  
   
416  static int  static int
417  i_ascii_casemap_contains (const char *pattern, const char *text)  i_ascii_casemap_contains (const char *pattern, const char *text)
418  {  {
419    register const unsigned char *haystack, *needle;    return mu_strcasestr (text, pattern) != NULL;
   register unsigned int b, c;  
   
 #define U(c) toupper (c)  
     
   haystack = (const unsigned char *)text;  
   
   if ((b = U (*(needle = (const unsigned char*)pattern))))  
     {  
       haystack--;                
       do  
         {  
           if (!(c = *++haystack))  
             goto ret0;  
         }  
       while (U (c) != b);  
   
       if (!(c = *++needle))  
         goto foundneedle;  
   
       c = U (c);  
       ++needle;  
       goto jin;  
   
       for (;;)  
         {  
           register unsigned int a;  
           register const unsigned char *rhaystack, *rneedle;  
   
           do  
             {  
               if (!(a = *++haystack))  
                 goto ret0;  
               if (U (a) == b)  
                 break;  
               if (!(a = *++haystack))  
                 goto ret0;  
 shloop:       ;  
             }  
           while (U (a) != b);  
             
 jin:     if (!(a = *++haystack))  
             goto ret0;  
   
           if (U (a) != c)  
             goto shloop;  
   
           if (U (*(rhaystack = haystack-- + 1)) ==  
               (a = U (*(rneedle = needle))))  
             do  
               {  
                 if (!a)  
                   goto foundneedle;  
                 if (U (*++rhaystack) != (a = U (*++needle)))  
                   break;  
                 if (!a)  
                   goto foundneedle;  
               }  
             while (U (*++rhaystack) == (a = U (*++needle)));  
   
           needle = rneedle;  
   
           if (!a)  
             break;  
         }  
     }  
 foundneedle:  
   return 1;  
 ret0:  
   return 0;  
   
 #undef U  
420  }  }
421    
422  static int  static int

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26