diff options
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/coding.c b/src/coding.c index 7e90b985143..328507de499 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6566,8 +6566,8 @@ highest priority. */) | |||
| 6566 | possible coding systems. If it is nil, it means that we have not | 6566 | possible coding systems. If it is nil, it means that we have not |
| 6567 | yet found any coding systems. | 6567 | yet found any coding systems. |
| 6568 | 6568 | ||
| 6569 | WORK_TABLE is a copy of the char-table Vchar_coding_system_table. An | 6569 | WORK_TABLE a char-table of which element is set to t once the |
| 6570 | element of WORK_TABLE is set to t once the element is looked up. | 6570 | element is looked up. |
| 6571 | 6571 | ||
| 6572 | If a non-ASCII single byte char is found, set | 6572 | If a non-ASCII single byte char is found, set |
| 6573 | *single_byte_char_found to 1. */ | 6573 | *single_byte_char_found to 1. */ |
| @@ -6582,6 +6582,8 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6582 | Lisp_Object val, ch; | 6582 | Lisp_Object val, ch; |
| 6583 | Lisp_Object prev, tail; | 6583 | Lisp_Object prev, tail; |
| 6584 | 6584 | ||
| 6585 | if (NILP (safe_codings)) | ||
| 6586 | goto done_safe_codings; | ||
| 6585 | while (p < pend) | 6587 | while (p < pend) |
| 6586 | { | 6588 | { |
| 6587 | c = STRING_CHAR_AND_LENGTH (p, pend - p, len); | 6589 | c = STRING_CHAR_AND_LENGTH (p, pend - p, len); |
| @@ -6591,11 +6593,6 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6591 | continue; | 6593 | continue; |
| 6592 | if (SINGLE_BYTE_CHAR_P (c)) | 6594 | if (SINGLE_BYTE_CHAR_P (c)) |
| 6593 | *single_byte_char_found = 1; | 6595 | *single_byte_char_found = 1; |
| 6594 | if (NILP (safe_codings)) | ||
| 6595 | /* Already all coding systems are excluded. But, we can't | ||
| 6596 | terminate the loop here because non-ASCII single-byte char | ||
| 6597 | must be found. */ | ||
| 6598 | continue; | ||
| 6599 | /* Check the safe coding systems for C. */ | 6596 | /* Check the safe coding systems for C. */ |
| 6600 | ch = make_number (c); | 6597 | ch = make_number (c); |
| 6601 | val = Faref (work_table, ch); | 6598 | val = Faref (work_table, ch); |
| @@ -6673,12 +6670,33 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6673 | { | 6670 | { |
| 6674 | /* Exclude this coding system from SAFE_CODINGS. */ | 6671 | /* Exclude this coding system from SAFE_CODINGS. */ |
| 6675 | if (EQ (tail, safe_codings)) | 6672 | if (EQ (tail, safe_codings)) |
| 6676 | safe_codings = XCDR (safe_codings); | 6673 | { |
| 6674 | safe_codings = XCDR (safe_codings); | ||
| 6675 | if (NILP (safe_codings)) | ||
| 6676 | goto done_safe_codings; | ||
| 6677 | } | ||
| 6677 | else | 6678 | else |
| 6678 | XSETCDR (prev, XCDR (tail)); | 6679 | XSETCDR (prev, XCDR (tail)); |
| 6679 | } | 6680 | } |
| 6680 | } | 6681 | } |
| 6681 | } | 6682 | } |
| 6683 | |||
| 6684 | done_safe_codings: | ||
| 6685 | /* If the above loop was terminated before P reaches PEND, it means | ||
| 6686 | SAFE_CODINGS was set to nil. If we have not yet found an | ||
| 6687 | non-ASCII single-byte char, check it now. */ | ||
| 6688 | if (! *single_byte_char_found) | ||
| 6689 | while (p < pend) | ||
| 6690 | { | ||
| 6691 | c = STRING_CHAR_AND_LENGTH (p, pend - p, len); | ||
| 6692 | p += len; | ||
| 6693 | if (! ASCII_BYTE_P (c) | ||
| 6694 | && SINGLE_BYTE_CHAR_P (c)) | ||
| 6695 | { | ||
| 6696 | *single_byte_char_found = 1; | ||
| 6697 | break; | ||
| 6698 | } | ||
| 6699 | } | ||
| 6682 | return safe_codings; | 6700 | return safe_codings; |
| 6683 | } | 6701 | } |
| 6684 | 6702 | ||