]> code.citadel.org Git - citadel.git/blobdiff - citadel/tools.c
* Removed the bmstrstr() function, and replaced all calls to it with calls
[citadel.git] / citadel / tools.c
index 69961493efbbbe85e59e6b0200c928028dabaea8..69cb23d443d2382c015af575854250154f85248f 100644 (file)
@@ -550,70 +550,6 @@ void urlesc(char *outbuf, char *strbuf)
 }
 
 
-/*
- * bmstrstr() is a variant of strstr() that uses the Boyer-Moore search
- * algorithm, and can use any caller-supplied string compare function whose
- * calling syntax is similar to strncmp().  For example, we can supply it
- * with strncasecmp() to do a case-insensitive search.
- * 
- * Original code: copyright (c) 1997-1998 by Urs Janssen <urs@tin.org>
- * Modifications: copyright (c) 2003 by Art Cancro <ajc@uncensored.citadel.org>
- */
-char *bmstrstr(char *text, char *pattern,
-       int (*cmpfunc)(const char *, const char *, size_t) )
-{
-       register unsigned char *p, *t;
-       register int i, j, *delta;
-       register size_t p1;
-       int deltaspace[256];
-       size_t textlen;
-       size_t patlen;
-
-       if (text == NULL) return(NULL);
-       if (pattern == NULL) return(NULL);
-
-       textlen = strlen(text);
-       patlen = strlen(pattern);
-
-       /* algorithm fails if pattern is empty */
-       if ((p1 = patlen) == 0)
-               return (text);
-
-       /* code below fails (whenever i is unsigned) if pattern too long */
-       if (p1 > textlen)
-               return (NULL);
-
-       /* set up deltas */
-       delta = deltaspace;
-       for (i = 0; i <= 255; i++)
-               delta[i] = p1;
-       for (p = (unsigned char *) pattern, i = p1; --i > 0;)
-               delta[*p++] = i;
-
-       /*
-        * From now on, we want patlen - 1.
-        * In the loop below, p points to the end of the pattern,
-        * t points to the end of the text to be tested against the
-        * pattern, and i counts the amount of text remaining, not
-        * including the part to be tested.
-        */
-       p1--;
-       p = (unsigned char *) pattern + p1;
-       t = (unsigned char *) text + p1;
-       i = textlen - patlen;
-       while (1) {
-               if (tolower(*p) == tolower(*t)
-                  && cmpfunc((p - p1), (t - p1), p1) == 0)
-                       return ((char *) t - p1);
-               j = delta[*t];
-               if (i < j)
-                       break;
-               i -= j;
-               t += j;
-       }
-       return (NULL);
-}
-
 
 /*
  * In our world, we want strcpy() to be able to work with overlapping strings.