From a8e061dda77b9793062716ececa4899aac30ba7b Mon Sep 17 00:00:00 2001 From: Nelson Ferreira Date: Sun, 11 Mar 2012 21:11:12 -0400 Subject: [PATCH] Refactor * src/mule/file-coding.c (determine_real_coding_system): Refactor condition in inner for loop so that negative branch of the condition will continue loop, and fall through is the old positive condition branch. Signed-off-by: Nelson Ferreira --- src/mule/file-coding.c | 54 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/src/mule/file-coding.c b/src/mule/file-coding.c index 92c21f4..1fbac24 100644 --- a/src/mule/file-coding.c +++ b/src/mule/file-coding.c @@ -1890,35 +1890,33 @@ determine_real_coding_system(lstream_t stream, Lisp_Object * codesys_in_out, Extbyte *suffix = p; /* Look for "coding:" */ for (p = local_vars_beg, scan_end = suffix - LENGTH("coding:?"); - p <= scan_end; p++) - if (memcmp("coding:", p, LENGTH("coding:")) == 0 - && (p == local_vars_beg - || (*(p - 1) == ' ' - || *(p - 1) == '\t' - || *(p - 1) == ';'))) { - Extbyte save; - int n; - p += LENGTH("coding:"); - while (*p == ' ' || *p == '\t') { - p++; - } - - /* Get coding system name */ - save = *suffix; - *suffix = '\0'; - /* Characters valid in a MIME charset name (rfc 1521), - and in a Lisp symbol name. */ - n = strspn((char *)p, - mime_name_valid_chars); - *suffix = save; - if (n > 0) { - save = p[n]; - p[n] = '\0'; - coding_system = Ffind_coding_system(intern((char *)p)); - p[n] = save; - } - break; + p <= scan_end; p++) { + if (memcmp("coding:", p, LENGTH("coding:")) != 0) + continue; + if (p != local_vars_beg && strchr(" \t;", *p) == NULL ) + continue; + Extbyte save; + int n; + p += LENGTH("coding:"); + while (*p == ' ' || *p == '\t') { + p++; } + + /* Get coding system name */ + save = *suffix; + *suffix = '\0'; + /* Characters valid in a MIME charset name (rfc 1521), + and in a Lisp symbol name. */ + n = strspn((char *)p, mime_name_valid_chars); + *suffix = save; + if (n > 0) { + save = p[n]; + p[n] = '\0'; + coding_system = Ffind_coding_system(intern((char *)p)); + p[n] = save; + } + break; + } break; } /* #### file must use standard EOLs or we miss 2d line */ -- 2.25.1