User: ben
Date: 05/01/29 10:06:45
Modified: xemacs/src ChangeLog file-coding.c
Log:
Fix recognition of coding magic cookie in autodetection
file-coding.c: Use UExtbyte for semantic correctness.
file-coding.c: Fix code that recognizes ;;;###coding cookie.
Revision Changes Path
1.780 +7 -0 XEmacs/xemacs/src/ChangeLog
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.779
retrieving revision 1.780
diff -u -b -r1.779 -r1.780
--- ChangeLog 2005/01/28 02:58:49 1.779
+++ ChangeLog 2005/01/29 09:06:37 1.780
@@ -1,3 +1,10 @@
+2005-01-29 Ben Wing <ben(a)xemacs.org>
+
+ * file-coding.c (snarf_coding_system):
+ Use UExtbyte for semantic correctness.
+ * file-coding.c (look_for_coding_system_magic_cookie):
+ Fix code that recognizes ;;;###coding cookie.
+
2005-01-27 Ben Wing <ben(a)xemacs.org>
* console-impl.h (struct console_methods):
1.43 +23 -14 XEmacs/xemacs/src/file-coding.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: file-coding.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/file-coding.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- file-coding.c 2005/01/24 23:33:54 1.42
+++ file-coding.c 2005/01/29 09:06:40 1.43
@@ -3541,10 +3541,10 @@
blanks). If found, return it, otherwise nil. */
static Lisp_Object
-snarf_coding_system (const Ibyte *p, Bytecount len)
+snarf_coding_system (const UExtbyte *p, Bytecount len)
{
Bytecount n;
- Ibyte *name;
+ UExtbyte *name;
while (*p == ' ' || *p == '\t') p++, len--;
len = min (len, 1000);
@@ -3563,7 +3563,9 @@
if (n > 0)
{
name[n] = '\0';
- return find_coding_system_for_text_file (intern_int (name), 0);
+ /* This call to intern_int() is OK because we already verified that
+ there are only ASCII characters in the string */
+ return find_coding_system_for_text_file (intern_int ((Ibyte *) name), 0);
}
return Qnil;
@@ -3598,6 +3600,7 @@
{
const UExtbyte *p;
const UExtbyte *scan_end;
+ Bytecount cookie_len;
/* Look for initial "-*-"; mode line prefix */
for (p = data,
@@ -3639,20 +3642,26 @@
break;
}
-#if 0
- /* #### Totally wrong as is, rewrite */
- /* Look for initial ;;;###coding system */
+ /* Look for ;;;###coding system */
+ cookie_len = LENGTH (";;;###coding system: ");
+
+ for (p = data,
+ scan_end = data + len - cookie_len;
+ p <= scan_end;
+ p++)
{
- Bytecount ind = fast_string_match (QScoding_system_cookie,
- data, Qnil, 0, len, 0, ERROR_ME_NOT,
- 1);
- if (ind >= 0)
- return
- snarf_coding_system (data + ind + LENGTH (";;;###coding system: "),
- len - ind - LENGTH (";;;###coding system: "));
+ if (*p == ';' && !memcmp (p, ";;;###coding system: ",
cookie_len))
+ {
+ const UExtbyte *suffix;
+
+ p += cookie_len;
+ suffix = p;
+ while (suffix < scan_end && !isspace (*suffix))
+ suffix++;
+ return snarf_coding_system (p, suffix - p);
+ }
}
-#endif /* 0 */
return Qnil;
}
Show replies by date