]> granicus.if.org Git - postgis/commitdiff
#2934, support strcasestr for platforms that (passing understanding) do not have it
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 19 Sep 2014 19:07:59 +0000 (19:07 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 19 Sep 2014 19:07:59 +0000 (19:07 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@12989 b70326c6-7e19-0410-871a-916f4a2858ee

configure.ac
liblwgeom/liblwgeom.h.in
liblwgeom/lwutil.c
postgis_config.h.in

index f381763f2f18732d1c66882e733d135f8349539c..671f51e423ee986f46eb69a9c26b6f61f9326303 100644 (file)
@@ -114,6 +114,7 @@ dnl Check for platform-specific functions
 dnl
 AC_CHECK_FUNC(vasprintf, AC_DEFINE([HAVE_VASPRINTF]))
 AC_CHECK_FUNC(asprintf, AC_DEFINE([HAVE_ASPRINTF]))
+AC_CHECK_FUNC(strcasestr, AC_DEFINE([HAVE_STRCASESTR]))
 AC_FUNC_FSEEKO()
 
 dnl 
index 2566beecb854e3cb4b5052736c84467e1ff4f69d..976081d78a137b7f0e122606194a724ea468de1d 100644 (file)
@@ -1877,6 +1877,9 @@ extern void lwfree(void *mem);
 /* Utilities */
 extern char *lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection);
 
+#ifndef HAVE_STRCASESTR
+extern char *strcasestr(const char *s, const char *find);
+#endif
 
 /*******************************************************************************
  * SQLMM internal functions - TODO: Move into separate header files
index 3c4a6bbb069a75fb8e4b01938c8886b06ab025f4..2f858f70d893ba3a09316455ac0c2cf15a62bcfc 100644 (file)
@@ -342,3 +342,24 @@ clamp_srid(int srid)
        
        return newsrid;
 }
+
+#ifndef HAVE_STRCASESTR
+char *strcasestr(const char *s, const char *find)
+{
+  char c, sc;
+  size_t len;
+
+  if ((c = *find++) != 0) {
+    c = tolower((unsigned char)c);
+    len = strlen(find);
+    do {
+      do {
+        if ((sc = *s++) == 0)
+          return (NULL);
+      } while ((char)tolower((unsigned char)sc) != c);
+    } while (strncasecmp(s, find, len) != 0);
+    s--;
+  }
+  return ((char *)s);
+}
+#endif
index 2fe598ae657231377fd3a26ad657ea135cd69502..3d46de2a640ba03346a75fff9a687ac9a36e5acb 100644 (file)
@@ -28,6 +28,7 @@
 #undef HAVE_ISFINITE
 #undef HAVE_GNU_ISFINITE
 #undef HAVE_FSEEKO
+#undef HAVE_STRCASESTR
 
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H