From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: expand-file-name problem for eight-bit-control/graphic Date: Thu, 13 Mar 2003 16:47:57 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200303130747.QAA21083@etlken.m17n.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1047541983 7886 80.91.224.249 (13 Mar 2003 07:53:03 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 13 Mar 2003 07:53:03 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Mar 13 08:53:00 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18tNWO-00022g-00 for ; Thu, 13 Mar 2003 08:53:00 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18tNu1-0002EW-00 for ; Thu, 13 Mar 2003 09:17:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18tNSt-0005uU-05 for emacs-devel@quimby.gnus.org; Thu, 13 Mar 2003 02:49:23 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18tNSI-0005Xd-00 for emacs-devel@gnu.org; Thu, 13 Mar 2003 02:48:46 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18tNRv-00050o-00 for emacs-devel@gnu.org; Thu, 13 Mar 2003 02:48:24 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18tNRY-0004CP-00 for emacs-devel@gnu.org; Thu, 13 Mar 2003 02:48:00 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h2D7lv922539 for ; Thu, 13 Mar 2003 16:47:57 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) by fs.m17n.org (8.11.6/3.7W-20010823150639) with ESMTP id h2D7lvA05665 for ; Thu, 13 Mar 2003 16:47:57 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id QAA21083; Thu, 13 Mar 2003 16:47:57 +0900 (JST) Original-To: emacs-devel@gnu.org User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:12327 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:12327 I've just found that expand-file-name sometimes converts unibyte filename to multibyte, and multibyte filename to unibyte. Ex.1 unibyte->multibyte (expand-file-name "~/\201\300") =3D> "/home/handa/=C0" Ex.2 multibyte->unibyte (expand-file-name "~/=C0\200") =3D> "/home/handa/\201\300\236\240" The reason is that it uses make_string and build_string blindly. It seems that the attached patch fixes this bug, but, as expand-file-name is one of heavily system-dependent parts, and has lots of "#ifdef", I'd like to ask the other poeple to confirm this patch doesn't cause any problem. --- Ken'ichi HANDA handa@m17n.org 2003-03-13 Kenichi Handa * fileio.c (Fexpand_file_name): Preserve multibyteness of NAME in the return value. *** fileio.c.~1.474.~ Mon Feb 3 09:16:21 2003 --- fileio.c Thu Mar 13 16:28:58 2003 *************** *** 1028,1033 **** --- 1028,1034 ---- #endif /* DOS_NT */ int length; Lisp_Object handler; + int multibyte; =20 CHECK_STRING (name); =20 *************** *** 1111,1116 **** --- 1112,1123 ---- name =3D FILE_SYSTEM_CASE (name); #endif =20 + if (STRING_MULTIBYTE (default_directory)) + default_directory =3D ENCODE_FILE (default_directory); + multibyte =3D STRING_MULTIBYTE (name); + if (multibyte) + name =3D ENCODE_FILE (name); +=20 nm =3D SDATA (name); =20 #ifdef DOS_NT *************** *** 1275,1281 **** { #ifdef VMS if (index (nm, '/')) ! return build_string (sys_translate_unix (nm)); #endif /* VMS */ #ifdef DOS_NT /* Make sure directories are all separated with / or \ as --- 1282,1294 ---- { #ifdef VMS if (index (nm, '/')) ! { ! nm =3D sys_translate_unix (nm); ! name =3D make_unibyte_string (nm, strlen (nm)); ! if (multibyte) ! name =3D DECODE_FILE (name); ! return name; ! } #endif /* VMS */ #ifdef DOS_NT /* Make sure directories are all separated with / or \ as *************** *** 1286,1307 **** if (IS_DIRECTORY_SEP (nm[1])) { if (strcmp (nm, SDATA (name)) !=3D 0) ! name =3D build_string (nm); } else #endif /* drive must be set, so this is okay */ if (strcmp (nm - 2, SDATA (name)) !=3D 0) { ! name =3D make_string (nm - 2, p - nm + 2); SSET (name, 0, DRIVE_LETTER (drive)); SSET (name, 1, ':'); } return name; #else /* not DOS_NT */ ! if (nm =3D=3D SDATA (name)) ! return name; ! return build_string (nm); #endif /* not DOS_NT */ } } --- 1299,1324 ---- if (IS_DIRECTORY_SEP (nm[1])) { if (strcmp (nm, SDATA (name)) !=3D 0) ! name =3D make_unibyte_string (nm, strlen (nm)); } else #endif /* drive must be set, so this is okay */ if (strcmp (nm - 2, SDATA (name)) !=3D 0) { ! name =3D make_unibyte_string (nm - 2, p - nm + 2); SSET (name, 0, DRIVE_LETTER (drive)); SSET (name, 1, ':'); } + if (multibyte) + name =3D DECODE_FILE (name); return name; #else /* not DOS_NT */ ! if (nm !=3D SDATA (name)) ! name =3D make_unibyte_string (nm, strlen (nm)); ! if (multibyte) ! name =3D DECODE_FILE (name); ! return name; #endif /* not DOS_NT */ } } *************** *** 1670,1676 **** CORRECT_DIR_SEPS (target); #endif /* DOS_NT */ =20 ! return make_string (target, o - target); } =20 #if 0 --- 1687,1696 ---- CORRECT_DIR_SEPS (target); #endif /* DOS_NT */ =20 ! name =3D make_unibyte_string (target, o - target); ! if (multibyte) ! name =3D DECODE_FILE (name); ! return name; } =20 #if 0