From: Kenichi Handa Date: Mon, 7 Jun 2004 00:00:03 +0000 (+0000) Subject: (find_safe_codings): Check NILP (safe_codings) only at X-Git-Tag: ttn-vms-21-2-B4~5893 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=12d5b1856c718a114ae75901ec34e0e9b16455c0;p=emacs.git (find_safe_codings): Check NILP (safe_codings) only at the necessary places. --- diff --git a/src/ChangeLog b/src/ChangeLog index 6f6af93995f..88f4a5c68ca 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-06-07 Kenichi Handa + + * coding.c (find_safe_codings): Check NILP (safe_codings) only at + the necessary places. + 2004-06-07 Kim F. Storm * process.c (Fdelete_process): Undo 2004-05-28 change. 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. */) possible coding systems. If it is nil, it means that we have not yet found any coding systems. - WORK_TABLE is a copy of the char-table Vchar_coding_system_table. An - element of WORK_TABLE is set to t once the element is looked up. + WORK_TABLE a char-table of which element is set to t once the + element is looked up. If a non-ASCII single byte char is found, set *single_byte_char_found to 1. */ @@ -6586,6 +6586,8 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) Lisp_Object val, ch; Lisp_Object prev, tail; + if (NILP (safe_codings)) + goto done_safe_codings; while (p < pend) { 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) continue; if (SINGLE_BYTE_CHAR_P (c)) *single_byte_char_found = 1; - if (NILP (safe_codings)) - /* Already all coding systems are excluded. But, we can't - terminate the loop here because non-ASCII single-byte char - must be found. */ - continue; /* Check the safe coding systems for C. */ ch = make_number (c); val = Faref (work_table, ch); @@ -6677,12 +6674,33 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) { /* Exclude this coding system from SAFE_CODINGS. */ if (EQ (tail, safe_codings)) - safe_codings = XCDR (safe_codings); + { + safe_codings = XCDR (safe_codings); + if (NILP (safe_codings)) + goto done_safe_codings; + } else XSETCDR (prev, XCDR (tail)); } } } + + done_safe_codings: + /* If the above loop was terminated before P reaches PEND, it means + SAFE_CODINGS was set to nil. If we have not yet found an + non-ASCII single-byte char, check it now. */ + if (! *single_byte_char_found) + while (p < pend) + { + c = STRING_CHAR_AND_LENGTH (p, pend - p, len); + p += len; + if (! ASCII_BYTE_P (c) + && SINGLE_BYTE_CHAR_P (c)) + { + *single_byte_char_found = 1; + break; + } + } return safe_codings; }