From 5dff5999c49d4c7527bca8758b99a21ab8c7e76b Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Thu, 17 Apr 2008 01:11:11 +0000 Subject: [PATCH] (Faset): Allow setting a multibyte character in an ASCII-only unibyte string. --- src/ChangeLog | 7 +++++++ src/data.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index dd0d8cd266f..527ff3c689d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2008-04-17 Kenichi Handa + + * data.c (Faset): Allow setting a multibyte character in an + ASCII-only unibyte string. + + * lisp.h (STRING_SET_MULTIBYTE): New macro. + 2008-04-16 Stefan Monnier * Makefile.in: Don't use HAVE_GTK and don't -DUSE_GTK since it's now diff --git a/src/data.c b/src/data.c index 6b1a9fc8860..cb9d210c628 100644 --- a/src/data.c +++ b/src/data.c @@ -2093,7 +2093,17 @@ bool-vector. IDX starts at 0. */) CHECK_NUMBER (newelt); if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt))) - args_out_of_range (array, 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)); } -- 2.39.5