qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs qe.c buffer.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.c buffer.c
Date: Mon, 08 Jun 2015 06:55:05 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        15/06/08 06:55:01

Modified files:
        .              : qe.c buffer.c 

Log message:
        fixed cr lf translation for older mac files
        
        * when MAC_EOL end of line is used, \n and \r are swapped for internal 
          EOL handling and restored, but restored for display in hex and 
          what-cursor-position buffer contents display.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.187&r2=1.188
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.82&r2=1.83

Patches:
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -b -r1.187 -r1.188
--- qe.c        9 May 2015 22:25:04 -0000       1.187
+++ qe.c        8 Jun 2015 06:54:56 -0000       1.188
@@ -2166,6 +2166,13 @@
             c2 = 0;
             offset2 = offset1;
         }
+        if (s->b->eol_type == EOL_MAC) {
+            if (c == '\r')
+                c = '\n';
+            else
+            if (c == '\n')
+                c = '\r';
+        }
         buf_puts(out, "char:");
         if (c < 32 || c == 127) {
             buf_printf(out, " ^%c", (c + '@') & 127);
@@ -3606,6 +3613,8 @@
             /* XXX: use embedding level for all cases ? */
             /* CG: should query screen or window about display methods */
             if ((c < ' ' && c != '\t') || c == 127) {
+                if (c == '\r' && s->b->eol_type == EOL_MAC)
+                    c = '\n';
                 display_printf(ds, offset0, offset, "^%c", ('@' + c) & 127);
             } else
             if (c > MAX_UNICODE_DISPLAY) {
@@ -5769,6 +5778,7 @@
     probe_data.charset = charset;
     charset_decode_init(&probe_data.charset_state, charset, eol_type);
 
+    /* XXX: Should handle eol_type and transcode \r and \r\n */
     if (charset == &charset_utf8
     ||  charset == &charset_raw
     ||  charset == &charset_8859_1) {

Index: buffer.c
===================================================================
RCS file: /sources/qemacs/qemacs/buffer.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- buffer.c    27 May 2014 22:59:48 -0000      1.82
+++ buffer.c    8 Jun 2015 06:54:59 -0000       1.83
@@ -1184,20 +1184,28 @@
         /* we use the charset conversion table directly to go faster */
         ch = b->charset_state.table[buf[0]];
         offset++;
-        if (ch == ESCAPE_CHAR || ch == '\r') {
+        if (ch == ESCAPE_CHAR) {
             eb_read(b, offset, buf + 1, MAX_CHAR_BYTES - 1);
             b->charset_state.p = buf;
             ch = b->charset_state.decode_func(&b->charset_state);
             offset += (b->charset_state.p - buf) - 1;
+        }
             if (ch == '\r') {
-                if (b->eol_type == EOL_DOS
+            if (b->eol_type == EOL_DOS) {
+                b->charset_state.p = buf;
+                if (eb_read(b, offset, buf, MAX_CHAR_BYTES) >= 1
                 &&  b->charset_state.decode_func(&b->charset_state) == '\n') {
-                    ch = '\n';
                     offset += b->charset_state.char_size;
+                    ch = '\n';
+                }
                 } else
                 if (b->eol_type == EOL_MAC) {
                     ch = '\n';
                 }
+        } else
+        if (ch == '\n') {
+            if (b->eol_type == EOL_MAC) {
+                ch = '\r';
             }                    
         }
     }
@@ -1286,12 +1294,24 @@
             b->charset_state.p = q;
             ch = b->charset_state.decode_func(&b->charset_state);
         }
-        if (ch == '\n' && b->eol_type == EOL_DOS && offset >= char_size) {
+        if (ch == '\r') {
+            if (b->eol_type == EOL_MAC) {
+                ch = '\n';
+            }
+        } else
+        if (ch == '\n') {
+            if (b->eol_type == EOL_DOS) {
+                if (offset >= char_size) {
             eb_read(b, offset - char_size, buf, char_size);
             b->charset_state.p = buf;
             if (b->charset_state.decode_func(&b->charset_state) == '\r')
                 offset -= char_size;
         }
+            } else
+            if (b->eol_type == EOL_MAC) {
+                ch = '\r';
+            }
+        }
     }
  the_end:
     *prev_ptr = offset;



reply via email to

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