[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 23.0.60; Assuming errstring unibyte is incorrect and leads to Emacs
From: |
Kenichi Handa |
Subject: |
Re: 23.0.60; Assuming errstring unibyte is incorrect and leads to Emacs crashes |
Date: |
Wed, 27 Aug 2008 10:13:06 +0900 |
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) |
In article <address@hidden>, Chong Yidong <address@hidden> 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 <address@hidden> 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 <address@hidden>
* 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
address@hidden