Skip to content

Commit

Permalink
Allow composition of pure-ASCII strings in the mode line
Browse files Browse the repository at this point in the history
* src/composite.c (Fcomposition_get_gstring): Allow unibyte
strings if they are pure ASCII, by copying text into a
multibyte string.
  • Loading branch information
Eli-Zaretskii committed Feb 8, 2020
1 parent 953e7ab commit fe903c5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit fe903c5

Please sign in to comment.