[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Stefan Monnier
Date: Wed, 14 May 2008 21:18:26 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

> Now don't get me wrong: I am not asking for a change in Emacs to fix
> a problem in Mew.  I am suggesting a change in Emacs for the sake of
> robustness: I think that if the problem of inserting multibyte
> characters in unibyte strings is worth fixing at all, it is worth
> fixing so it works in all cases.  Otherwise, why bother? I do
> understand the arguments against fixing it, but the current situation
> where it will often work, but fail sometimes does not seem good to me.

I don't claim that Mew does things wrong.  I just want to see more
examples to better understand the context and try to figure out what's
the right way to fix the problem.  Notice that in your example,

   (setq foo (make-string 4 ?a))
   (aset foo 1 ?å)
   (aset foo 1 ?€) ; => Error: args out of range

the problem comes from the fact that now that we use Unicode, ?å = 229.
So this integer is also the code of a byte, which is why the first aset
succeeds.  Maybe the better answer is for `make-string' to always create
multibyte strings, just like `string' now does.

In any case if you stay far away from `aset on strings' your life will
be generally better, the birds will sing and the sun will shine.

>   The most basic way to alter the contents of an existing string is with
>   `aset' (*note Array Functions::).  `(aset STRING IDX CHAR)' stores CHAR
>   into STRING at index IDX.  Each character occupies one or more bytes,
>   and if CHAR needs a different number of bytes from the character
>   already present at that index, `aset' signals an error.

> That last bit actually seems to be outdated: An error is not ALWAYS
> signaled in the indicated situation, only sometimes.

I hope the text is correct, if not, please report it as a bug.

> (defun mew-addrstr-parse-syntax-list (str sep addrp &optional depth allow-spc)
>   (when str
>     (let* ((i 0) (len (length str))
>          (par-cnt 0) (tmp-cnt 0) (sep-cnt 0)
>          (tmp (mew-make-string len))
>          c ret prevc)
>       (catch 'max
>       (while (< i len)
>         (setq c (aref str i)) ; <= problem occurs here
>         ... deleted ...)))))

Hmm... I don't see any `aset'.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]