Blob Blame History Raw
The symbol my_charset_latin1 is not exported, but upstream uses it probably,
since they use some weird environment with mysql buildroot. Anyway, it is only
used only for case-insensitive comparison of encoding identificators, which
should include only ASCII chars. So we really don't need any charset
information and can use simple case-insensitive strcmp.

However, the only function doing that is defined at driver/utility.c so it
would be better to move it to util/stringutil.c and have it available as
a general purpose function. That's basically what this patch does.

diff -up --recursive mysql-connector-odbc-5.3.2-src.orig/util/stringutil.c mysql-connector-odbc-5.3.2-src/util/stringutil.c
--- mysql-connector-odbc-5.3.2-src.orig/util/stringutil.c	2014-03-26 22:20:55.000000000 +0100
+++ mysql-connector-odbc-5.3.2-src/util/stringutil.c	2014-06-12 16:55:18.093235491 +0200
@@ -925,13 +925,40 @@ static const MY_CSET_OS_NAME charsets[]=
 };
 
 
+/*
+ *   @type    : myodbc internal
+ *   @purpose : compare strings without regarding to case
+ */
+
+int myodbc_strcasecmp(const char *s, const char *t)
+{
+  while (toupper(*s) == toupper(*t++))
+    if (!*s++)
+      return 0;
+  return((int) toupper(s[0]) - (int) toupper(t[-1]));
+}
+
+
+/*
+  @type    : myodbc internal
+  @purpose : compare strings without regarding to case
+*/
+
+int myodbc_casecmp(const char *s, const char *t, uint len)
+{
+  while (len-- != 0 && toupper(*s++) == toupper(*t++))
+    ;
+  return (int)len + 1;
+}
+
+
 const char *
 my_os_charset_to_mysql_charset(const char *csname)
 {
   const MY_CSET_OS_NAME *csp;
   for (csp= charsets; csp->os_name; ++csp)
   {
-    if (!my_strcasecmp(&my_charset_latin1, csp->os_name, csname))
+    if (!myodbc_strcasecmp(csp->os_name, csname))
     {
       switch (csp->param)
       {
diff -up --recursive mysql-connector-odbc-5.3.2-src.orig/util/stringutil.h mysql-connector-odbc-5.3.2-src/util/stringutil.h
--- mysql-connector-odbc-5.3.2-src.orig/util/stringutil.h	2014-03-26 22:20:55.000000000 +0100
+++ mysql-connector-odbc-5.3.2-src/util/stringutil.h	2014-06-12 16:55:18.094235489 +0200
@@ -119,6 +119,8 @@ SQLWCHAR *wchar_t_as_sqlwchar(wchar_t *f
 
 char * myodbc_strlwr(char *target, size_t len);
 SQLCHAR* sqlwchar_as_utf8_simple(SQLWCHAR *s);
+int myodbc_strcasecmp(const char *s, const char *t);
+int myodbc_casecmp(const char *s, const char *t, uint len);
 
 #ifdef __cplusplus
 }
--- mysql-connector-odbc-5.3.2-src.orig/driver/utility.c	2014-06-16 13:11:32.417200884 +0200
+++ mysql-connector-odbc-5.3.2-src/driver/utility.c	2014-06-16 13:26:12.071513337 +0200
@@ -2314,53 +2314,6 @@ my_bool reget_current_catalog(DBC *dbc)
 
 
-/*
-  @type    : myodbc internal
-  @purpose : compare strings without regarding to case
-*/
-
-int myodbc_strcasecmp(const char *s, const char *t)
-{
-  if (!s && !t)
-  {
-    return 0;
-  }
-
-  if (!s || !t)
-  {
-    return 1;
-  }
-
-  while (toupper((uchar) *s) == toupper((uchar) *t++))
-    if (!*s++)
-      return 0;
-  return((int) toupper((uchar) s[0]) - (int) toupper((uchar) t[-1]));
-}
-
-
-/*
-  @type    : myodbc internal
-  @purpose : compare strings without regarding to case
-*/
-
-int myodbc_casecmp(const char *s, const char *t, uint len)
-{
-  if (!s && !t)
-  {
-    return 0;
-  }
-
-  if (!s || !t)
-  {
-    return (int)len + 1;
-  }
-
-  while (len-- != 0 && toupper(*s++) == toupper(*t++))
-    ;
-  return (int)len + 1;
-}
-
-
 /*
   @type    : myodbc3 internal
   @purpose : logs the queries sent to server
 */