unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Harald Hanche-Olsen <hanche@math.ntnu.no>
To: emacs-devel@gnu.org
Subject: Re: (aset UNIBYTE-STRING MULTIBYTE-CHAR)
Date: Wed, 14 May 2008 08:54:38 +0200 (CEST)	[thread overview]
Message-ID: <20080514.085438.56819933.hanche@math.ntnu.no> (raw)
In-Reply-To: <20080507.213112.10351177.hanche@math.ntnu.no>

My message on this topic of a week ago elicited no responses, so I did
a little more research on my own (which I should have done in the
first place, maybe). This time I hope to see some discussion:

+ Harald Hanche-Olsen <hanche@math.ntnu.no>:

> 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

I went back in the mail archives and read the whole thread (it was in
February and April this year), and I realize that the whole idea of
changing a unibyte string into a multibyte one on the fly in order to
support aset on them is somewhat controversial. Be that as it may, the
above example shows that the fix put in by Kenichi Handa does not fix
it right. Moreover, it is clear from the commit message that he was
well aware of this limitation at the time:

Working file: data.c
revision 1.291
date: 2008-04-17 03:10:58 +0200;  author: handa;  state: Exp;  lines: +11 -1;  commitid: yW6gyKxwbZ4EPoZs;
(Faset): Allow setting a multibyte character in an
ASCII-only unibyte string.

It seems to me that in order to get it right, one has to reallocate
the data in the case of a non-ASCII-only unibyte string, using
code like what is already there for the case when aset replaces an
ASCII character with a non-ASCII one (which will increase the byte
count of the string). The end result will be ugly and inefficient, but
I see no other way if we are going to lay this one to rest.

Comments?

- Harald




  reply	other threads:[~2008-05-14  6:54 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-07 19:31 (aset UNIBYTE-STRING MULTIBYTE-CHAR) Harald Hanche-Olsen
2008-05-14  6:54 ` Harald Hanche-Olsen [this message]
2008-05-14 12:22   ` Stefan Monnier
2008-05-14 12:50     ` Harald Hanche-Olsen
2008-05-15  1:18       ` Stefan Monnier
2008-05-15  6:11         ` Harald Hanche-Olsen
  -- strict thread matches above, loose matches on Subject: below --
2008-04-15  7:11 Kenichi Handa
2008-04-15 15:52 ` Stefan Monnier
2008-04-17  1:13   ` Kenichi Handa
2008-02-13  2:36 Kenichi Handa
2008-02-13  2:49 ` Stefan Monnier
2008-02-13  3:48   ` Kenichi Handa
2008-02-13 15:33     ` Stefan Monnier
2008-02-13 18:06       ` Stephen J. Turnbull
2008-02-13 19:33         ` Stefan Monnier
2008-02-13 22:49         ` Miles Bader
2008-02-14  1:11           ` Stephen J. Turnbull
2008-02-14  1:17             ` Miles Bader
2008-02-14  1:40               ` Stefan Monnier
2008-02-14  1:49                 ` Miles Bader
2008-02-14 18:10                 ` Richard Stallman
2008-02-14 22:40                   ` David Kastrup
2008-02-15  1:08                     ` Stephen J. Turnbull
2008-02-15  1:17                       ` Miles Bader
2008-02-15  7:27                         ` David Kastrup
2008-02-15 12:58                     ` Richard Stallman
2008-02-14 23:37                   ` Leo
2008-02-15 12:59                     ` Richard Stallman
2008-02-14  4:20               ` Stephen J. Turnbull
2008-02-14  4:42         ` Richard Stallman
2008-02-15  1:39       ` Kenichi Handa
2008-02-15  4:27         ` Stefan Monnier
2008-02-15  8:42         ` Eli Zaretskii
2008-02-15  8:53           ` Miles Bader
2008-02-16 12:55             ` Eli Zaretskii
2008-02-16  5:53         ` Richard Stallman
2008-02-16 14:33           ` Stefan Monnier
2008-02-17 20:29             ` Richard Stallman
2008-02-18  1:15               ` Stefan Monnier
2008-02-18  4:00                 ` Kenichi Handa
2008-02-18 17:31                 ` Richard Stallman
2008-02-13 22:01 ` Richard Stallman
2008-02-13 23:13   ` Miles Bader

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080514.085438.56819933.hanche@math.ntnu.no \
    --to=hanche@math.ntnu.no \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).