/[mailutils]/mailutils/mailbox/mutil.c
ViewVC logotype

Diff of /mailutils/mailbox/mutil.c

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

revision 1.50 by gray, Tue Mar 25 22:08:00 2003 UTC revision 1.51 by gray, Sat Jul 26 11:10:00 2003 UTC
# Line 1019  mu_rfc2822_in_reply_to (message_t msg, c Line 1019  mu_rfc2822_in_reply_to (message_t msg, c
1019      }      }
1020    return MU_ERR_FAILURE;    return MU_ERR_FAILURE;
1021  }  }
1022    
1023    /* Based on strstr from GNU libc (Stephen R. van den Berg,
1024       berg@pool.informatik.rwth-aachen.de) */
1025    
1026    char *
1027    mu_strcasestr (const char *a_haystack, const char *a_needle)
1028    {
1029      register const unsigned char *haystack = (unsigned char*) a_haystack,
1030        *needle = (unsigned char*) a_needle;
1031      register unsigned int b, c;
1032    
1033    #define U(c) toupper (c)
1034      if ((b = U (*needle)))
1035        {
1036          haystack--;              
1037          do
1038            {
1039              if (!(c = *++haystack))
1040                goto ret0;
1041            }
1042          while (U (c) != b);
1043    
1044          if (!(c = *++needle))
1045            goto foundneedle;
1046    
1047          c = U (c);
1048          ++needle;
1049          goto jin;
1050    
1051          for (;;)
1052            {
1053              register unsigned int a;
1054              register const unsigned char *rhaystack, *rneedle;
1055    
1056              do
1057                {
1058                  if (!(a = *++haystack))
1059                    goto ret0;
1060                  if (U (a) == b)
1061                    break;
1062                  if (!(a = *++haystack))
1063                    goto ret0;
1064    shloop:       ;
1065                }
1066              while (U (a) != b);
1067              
1068    jin:     if (!(a = *++haystack))
1069                goto ret0;
1070    
1071              if (U (a) != c)
1072                goto shloop;
1073    
1074              if (U (*(rhaystack = haystack-- + 1)) ==
1075                  (a = U (*(rneedle = needle))))
1076                do
1077                  {
1078                    if (!a)
1079                      goto foundneedle;
1080                    if (U (*++rhaystack) != (a = U (*++needle)))
1081                      break;
1082                    if (!a)
1083                      goto foundneedle;
1084                  }
1085                while (U (*++rhaystack) == (a = U (*++needle)));
1086    
1087              needle = rneedle;
1088    
1089              if (!a)
1090                break;
1091            }
1092        }
1093    foundneedle:
1094      return (char*)haystack;
1095    ret0:
1096      return NULL;
1097    
1098    #undef U
1099    }  

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

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