From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: 23.0.60; Assuming errstring unibyte is incorrect and leads to Emacs crashes Date: Wed, 27 Aug 2008 10:13:06 +0900 Message-ID: References: <87y72ju1mg.fsf@cyd.mit.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1219799611 29651 80.91.229.12 (27 Aug 2008 01:13:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Aug 2008 01:13:31 +0000 (UTC) Cc: dima@sphinx.net.ru, emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 27 03:14:24 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KY9c7-0005xI-2t for ged-emacs-devel@m.gmane.org; Wed, 27 Aug 2008 03:14:23 +0200 Original-Received: from localhost ([127.0.0.1]:42779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KY9b7-0002Qk-Hq for ged-emacs-devel@m.gmane.org; Tue, 26 Aug 2008 21:13:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KY9b2-0002N4-AM for emacs-devel@gnu.org; Tue, 26 Aug 2008 21:13:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KY9b0-0002K1-9d for emacs-devel@gnu.org; Tue, 26 Aug 2008 21:13:15 -0400 Original-Received: from [199.232.76.173] (port=57819 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KY9b0-0002Jo-5z for emacs-devel@gnu.org; Tue, 26 Aug 2008 21:13:14 -0400 Original-Received: from mx1.aist.go.jp ([150.29.246.133]:33121) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KY9az-0001XQ-6M for emacs-devel@gnu.org; Tue, 26 Aug 2008 21:13:14 -0400 Original-Received: from rqsmtp2.aist.go.jp (rqsmtp2.aist.go.jp [150.29.254.123]) by mx1.aist.go.jp with ESMTP id m7R1D8ik005987; Wed, 27 Aug 2008 10:13:08 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp4.aist.go.jp by rqsmtp2.aist.go.jp with ESMTP id m7R1D8uJ007066; Wed, 27 Aug 2008 10:13:08 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp4.aist.go.jp with ESMTP id m7R1D6e8017926; Wed, 27 Aug 2008 10:13:06 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken.m17n.org with local (Exim 4.69) (envelope-from ) id 1KY9as-0005ES-P7; Wed, 27 Aug 2008 10:13:06 +0900 In-reply-to: <87y72ju1mg.fsf@cyd.mit.edu> (message from Chong Yidong on Tue, 26 Aug 2008 13:28:39 -0400) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-detected-kernel: by monty-python.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:103003 Archived-At: In article <87y72ju1mg.fsf@cyd.mit.edu>, Chong Yidong writes: > Could someone review the patch submitted with bug#778 for correctness? > I've excerpted part of the bug report below; the full report can be > viewed at > http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=778 > Dmitry Dzhus wrote: [...] > > Looks like the issue may be resolved replacing a SSET&SREF call at > > `report_file_error' with something multibyte-aware. I've attached a > > one-line patch which does the job. It makes an assertion that a > > downcase and uppercase character both occupy the same amount of bytes. > > > > Using `Fdowncase' function instead also fixes the problem, but at a > > cost of slight overhead (the whole string gets processed, not just the > > first character (this cannot impact performance seriously though, as I > > believe those `errstring' variables are not processed often)) my patch > > does not introduce. > > > > I've tested the patch with several locales (both problematic and > > traditional ones) and couldn't spot any regression introduced with > > this patch. Unfortunately, downcasing may change character bytes in some locale (e.g. turkish), and if the first character is multibyte, "SREF (errstring, 1)" doesn't give the second character. So, I just installed the following change. 2008-08-27 Kenichi Handa * fileio.c (report_file_error): Fix handling of multibyte error string. Index: fileio.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/fileio.c,v retrieving revision 1.629 retrieving revision 1.630 diff -u -r1.629 -r1.630 --- fileio.c 5 Aug 2008 21:41:14 -0000 1.629 +++ fileio.c 27 Aug 2008 01:11:26 -0000 1.630 @@ -261,8 +261,14 @@ default: /* System error messages are capitalized. Downcase the initial unless it is followed by a slash. */ - if (SREF (errstring, 1) != '/') - SSET (errstring, 0, DOWNCASE (SREF (errstring, 0))); + if (! EQ (Faref (errstring, make_number (1)), make_number ('/'))) + { + int c; + + str = (char *) SDATA (errstring); + c = STRING_CHAR (str, 0); + Faset (errstring, 0, make_number (DOWNCASE (c))); + } xsignal (Qfile_error, Fcons (build_string (string), Fcons (errstring, data))); --- Kenichi Handa handa@ni.aist.go.jp