[util] add strcasestr related util function
authorShinwoo Kim <cinoo.kim@samsung.com>
Tue, 23 Aug 2011 01:15:56 +0000 (10:15 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Tue, 23 Aug 2011 01:30:40 +0000 (10:30 +0900)
Change-Id: I7e64ec774b74cf18a853f6947c9536d023d5d821

configure.ac
src/lib/elm_entry.c

index 59a5f8f..45c83ab 100755 (executable)
@@ -175,6 +175,7 @@ dnl managed by evil
       have_socket="yes"
       ;;
 esac
+AC_CHECK_FUNCS(strcasestr, AC_DEFINE(HAVE_STRCASESTR))
 AM_CONDITIONAL([BUILD_RUN], [test "x$have_socket" = "xyes"])
 
 m4_ifdef([v_mic],
index 8d4f861..1c9f3b3 100644 (file)
@@ -1689,6 +1689,27 @@ _entry_length_get(Evas_Object *obj)
    return len;
 }
 
+#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
+
 static void
 _matchlist_show(void *data)
 {
@@ -1733,7 +1754,11 @@ _matchlist_show(void *data)
              if (wd->matchlist_case_sensitive)
                str_result = strstr(str_list, text);
              else
-               str_result = strcasestr(str_list, text);
+#ifdef HAVE_STRCASESTR
+                str_result = strcasestr(str_list, text);
+#else
+                str_result = _strcasestr(str_list, text);
+#endif
 
              if (str_result)
                {