MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:bar Date:August 8 2005 2:52pm
Subject:bk commit into 4.1 tree (bar:1.2350) BUG#5439
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2350 05/08/08 19:52:30 bar@stripped +4 -0
  Bug#5439 : mysql_server_init() crashes if ShiftJIS path is passed
  (important for Adobe).
  
  mf_pack.c, mf_dirname.c, charset.c, my_sys.h:
  
    - adding fs_character_set() function on Windows
    - ignoring fake slashes which are just multibyte
      parts in several functions in /mysys
  
  Verified by Shu to work on WinXP and Win2k.
  Test is not possible, or very hard to do.

  mysys/mf_pack.c
    1.21 05/08/08 19:51:18 bar@stripped +12 -0
    d

  mysys/mf_dirname.c
    1.11 05/08/08 19:51:16 bar@stripped +32 -1
    d

  mysys/charset.c
    1.137 05/08/08 19:51:11 bar@stripped +26 -0
    d

  include/my_sys.h
    1.139 05/08/08 19:49:54 bar@stripped +5 -0
    Bug#5439 : mysql_server_init() crashes if ShiftJIS path is passed
    (important for Adobe)
    - adding fs_character_set() function on Windows
    - ignoring fake slashes which are just multibyte
      parts in several functions in /mysys

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bar
# Host:	bar.intranet.mysql.r18.ru
# Root:	/usr/home/bar/mysql-4.1.b5439

--- 1.138/include/my_sys.h	2005-07-20 15:27:52 +05:00
+++ 1.139/include/my_sys.h	2005-08-08 19:49:54 +05:00
@@ -788,6 +788,11 @@
 extern void add_compiled_collation(CHARSET_INFO *cs);
 extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
                                      const char *from, ulong length);
+#ifdef __WIN__
+#define BACKSLASH_MBTAIL
+/* File system character set */
+extern CHARSET_INFO *fs_character_set(void);
+#endif
 
 #ifdef __WIN__
 extern my_bool have_tcpip;		/* Is set if tcpip is used */

--- 1.136/mysys/charset.c	2005-07-25 21:32:40 +05:00
+++ 1.137/mysys/charset.c	2005-08-08 19:51:11 +05:00
@@ -637,3 +637,29 @@
   *to= 0;
   return (ulong) (to - to_start);
 }
+
+
+#ifdef BACKSLASH_MBTAIL
+static CHARSET_INFO *fs_cset_cache= NULL;
+
+CHARSET_INFO *fs_character_set()
+{
+  if (!fs_cset_cache)
+  {
+    char buf[10]= "cp";
+    GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE,
+                  buf+2, sizeof(buf)-3);
+    /*
+      We cannot call get_charset_by_name here
+      because fs_character_set() is executed before
+      LOCK_THD_charset mutex initialization, which
+      is used inside get_charset_by_name.
+      As we're now interested in cp932 only,
+      let's just detect it using strcmp().
+    */
+    fs_cset_cache= !strcmp(buf, "cp932") ?
+                   &my_charset_cp932_japanese_ci : &my_charset_bin;
+  }
+  return fs_cset_cache;
+}
+#endif

--- 1.10/mysys/mf_dirname.c	2003-10-07 16:12:07 +05:00
+++ 1.11/mysys/mf_dirname.c	2005-08-08 19:51:16 +05:00
@@ -22,6 +22,9 @@
 uint dirname_length(const char *name)
 {
   register my_string pos,gpos;
+#ifdef BASKSLASH_MBTAIL
+  CHARSET_INFO *fs= fs_character_set();
+#endif
 #ifdef FN_DEVCHAR
   if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0)
 #endif
@@ -29,12 +32,22 @@
 
   gpos= pos++;
   for ( ; *pos ; pos++)				/* Find last FN_LIBCHAR */
+  {
+#ifdef BASKSLASH_MBTAIL
+    uint l;
+    if (use_mb(fs) && (l= my_ismbchar(fs, pos, pos + 3)))
+    {
+      pos+= l - 1;
+      continue;
+    }
+#endif
     if (*pos == FN_LIBCHAR || *pos == '/'
 #ifdef FN_C_AFTER_DIR
 	|| *pos == FN_C_AFTER_DIR || *pos == FN_C_AFTER_DIR_2
 #endif
 	)
       gpos=pos;
+  }
   return ((uint) (uint) (gpos+1-(char*) name));
 }
 
@@ -85,6 +98,9 @@
 char *convert_dirname(char *to, const char *from, const char *from_end)
 {
   char *to_org=to;
+#ifdef BACKSLASH_MBTAIL
+  CHARSET_INFO *fs= fs_character_set();
+#endif
 
   /* We use -2 here, becasue we need place for the last FN_LIBCHAR */
   if (!from_end || (from_end - from) > FN_REFLEN-2)
@@ -103,7 +119,22 @@
 	*to++= FN_C_AFTER_DIR;
 #endif
       else
-	*to++= *from;
+      {
+#ifdef BACKSLASH_MBTAIL
+        uint l;
+        if (use_mb(fs) && (l= my_ismbchar(fs, from, from + 3)))
+        {
+          memmove(to, from, l);
+          to+= l;
+          from+= l - 1;
+          to_org= to; /* Don't look inside mbchar */
+        }
+        else
+#endif
+        {
+          *to++= *from;
+        }
+      }
     }
     *to=0;
   }

--- 1.20/mysys/mf_pack.c	2005-05-21 02:53:34 +05:00
+++ 1.21/mysys/mf_pack.c	2005-08-08 19:51:18 +05:00
@@ -124,6 +124,9 @@
   reg4 my_string start;
   char parent[5],				/* for "FN_PARENTDIR" */
        buff[FN_REFLEN+1],*end_parentdir;
+#ifdef BACKSLASH_MBTAIL
+  CHARSET_INFO *fs= fs_character_set();
+#endif
   DBUG_ENTER("cleanup_dirname");
   DBUG_PRINT("enter",("from: '%s'",from));
 
@@ -141,6 +144,15 @@
   length=(uint) (strmov(parent+1,FN_PARENTDIR)-parent);
   for (pos=start ; (*pos= *from_ptr++) != 0 ; pos++)
   {
+#ifdef BACKSLASH_MBTAIL
+    uint l;
+    if (use_mb(fs) && (l= my_ismbchar(fs, from_ptr - 1, from_ptr + 2)))
+    {
+      for (l-- ; l ; *++pos= *from_ptr++, l--);
+      start= pos + 1; /* Don't look inside multi-byte char */
+      continue;
+    }
+#endif
     if (*pos == '/')
       *pos = FN_LIBCHAR;
     if (*pos == FN_LIBCHAR)
Thread
bk commit into 4.1 tree (bar:1.2350) BUG#5439bar8 Aug