[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (aset UNIBYTE-STRING MULTIBYTE-CHAR)
From: |
Harald Hanche-Olsen |
Subject: |
Re: (aset UNIBYTE-STRING MULTIBYTE-CHAR) |
Date: |
Wed, 07 May 2008 21:31:12 +0200 (CEST) |
This works as it should in the latest CVS:
(setq foo (make-string 4 ?a))
(aset foo 1 ?€) ; <= that's a euro sign
But this fails:
(setq foo (make-string 4 ?a))
(aset foo 1 ?å)
(aset foo 1 ?€) ; => Error: args out of range
The problem seems to lie in these lines (2095-2107) from data.c:
if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt)))
{
int i;
for (i = SBYTES (array) - 1; i >= 0; i--)
if (SREF (array, i) >= 0x80)
args_out_of_range (array, newelt);
/* ARRAY is an ASCII string. Convert it to a multibyte
string, and try `aset' again. */
STRING_SET_MULTIBYTE (array);
return Faset (array, idx, newelt);
}
SSET (array, idxval, XINT (newelt));
I am sure the test for members >= 0x80 is there for a good reason, but
it clearly screws up this case and makes the fix rather less useful
than it should have been. I don't know emacs internals well enough to
suggest a fix.
And yes, this did bite in real life: It caused mew to choke on a
malformed spam email. No disaster obviously, but inconvenient.
- Harald
PS. My apologies for messing up threading; I wasn't on the list when
the message I am responding to was posted on 2008-07-15, so I don't
know its message-id.
- Re: (aset UNIBYTE-STRING MULTIBYTE-CHAR),
Harald Hanche-Olsen <=