]> code.delx.au - gnu-emacs/blobdiff - src/ccl.c
(x_create_tip_frame): Initialize frame's colors like
[gnu-emacs] / src / ccl.c
index 0b11bafe7d27f0d31101193e73f2c0e0a238b032..4f0dfbfbdbc0c92d504e3b323bc03f9d360e8a4d 100644 (file)
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -668,19 +668,29 @@ static tr_stack *mapping_stack_pointer;
    output buffer.  If CH is less than 256, CH is written as is.  */
 #define CCL_WRITE_CHAR(ch)                                     \
   do {                                                         \
+    int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch);  \
+    if (ch == '\n' && ccl->eol_type == CODING_EOL_CRLF)                \
+      bytes++;                                                 \
     if (!dst)                                                  \
       CCL_INVALID_CMD;                                         \
-    else                                                       \
+    else if (dst + bytes <= (dst_bytes ? dst_end : src))       \
       {                                                                \
-       unsigned char str[MAX_MULTIBYTE_LENGTH], *p = str;      \
-       int len = CHAR_STRING (ch, str);                        \
-       if (dst + len <= (dst_bytes ? dst_end : src))           \
+       if (ch == '\n')                                         \
          {                                                     \
-           while (len--) *dst++ = *p++;                        \
+           if (ccl->eol_type == CODING_EOL_CRLF)               \
+             *dst++ = '\r', *dst++ = '\n';                     \
+           else if (ccl->eol_type == CODING_EOL_CR)            \
+             *dst++ = '\r';                                    \
+           else                                                \
+             *dst++ = '\n';                                    \
          }                                                     \
+       else if (bytes == 1)                                    \
+         *dst++ = (ch);                                        \
        else                                                    \
-         CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST);                \
+         dst += CHAR_STRING (ch, dst);                         \
       }                                                                \
+    else                                                       \
+      CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST);                   \
   } while (0)
 
 /* Write a string at ccl_prog[IC] of length LEN to the current output
@@ -732,10 +742,10 @@ static tr_stack *mapping_stack_pointer;
                                                                \
        if (code >= 256)                                        \
          c2 = c1, c1 = (code >> 7) & 0x7F;                     \
-       c = MAKE_NON_ASCII_CHAR (charset, c1, c2);              \
+       c = MAKE_CHAR (charset, c1, c2);                        \
       }                                                                \
     else                                                       \
-      c = code & 0xFF;                                 \
+      c = code & 0xFF;                                         \
   } while (0)
 
 
@@ -1016,8 +1026,9 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
          break;
 
        case CCL_End:           /* 0000000000000000000000XXXXX */
-         if (stack_idx-- > 0)
+         if (stack_idx > 0)
            {
+             stack_idx--;
              ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog;
              ic = ccl_prog_stack_struct[stack_idx].ic;
              break;
@@ -1192,6 +1203,18 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
                    reg[rrr] = ((i << 7) | (*src & 0x7F));
                    src++;
                  }
+               else if (i == LEADING_CODE_8_BIT_CONTROL)
+                 {
+                   if (src >= src_end)
+                     goto ccl_read_multibyte_character_suspend;
+                   reg[RRR] = CHARSET_8_BIT_CONTROL;
+                   reg[rrr] = (*src++ - 0x20);
+                 }
+               else if (i >= 0xA0)
+                 {
+                   reg[RRR] = CHARSET_8_BIT_GRAPHIC;
+                   reg[rrr] = i;
+                 }
                else
                  {
                    /* INVALID CODE.  Return a single byte character.  */
@@ -1216,7 +1239,9 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
 
            case CCL_WriteMultibyteChar2:
              i = reg[RRR]; /* charset */
-             if (i == CHARSET_ASCII)
+             if (i == CHARSET_ASCII
+                 || i == CHARSET_8_BIT_CONTROL
+                 || i == CHARSET_8_BIT_GRAPHIC)
                i = reg[rrr] & 0xFF;
              else if (CHARSET_DIMENSION (i) == 1)
                i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F);
@@ -1742,6 +1767,7 @@ setup_ccl_program (ccl, ccl_prog)
   ccl->private_state = 0;
   ccl->status = 0;
   ccl->stack_idx = 0;
+  ccl->eol_type = CODING_EOL_LF;
   return 0;
 }