]> code.delx.au - gnu-emacs/blobdiff - src/ccl.c
(print_error_message): Print data of `end-of-file'
[gnu-emacs] / src / ccl.c
index 93cb0873b96390099af841667bdd129ad6ede95f..0b11bafe7d27f0d31101193e73f2c0e0a238b032 100644 (file)
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -714,6 +714,31 @@ static tr_stack *mapping_stack_pointer;
   } while (0)
 
 
+/* Set C to the character code made from CHARSET and CODE.  This is
+   like MAKE_CHAR but check the validity of CHARSET and CODE.  If they
+   are not valid, set C to (CODE & 0xFF) because that is usually the
+   case that CCL_ReadMultibyteChar2 read an invalid code and it set
+   CODE to that invalid byte.  */
+
+#define CCL_MAKE_CHAR(charset, code, c)                                \
+  do {                                                         \
+    if (charset == CHARSET_ASCII)                              \
+      c = code & 0xFF;                                         \
+    else if (CHARSET_DEFINED_P (charset)                       \
+            && (code & 0x7F) >= 32                             \
+            && (code < 256 || ((code >> 7) & 0x7F) >= 32))     \
+      {                                                                \
+       int c1 = code & 0x7F, c2 = 0;                           \
+                                                               \
+       if (code >= 256)                                        \
+         c2 = c1, c1 = (code >> 7) & 0x7F;                     \
+       c = MAKE_NON_ASCII_CHAR (charset, c1, c2);              \
+      }                                                                \
+    else                                                       \
+      c = code & 0xFF;                                 \
+  } while (0)
+
+
 /* Execute CCL code on SRC_BYTES length text at SOURCE.  The resulting
    text goes to a place pointed by DESTINATION, the length of which
    should not exceed DST_BYTES.  The bytes actually processed is
@@ -909,7 +934,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
          i = reg[RRR];
          j = XINT (ccl_prog[ic]);
          op = field1 >> 6;
-         ic++;
+         jump_address = ic + 1;
          goto ccl_set_expr;
 
        case CCL_WriteRegister: /* CCCCCCCCCCCCCCCCCCCrrrXXXXX */
@@ -929,6 +954,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
          i = reg[RRR];
          j = reg[Rrr];
          op = field1 >> 6;
+         jump_address = ic;
          goto ccl_set_expr;
 
        case CCL_Call:          /* 1:CCCCCCCCCCCCCCCCCCCCFFFXXXXX */
@@ -1105,6 +1131,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
            {
              i = reg[rrr];
              CCL_WRITE_CHAR (i);
+             ic = jump_address;
            }
          else if (!reg[rrr])
            ic = jump_address;
@@ -1203,16 +1230,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
              break;
 
            case CCL_TranslateCharacter:
-             i = reg[RRR]; /* charset */
-             if (i == CHARSET_ASCII)
-               i = reg[rrr];
-             else if (CHARSET_DIMENSION (i) == 1)
-               i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F);
-             else if (i < MIN_CHARSET_PRIVATE_DIMENSION2)
-               i = ((i - 0x8F) << 14) | (reg[rrr] & 0x3FFF);
-             else
-               i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF);
-
+             CCL_MAKE_CHAR (reg[RRR], reg[rrr], i);
              op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]),
                                   i, -1, 0, 0);
              SPLIT_CHAR (op, reg[RRR], i, j);
@@ -1225,16 +1243,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
            case CCL_TranslateCharacterConstTbl:
              op = XINT (ccl_prog[ic]); /* table */
              ic++;
-             i = reg[RRR]; /* charset */
-             if (i == CHARSET_ASCII)
-               i = reg[rrr];
-             else if (CHARSET_DIMENSION (i) == 1)
-               i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F);
-             else if (i < MIN_CHARSET_PRIVATE_DIMENSION2)
-               i = ((i - 0x8F) << 14) | (reg[rrr] & 0x3FFF);
-             else
-               i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF);
-
+             CCL_MAKE_CHAR (reg[RRR], reg[rrr], i);
              op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0);
              SPLIT_CHAR (op, reg[RRR], i, j);
              if (j != -1)
@@ -1441,6 +1450,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
                      }
                    else if (EQ (content, Qlambda))
                      {
+                       reg[RRR] = i;
                        break;
                      }
                    else
@@ -1483,13 +1493,13 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
                  reg[RRR] = -1;
                else
                  {
+                   reg[RRR] = 0;
                    content = XVECTOR (map)->contents[point];
                    if (NILP (content))
                      reg[RRR] = -1;
                    else if (NUMBERP (content))
                      reg[rrr] = XINT (content);
-                   else if (EQ (content, Qt))
-                     reg[RRR] = i;
+                   else if (EQ (content, Qt));
                    else if (CONSP (content))
                      {
                        attrib = XCAR (content);