qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs qe.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.c
Date: Wed, 14 May 2014 17:14:05 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        14/05/14 17:14:05

Modified files:
        .              : qe.c 

Log message:
        improve BOM handling
        
        * colorize BOM character separately from mode based colorizer
        * skip BOM char for mode probing

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.168&r2=1.169

Patches:
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -b -r1.168 -r1.169
--- qe.c        13 May 2014 08:56:23 -0000      1.168
+++ qe.c        14 May 2014 17:14:05 -0000      1.169
@@ -3310,6 +3310,9 @@
             len = eb_get_line(s->b, buf, buf_size - 1, &offset);
             /* skip byte order mark if present */
             bom = (len > 0 && buf[0] == 0xFEFF);
+            if (bom) {
+                SET_COLOR1(buf, 0, QE_STYLE_PREPROCESS);
+            }
             s->colorize_func(&cctx, buf + bom, len - bom, s->mode_flags);
             /* buf[len] has char '\0' but may hold style, force buf ending */
             buf[len + 1] = 0;
@@ -3322,6 +3325,9 @@
     cctx.state_only = 0;
     len = eb_get_line(s->b, buf, buf_size - 1, offsetp);
     bom = (len > 0 && buf[0] == 0xFEFF);
+    if (bom) {
+        SET_COLOR1(buf, 0, QE_STYLE_PREPROCESS);
+    }
     s->colorize_func(&cctx, buf + bom, len - bom, s->mode_flags);
     buf[len + 1] = 0;
 
@@ -5712,6 +5718,16 @@
             probe_data.buf_size = bufp - buf;
         }
     }
+
+    /* Skip the BOM if present */
+    if (probe_data.buf_size >= 3
+    &&  probe_data.buf[0] == 0xEF
+    &&  probe_data.buf[1] == 0xBB
+    &&  probe_data.buf[2] == 0xBF) {
+        probe_data.buf += 3;
+        probe_data.buf_size -= 3;
+    }
+
     charset_decode_close(&probe_data.charset_state);
 
     p = memchr(probe_data.buf, '\n', probe_data.buf_size);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]