diff options
| author | Kenichi Handa | 2004-06-07 00:00:03 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-06-07 00:00:03 +0000 |
| commit | 12d5b1856c718a114ae75901ec34e0e9b16455c0 (patch) | |
| tree | e81299f89d00c74db2ebbd05c1fd203f56c6009f /src/coding.c | |
| parent | 2e2d7ee6545f4089cec9ad69c79c6b1ff31ac5ba (diff) | |
| download | emacs-12d5b1856c718a114ae75901ec34e0e9b16455c0.tar.gz emacs-12d5b1856c718a114ae75901ec34e0e9b16455c0.zip | |
(find_safe_codings): Check NILP (safe_codings) only at
the necessary places.
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 abf60da44f8..3416e4694ea 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6570,8 +6570,8 @@ highest priority. */) | |||
| 6570 | possible coding systems. If it is nil, it means that we have not | 6570 | possible coding systems. If it is nil, it means that we have not |
| 6571 | yet found any coding systems. | 6571 | yet found any coding systems. |
| 6572 | 6572 | ||
| 6573 | WORK_TABLE is a copy of the char-table Vchar_coding_system_table. An | 6573 | WORK_TABLE a char-table of which element is set to t once the |
| 6574 | element of WORK_TABLE is set to t once the element is looked up. | 6574 | element is looked up. |
| 6575 | 6575 | ||
| 6576 | If a non-ASCII single byte char is found, set | 6576 | If a non-ASCII single byte char is found, set |
| 6577 | *single_byte_char_found to 1. */ | 6577 | *single_byte_char_found to 1. */ |
| @@ -6586,6 +6586,8 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6586 | Lisp_Object val, ch; | 6586 | Lisp_Object val, ch; |
| 6587 | Lisp_Object prev, tail; | 6587 | Lisp_Object prev, tail; |
| 6588 | 6588 | ||
| 6589 | if (NILP (safe_codings)) | ||
| 6590 | goto done_safe_codings; | ||
| 6589 | while (p < pend) | 6591 | while (p < pend) |
| 6590 | { | 6592 | { |
| 6591 | c = STRING_CHAR_AND_LENGTH (p, pend - p, len); | 6593 | c = STRING_CHAR_AND_LENGTH (p, pend - p, len); |
| @@ -6595,11 +6597,6 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6595 | continue; | 6597 | continue; |
| 6596 | if (SINGLE_BYTE_CHAR_P (c)) | 6598 | if (SINGLE_BYTE_CHAR_P (c)) |
| 6597 | *single_byte_char_found = 1; | 6599 | *single_byte_char_found = 1; |
| 6598 | if (NILP (safe_codings)) | ||
| 6599 | /* Already all coding systems are excluded. But, we can't | ||
| 6600 | terminate the loop here because non-ASCII single-byte char | ||
| 6601 | must be found. */ | ||
| 6602 | continue; | ||
| 6603 | /* Check the safe coding systems for C. */ | 6600 | /* Check the safe coding systems for C. */ |
| 6604 | ch = make_number (c); | 6601 | ch = make_number (c); |
| 6605 | val = Faref (work_table, ch); | 6602 | val = Faref (work_table, ch); |
| @@ -6677,12 +6674,33 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6677 | { | 6674 | { |
| 6678 | /* Exclude this coding system from SAFE_CODINGS. */ | 6675 | /* Exclude this coding system from SAFE_CODINGS. */ |
| 6679 | if (EQ (tail, safe_codings)) | 6676 | if (EQ (tail, safe_codings)) |
| 6680 | safe_codings = XCDR (safe_codings); | 6677 | { |
| 6678 | safe_codings = XCDR (safe_codings); | ||
| 6679 | if (NILP (safe_codings)) | ||
| 6680 | goto done_safe_codings; | ||
| 6681 | } | ||
| 6681 | else | 6682 | else |
| 6682 | XSETCDR (prev, XCDR (tail)); | 6683 | XSETCDR (prev, XCDR (tail)); |
| 6683 | } | 6684 | } |
| 6684 | } | 6685 | } |
| 6685 | } | 6686 | } |
| 6687 | |||
| 6688 | done_safe_codings: | ||
| 6689 | /* If the above loop was terminated before P reaches PEND, it means | ||
| 6690 | SAFE_CODINGS was set to nil. If we have not yet found an | ||
| 6691 | non-ASCII single-byte char, check it now. */ | ||
| 6692 | if (! *single_byte_char_found) | ||
| 6693 | while (p < pend) | ||
| 6694 | { | ||
| 6695 | c = STRING_CHAR_AND_LENGTH (p, pend - p, len); | ||
| 6696 | p += len; | ||
| 6697 | if (! ASCII_BYTE_P (c) | ||
| 6698 | && SINGLE_BYTE_CHAR_P (c)) | ||
| 6699 | { | ||
| 6700 | *single_byte_char_found = 1; | ||
| 6701 | break; | ||
| 6702 | } | ||
| 6703 | } | ||
| 6686 | return safe_codings; | 6704 | return safe_codings; |
| 6687 | } | 6705 | } |
| 6688 | 6706 | ||