Created
November 4, 2015 22:10
-
-
Save minimal/b3286ef3f225648cf2c6 to your computer and use it in GitHub Desktop.
emacsligpatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/composite.c b/src/composite.c | |
index 0f729bc..80e15f1 100644 | |
--- a/src/composite.c | |
+++ b/src/composite.c | |
@@ -1727,20 +1727,45 @@ should be ignored. */) | |
if (NILP (string)) | |
{ | |
- if (NILP (BVAR (current_buffer, enable_multibyte_characters))) | |
- error ("Attempt to shape unibyte text"); | |
+ | |
validate_region (&from, &to); | |
frompos = XFASTINT (from); | |
topos = XFASTINT (to); | |
- frombyte = CHAR_TO_BYTE (frompos); | |
+ if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) | |
+ frombyte = CHAR_TO_BYTE (frompos); | |
+ else | |
+ { | |
+ ptrdiff_t pos; | |
+ | |
+ /* fill_gstring_header below uses | |
+ FETCH_CHAR_ADVANCE_NO_CHECK that assumes the current | |
+ buffer is multibyte, but it is safe as long as it only | |
+ fetches ASCII chars. */ | |
+ for (pos = frompos; pos < topos; pos++) | |
+ if (!ASCII_BYTE_P (*(BYTE_POS_ADDR (pos)))) | |
+ error ("Attempt to shape non-ASCII part of unibyte text"); | |
+ frombyte = frompos; | |
+ } | |
} | |
else | |
{ | |
CHECK_STRING (string); | |
validate_subarray (string, from, to, SCHARS (string), &frompos, &topos); | |
- if (! STRING_MULTIBYTE (string)) | |
- error ("Attempt to shape unibyte text"); | |
- frombyte = string_char_to_byte (string, frompos); | |
+ if (STRING_MULTIBYTE (string)) | |
+ frombyte = string_char_to_byte (string, frompos); | |
+ else | |
+ { | |
+ ptrdiff_t pos; | |
+ | |
+ /* fill_gstring_header below uses | |
+ FETCH_STRING_CHAR_ADVANCE_NO_CHECK that assumes the | |
+ string is multibyte, but it is safe as long as it only | |
+ fetches ASCII chars. */ | |
+ for (pos = frompos; pos < topos; pos++) | |
+ if (!ASCII_BYTE_P (SREF (string, pos))) | |
+ error ("Attempt to shape non-ASCII part of unibyte text"); | |
+ frombyte = frompos; | |
+ } | |
} | |
header = fill_gstring_header (Qnil, frompos, frombyte, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment