(Vmicrosoft_code_table): This variable deleted.
[bpt/emacs.git] / src / coding.h
index 07a0960..6aa9a45 100644 (file)
@@ -1,7 +1,6 @@
 /* Header for coding system handler.
-   Ver.1.0
-   Copyright (C) 1995 Free Software Foundation, Inc.
-   Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
+   Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
+   Licensed to the Free Software Foundation.
 
 This file is part of GNU Emacs.
 
@@ -136,6 +135,17 @@ enum iso_code_class_type
    on output.  */
 #define CODING_FLAG_ISO_DESIGNATE_AT_BOL 0x0400
 
+/* If set, do not encode unexpected charactes on output.  */
+#define CODING_FLAG_ISO_SAFE           0x0800
+
+/* If set, extra latin codes (128..159) are accepted as a valid code
+   on input.  */
+#define CODING_FLAG_ISO_LATIN_EXTRA    0x1000
+
+/* A character to be produced on output if encoding of the original
+   character is prohibited by CODING_FLAG_ISO_SAFE.  */
+#define CODING_INHIBIT_CHARACTER_SUBSTITUTION  077 /* 077 == `?' */
+
 /* Structure of the field `spec.iso2022' in the structure `coding_system'.  */
 struct iso2022_spec
 {
@@ -151,6 +161,12 @@ struct iso2022_spec
   /* A graphic register to which each charset should be designated.  */
   unsigned char requested_designation[MAX_CHARSET + 1];
 
+  /* Table of expected character sets for this coding system.  If the
+     Nth element is 0, the charset of ID N is not an expected
+     character set.  Such a character set is not encoded when
+     CODING_ISO_FLAG_SAFE is set.  */
+  unsigned char expected_charsets[MAX_CHARSET + 1];
+
   /* Set to 1 temporarily only when graphic register 2 or 3 is invoked
      by single-shift while encoding.  */
   int single_shifting;
@@ -168,6 +184,8 @@ struct iso2022_spec
   coding->spec.iso2022.initial_designation[reg]
 #define CODING_SPEC_ISO_REQUESTED_DESIGNATION(coding, charset) \
   coding->spec.iso2022.requested_designation[charset]
+#define CODING_SPEC_ISO_EXPECTED_CHARSETS(coding) \
+  coding->spec.iso2022.expected_charsets
 #define CODING_SPEC_ISO_SINGLE_SHIFTING(coding) \
   coding->spec.iso2022.single_shifting
 #define CODING_SPEC_ISO_BOL(coding) \
@@ -296,8 +314,9 @@ struct coding_system
      additional conversion. */
   Lisp_Object pre_write_conversion;
 
-  /* Character unification table to look up, or nil.  */
-  Lisp_Object character_unification_table;
+  /* Character unification tables to look up, or nil.  */
+  Lisp_Object character_unification_table_for_decode;
+  Lisp_Object character_unification_table_for_encode;
 
   /* Carryover yielded by decoding/encoding incomplete source.  No
      coding-system yields more than 7-byte of carryover.  This does
@@ -309,22 +328,19 @@ struct coding_system
   int carryover_size;
 };
 
-/* Return 1 if the coding-system CODING requires conversion of
-   representation of a visible character (text).  */
-#define CODING_REQUIRE_TEXT_CONVERSION(coding) \
-  ((coding)->type != coding_type_no_conversion         \
-   && (coding)->type != coding_type_emacs_mule)
-
-/* Return 1 if the coding-system CODING requires conversion of the
-   format of end-of-line.  */
-#define CODING_REQUIRE_EOL_CONVERSION(coding)  \
-  ((coding)->eol_type != CODING_EOL_UNDECIDED          \
-   && (coding)->eol_type != CODING_EOL_LF)
+/* Return 1 if coding system CODING never requires any code conversion.  */
+#define CODING_REQUIRE_NO_CONVERSION(coding)           \
+  (((coding)->type == coding_type_no_conversion                \
+    || (coding)->type == coding_type_emacs_mule)       \
+   && (coding)->eol_type == CODING_EOL_LF)
 
-/* Return 1 if the coding-system CODING requires some conversion.  */
-#define CODING_REQUIRE_CONVERSION(coding)      \
-  (CODING_REQUIRE_TEXT_CONVERSION (coding)     \
-   || CODING_REQUIRE_EOL_CONVERSION (coding))
+/* Return 1 if coding system CODING may not require code conversion.  */
+#define CODING_MAY_REQUIRE_NO_CONVERSION(coding)       \
+  (((coding)->type == coding_type_no_conversion                \
+    || (coding)->type == coding_type_emacs_mule                \
+    || (coding)->type == coding_type_undecided)                \
+   && ((coding)->eol_type == CODING_EOL_LF             \
+       || (coding)->eol_type == CODING_EOL_UNDECIDED))
 
 /* Index for each coding category in `coding_category_table' */
 #define CODING_CATEGORY_IDX_EMACS_MULE 0
@@ -332,10 +348,11 @@ struct coding_system
 #define CODING_CATEGORY_IDX_ISO_7      2
 #define CODING_CATEGORY_IDX_ISO_8_1    3
 #define CODING_CATEGORY_IDX_ISO_8_2    4
-#define CODING_CATEGORY_IDX_ISO_ELSE   5
-#define CODING_CATEGORY_IDX_BIG5       6
-#define CODING_CATEGORY_IDX_BINARY     7
-#define CODING_CATEGORY_IDX_MAX                8
+#define CODING_CATEGORY_IDX_ISO_7_ELSE 5
+#define CODING_CATEGORY_IDX_ISO_8_ELSE 6
+#define CODING_CATEGORY_IDX_BIG5       7
+#define CODING_CATEGORY_IDX_BINARY     8
+#define CODING_CATEGORY_IDX_MAX                9
 
 /* Definitions of flag bits returned by the function
    detect_coding_mask ().  */
@@ -344,8 +361,10 @@ struct coding_system
 #define CODING_CATEGORY_MASK_ISO_7     (1 << CODING_CATEGORY_IDX_ISO_7)
 #define CODING_CATEGORY_MASK_ISO_8_1   (1 << CODING_CATEGORY_IDX_ISO_8_1)
 #define CODING_CATEGORY_MASK_ISO_8_2   (1 << CODING_CATEGORY_IDX_ISO_8_2)
-#define CODING_CATEGORY_MASK_ISO_ELSE  (1 << CODING_CATEGORY_IDX_ISO_ELSE)
+#define CODING_CATEGORY_MASK_ISO_7_ELSE        (1 << CODING_CATEGORY_IDX_ISO_7_ELSE)
+#define CODING_CATEGORY_MASK_ISO_8_ELSE        (1 << CODING_CATEGORY_IDX_ISO_8_ELSE)
 #define CODING_CATEGORY_MASK_BIG5      (1 << CODING_CATEGORY_IDX_BIG5)
+#define CODING_CATEGORY_MASK_BINARY    (1 << CODING_CATEGORY_IDX_BINARY)
 
 /* This value is returned if detect_coding_mask () find nothing other
    than ASCII characters.  */
@@ -355,7 +374,8 @@ struct coding_system
    | CODING_CATEGORY_MASK_ISO_7                \
    | CODING_CATEGORY_MASK_ISO_8_1      \
    | CODING_CATEGORY_MASK_ISO_8_2      \
-   | CODING_CATEGORY_MASK_ISO_ELSE     \
+   | CODING_CATEGORY_MASK_ISO_7_ELSE   \
+   | CODING_CATEGORY_MASK_ISO_8_ELSE   \
    | CODING_CATEGORY_MASK_BIG5)
 
 /* Macros to decode or encode a character of JISX0208 in SJIS.  S1 and
@@ -390,6 +410,7 @@ extern int conversion_buffer_size;
 extern char *conversion_buffer, *get_conversion_buffer ();
 extern Lisp_Object Fcheck_coding_system ();
 extern Lisp_Object Qcoding_system, Qeol_type, Qcoding_category_index;
+extern Lisp_Object Qemacs_mule;
 extern Lisp_Object Qbuffer_file_coding_system;
 extern Lisp_Object Vcoding_category_list;
 
@@ -420,6 +441,10 @@ extern Lisp_Object Vlast_coding_system_used;
    function `set-terminal-coding-system'.  */
 extern struct coding_system terminal_coding;
 
+/* Coding system to be used to encode text for terminal display when
+   terminal coding system is nil.  */
+extern struct coding_system safe_terminal_coding;
+
 /* Coding-system of what is sent from terminal keyboard.  This
    structure contains information of a coding-system specified by the
    function `set-keyboard-coding-system'.  */