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: Re: expand-file-name problem for eight-bit-control/graphic Date: Tue, 18 Mar 2003 11:03:35 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200303180203.LAA27619@etlken.m17n.org> References: <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=US-ASCII X-Trace: main.gmane.org 1047953090 9132 80.91.224.249 (18 Mar 2003 02:04:50 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 18 Mar 2003 02:04:50 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Mar 18 03:04:49 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 18v6TA-0002NA-00 for ; Tue, 18 Mar 2003 03:04:48 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18v6TE-00027B-00 for ; Tue, 18 Mar 2003 03:04:52 +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 18v6SY-0007Pm-01 for emacs-devel@quimby.gnus.org; Mon, 17 Mar 2003 21:04:10 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18v6S5-0007Ho-00 for emacs-devel@gnu.org; Mon, 17 Mar 2003 21:03:41 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18v6S3-0007CY-00 for emacs-devel@gnu.org; Mon, 17 Mar 2003 21:03:40 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18v6S2-00073o-00; Mon, 17 Mar 2003 21:03:38 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h2I23a913404; Tue, 18 Mar 2003 11:03:36 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) h2I23aA00539; Tue, 18 Mar 2003 11:03:36 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id LAA27619; Tue, 18 Mar 2003 11:03:35 +0900 (JST) Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Sat, 15 Mar 2003 01:54:42 -0500) 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:12425 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:12425 In article , Richard Stallman writes: > I have a lot of doubts about this code, because it seems to encode and > then decode the file name. Since the arguments and values are both > strings for use within Emacs, I think it is incorrect for > expand-file-name to ever encode or decode a file name. But, at least, we can't use build_string and make_string blindly to reconstruct a file name. So, how about the attached change? --- Ken'ichi HANDA handa@m17n.org *** fileio.c.~1.474.~ Tue Mar 18 09:59:02 2003 --- fileio.c Tue Mar 18 10:52:33 2003 *************** *** 992,997 **** --- 992,1014 ---- + /* Return a string made from NBYTES bytes at P. If MULTIBYTE is + nonzero, the string is multibyte (it is assumed that the bytes are + in correct multibyte form). If MULTIBYTE is zero, the string is + unibyte. */ + + static Lisp_Object + bytes_to_string (unsigned char *p, int nbytes, int multibyte) + { + int nchars; + + if (! multibyte) + return make_unibyte_string ((char *) p, nbytes); + nchars = multibyte_chars_in_text (p, nbytes); + return make_multibyte_string ((char *) p, nchars, nbytes); + } + + DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, doc: /* Convert filename NAME to absolute, and canonicalize it. Second arg DEFAULT-DIRECTORY is directory to start with if NAME is relative *************** *** 1028,1033 **** --- 1045,1051 ---- #endif /* DOS_NT */ int length; Lisp_Object handler; + int multibyte; CHECK_STRING (name); *************** *** 1111,1116 **** --- 1129,1135 ---- name = FILE_SYSTEM_CASE (name); #endif + multibyte = STRING_MULTIBYTE (name); nm = SDATA (name); #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 --- 1294,1304 ---- { #ifdef VMS if (index (nm, '/')) ! { ! nm = sys_translate_unix (nm); ! length = strlen (nm); ! return bytes_to_string (nm, length, multibyte); ! } #endif /* VMS */ #ifdef DOS_NT /* Make sure directories are all separated with / or \ as *************** *** 1286,1299 **** if (IS_DIRECTORY_SEP (nm[1])) { if (strcmp (nm, SDATA (name)) != 0) ! name = build_string (nm); } else #endif /* drive must be set, so this is okay */ if (strcmp (nm - 2, SDATA (name)) != 0) { ! name = make_string (nm - 2, p - nm + 2); SSET (name, 0, DRIVE_LETTER (drive)); SSET (name, 1, ':'); } --- 1309,1322 ---- if (IS_DIRECTORY_SEP (nm[1])) { if (strcmp (nm, SDATA (name)) != 0) ! name = bytes_to_string (nm, strlen (nm), multibyte); } else #endif /* drive must be set, so this is okay */ if (strcmp (nm - 2, SDATA (name)) != 0) { ! name = bytes_to_string (nm, strlen (nm), multibyte); SSET (name, 0, DRIVE_LETTER (drive)); SSET (name, 1, ':'); } *************** *** 1301,1307 **** #else /* not DOS_NT */ if (nm == SDATA (name)) return name; ! return build_string (nm); #endif /* not DOS_NT */ } } --- 1324,1330 ---- #else /* not DOS_NT */ if (nm == SDATA (name)) return name; ! return bytes_to_string (nm, strlen (nm), multibyte); #endif /* not DOS_NT */ } } *************** *** 1670,1676 **** CORRECT_DIR_SEPS (target); #endif /* DOS_NT */ ! return make_string (target, o - target); } #if 0 --- 1693,1699 ---- CORRECT_DIR_SEPS (target); #endif /* DOS_NT */ ! return bytes_to_string (target, o - target, multibyte); } #if 0