diff options
| author | Eli Zaretskii <eliz@gnu.org> | 2020-02-08 15:41:36 +0200 |
|---|---|---|
| committer | Eli Zaretskii <eliz@gnu.org> | 2020-02-08 15:41:36 +0200 |
| commit | fe903c5ab7354b97f80ecf1b01ca3ff1027be446 (patch) | |
| tree | e3bb6b5cc872e5e0bb075985ba8306f47ba58382 /src | |
| parent | 953e7abf5befc560d1c88b6dfbbeb5f52d60e8b6 (diff) | |
| download | emacs-fe903c5ab7354b97f80ecf1b01ca3ff1027be446.tar.gz | |
Allow composition of pure-ASCII strings in the mode line
* src/composite.c (Fcomposition_get_gstring): Allow unibyte
strings if they are pure ASCII, by copying text into a
multibyte string.
Diffstat (limited to 'src')
| -rw-r--r-- | src/composite.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/composite.c b/src/composite.c index 53e6930b5f2..05365cfb65e 100644 --- a/src/composite.c +++ b/src/composite.c @@ -1746,7 +1746,18 @@ should be ignored. */) CHECK_STRING (string); validate_subarray (string, from, to, SCHARS (string), &frompos, &topos); if (! STRING_MULTIBYTE (string)) - error ("Attempt to shape unibyte text"); + { + ptrdiff_t i; + + for (i = SBYTES (string) - 1; i >= 0; i--) + if (!ASCII_CHAR_P (SREF (string, i))) + error ("Attempt to shape unibyte text"); + /* STRING is a pure-ASCII string, so we can convert it (or, + rather, its copy) to multibyte and use that thereafter. */ + Lisp_Object string_copy = Fconcat (1, &string); + STRING_SET_MULTIBYTE (string_copy); + string = string_copy; + } frombyte = string_char_to_byte (string, frompos); } |
