From 96fd7673c2f131dcf3609c502da86bdd39f680db Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Sat, 25 Apr 2009 10:35:42 +0200 Subject: [PATCH] Add strcasestr() from uclibc to unbreak (Open)Solaris build. Closes #3222. --- ChangeLog | 23 +++++++++++++++++++++++ configure.ac | 1 + protos.h | 4 ++++ strcasestr.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 strcasestr.c diff --git a/ChangeLog b/ChangeLog index 9b807e90..1dba001b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2009-04-21 15:10 -0400 Aron Griffis (3d89eddb2d9a) + + * buffy.c: Equivalent mutt_buffy, but readable code + + Signed-off-by: Aron Griffis + +2009-04-21 15:06 -0400 Aron Griffis (7bc332ddd8fc) + + * buffy.c, buffy.h: Call mutt_expand_path() from mutt_buffy to fix + imap separator. Closes #3208 and #3218 + + Signed-off-by: Aron Griffis + +2009-04-21 14:09 -0400 Aron Griffis (1dc96cc13a87) + + * buffy.c: Use slen instead of assuming _POSIX_PATH_MAX + + Signed-off-by: Aron Griffis + +2009-04-23 12:51 -0700 Vincent Lefevre (b5b4e652e4b1) + + * ChangeLog, po/fr.po: Updated French translation. + 2009-04-20 18:36 +0200 Christoph Berg (39fee3a9d034) * doc/manual.xml.head, init.h: Better document that some send-hooks diff --git a/configure.ac b/configure.ac index c4534433..fe479b7a 100644 --- a/configure.ac +++ b/configure.ac @@ -344,6 +344,7 @@ AC_CHECK_TYPE(ssize_t, int) AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror) AC_REPLACE_FUNCS([setenv strcasecmp strdup strsep strtok_r wcscasecmp]) +AC_REPLACE_FUNCS([strcasestr]) AC_CHECK_FUNC(getopt) if test $ac_cv_func_getopt = yes; then diff --git a/protos.h b/protos.h index bc49b8df..6fcc6015 100644 --- a/protos.h +++ b/protos.h @@ -552,3 +552,7 @@ char *strtok_r (char *, const char *, char **); #ifndef HAVE_WCSCASECMP int wcscasecmp (const wchar_t *a, const wchar_t *b); #endif + +#ifndef HAVE_STRCASESTR +char *strcasestr (const char *, const char *); +#endif diff --git a/strcasestr.c b/strcasestr.c new file mode 100644 index 00000000..a93b6af2 --- /dev/null +++ b/strcasestr.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2002 Manuel Novoa III + * Copyright (C) 2000-2005 Erik Andersen + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ +#include +#include + +char *strcasestr(const char *s1, const char *s2) +{ + register const char *s = s1; + register const char *p = s2; + +#if 1 + do { + if (!*p) { + return (char *) s1;; + } + if ((*p == *s) + || (tolower(*((unsigned char *)p)) == tolower(*((unsigned char *)s))) + ) { + ++p; + ++s; + } else { + p = s2; + if (!*s) { + return NULL; + } + s = ++s1; + } + } while (1); +#else + while (*p && *s) { + if ((*p == *s) + || (tolower(*((unsigned char *)p)) == tolower(*((unsigned char *)s))) + ) { + ++p; + ++s; + } else { + p = s2; + s = ++s1; + } + } + + return (*p) ? NULL : (char *) s1; +#endif +} -- 2.40.0