diff options
| author | Andrea Corallo | 2020-04-06 18:06:29 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-04-06 18:06:29 +0100 |
| commit | 4abb8c822ce02cf33712bd2699c5b77a5db49e31 (patch) | |
| tree | 7520e3cae0f9a958ae223161034ebee6b5aa9e63 /src/coding.c | |
| parent | 32a079aef290fdc8913c1ce4e8910e63e6ff6dcc (diff) | |
| parent | 3dc2f50e5bf9f58aee23fd6c61c02fadc240a377 (diff) | |
| download | emacs-4abb8c822ce02cf33712bd2699c5b77a5db49e31.tar.gz emacs-4abb8c822ce02cf33712bd2699c5b77a5db49e31.zip | |
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/coding.c b/src/coding.c index 0bea2a0c2bc..49c1e625d57 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -9471,6 +9471,17 @@ not fully specified.) */) | |||
| 9471 | return code_convert_region (start, end, coding_system, destination, 1, 0); | 9471 | return code_convert_region (start, end, coding_system, destination, 1, 0); |
| 9472 | } | 9472 | } |
| 9473 | 9473 | ||
| 9474 | /* Whether a string only contains chars in the 0..127 range. */ | ||
| 9475 | static bool | ||
| 9476 | string_ascii_p (Lisp_Object str) | ||
| 9477 | { | ||
| 9478 | ptrdiff_t nbytes = SBYTES (str); | ||
| 9479 | for (ptrdiff_t i = 0; i < nbytes; i++) | ||
| 9480 | if (SREF (str, i) > 127) | ||
| 9481 | return false; | ||
| 9482 | return true; | ||
| 9483 | } | ||
| 9484 | |||
| 9474 | Lisp_Object | 9485 | Lisp_Object |
| 9475 | code_convert_string (Lisp_Object string, Lisp_Object coding_system, | 9486 | code_convert_string (Lisp_Object string, Lisp_Object coding_system, |
| 9476 | Lisp_Object dst_object, bool encodep, bool nocopy, | 9487 | Lisp_Object dst_object, bool encodep, bool nocopy, |
| @@ -9485,7 +9496,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system, | |||
| 9485 | if (! norecord) | 9496 | if (! norecord) |
| 9486 | Vlast_coding_system_used = Qno_conversion; | 9497 | Vlast_coding_system_used = Qno_conversion; |
| 9487 | if (NILP (dst_object)) | 9498 | if (NILP (dst_object)) |
| 9488 | return (nocopy ? Fcopy_sequence (string) : string); | 9499 | return nocopy ? string : Fcopy_sequence (string); |
| 9489 | } | 9500 | } |
| 9490 | 9501 | ||
| 9491 | if (NILP (coding_system)) | 9502 | if (NILP (coding_system)) |
| @@ -9502,7 +9513,21 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system, | |||
| 9502 | chars = SCHARS (string); | 9513 | chars = SCHARS (string); |
| 9503 | bytes = SBYTES (string); | 9514 | bytes = SBYTES (string); |
| 9504 | 9515 | ||
| 9505 | if (BUFFERP (dst_object)) | 9516 | if (EQ (dst_object, Qt)) |
| 9517 | { | ||
| 9518 | /* Fast path for ASCII-only input and an ASCII-compatible coding: | ||
| 9519 | act as identity. */ | ||
| 9520 | Lisp_Object attrs = CODING_ID_ATTRS (coding.id); | ||
| 9521 | if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs)) | ||
| 9522 | && (STRING_MULTIBYTE (string) | ||
| 9523 | ? (chars == bytes) : string_ascii_p (string))) | ||
| 9524 | return (nocopy | ||
| 9525 | ? string | ||
| 9526 | : (encodep | ||
| 9527 | ? make_unibyte_string (SSDATA (string), bytes) | ||
| 9528 | : make_multibyte_string (SSDATA (string), bytes, bytes))); | ||
| 9529 | } | ||
| 9530 | else if (BUFFERP (dst_object)) | ||
| 9506 | { | 9531 | { |
| 9507 | struct buffer *buf = XBUFFER (dst_object); | 9532 | struct buffer *buf = XBUFFER (dst_object); |
| 9508 | ptrdiff_t buf_pt = BUF_PT (buf); | 9533 | ptrdiff_t buf_pt = BUF_PT (buf); |
| @@ -11061,10 +11086,8 @@ usage: (define-coding-system-internal ...) */) | |||
| 11061 | else | 11086 | else |
| 11062 | { | 11087 | { |
| 11063 | CHECK_CONS (val); | 11088 | CHECK_CONS (val); |
| 11064 | CHECK_RANGED_INTEGER (XCAR (val), 0, 255); | 11089 | from = check_integer_range (XCAR (val), 0, 255); |
| 11065 | from = XFIXNUM (XCAR (val)); | 11090 | to = check_integer_range (XCDR (val), from, 255); |
| 11066 | CHECK_RANGED_INTEGER (XCDR (val), from, 255); | ||
| 11067 | to = XFIXNUM (XCDR (val)); | ||
| 11068 | } | 11091 | } |
| 11069 | for (int i = from; i <= to; i++) | 11092 | for (int i = from; i <= to; i++) |
| 11070 | SSET (valids, i, 1); | 11093 | SSET (valids, i, 1); |
| @@ -11149,7 +11172,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 11149 | val = XCAR (tail); | 11172 | val = XCAR (tail); |
| 11150 | CHECK_CONS (val); | 11173 | CHECK_CONS (val); |
| 11151 | CHECK_CHARSET_GET_ID (XCAR (val), id); | 11174 | CHECK_CHARSET_GET_ID (XCAR (val), id); |
| 11152 | CHECK_RANGED_INTEGER (XCDR (val), 0, 3); | 11175 | check_integer_range (XCDR (val), 0, 3); |
| 11153 | XSETCAR (val, make_fixnum (id)); | 11176 | XSETCAR (val, make_fixnum (id)); |
| 11154 | } | 11177 | } |
| 11155 | 11178 | ||