* font.c (valid_font_driver) [ENABLE_CHECKING]: New function
[bpt/emacs.git] / src / coding.h
index 2c01a05..299c20d 100644 (file)
@@ -226,7 +226,7 @@ enum coding_attr_index
   hash_lookup (XHASH_TABLE (Vcoding_system_hash_table),                \
               coding_system_symbol, NULL)
 
-/* Return 1 if CODING_SYSTEM_SYMBOL is a coding system.  */
+/* Return true if CODING_SYSTEM_SYMBOL is a coding system.  */
 
 #define CODING_SYSTEM_P(coding_system_symbol)          \
   (CODING_SYSTEM_ID (coding_system_symbol) >= 0                \
@@ -240,7 +240,7 @@ enum coding_attr_index
     if (CODING_SYSTEM_ID (x) < 0                       \
        && NILP (Fcheck_coding_system (x)))             \
       wrong_type_argument (Qcoding_system_p, (x));     \
-  } while (0)
+  } while (false)
 
 
 /* Check if X is a coding system or not.  If it is, set SEPC to the
@@ -256,7 +256,7 @@ enum coding_attr_index
       }                                                        \
     if (NILP (spec))                                   \
       wrong_type_argument (Qcoding_system_p, (x));     \
-  } while (0)
+  } while (false)
 
 
 /* Check if X is a coding system or not.  If it is, set ID to the
@@ -273,7 +273,7 @@ enum coding_attr_index
        }                                                       \
       if (id < 0)                                              \
        wrong_type_argument (Qcoding_system_p, (x));    \
-    } while (0)
+    } while (false)
 
 
 /*** GENERAL section ***/
@@ -361,13 +361,13 @@ struct iso_2022_spec
 
   /* True temporarily only when graphic register 2 or 3 is invoked by
      single-shift while encoding.  */
-  unsigned single_shifting : 1;
+  bool_bf single_shifting : 1;
 
   /* True temporarily only when processing at beginning of line.  */
-  unsigned bol : 1;
+  bool_bf bol : 1;
 
   /* If true, we are now scanning embedded UTF-8 sequence.  */
-  unsigned embedded_utf_8 : 1;
+  bool_bf embedded_utf_8 : 1;
 
   /* The current composition.  */
   struct composition_status cmp_status;
@@ -455,11 +455,11 @@ struct coding_system
   unsigned char *safe_charsets;
 
   /* The following two members specify how binary 8-bit code 128..255
-     are represented in source and destination text respectively.  1
-     means they are represented by 2-byte sequence, 0 means they are
+     are represented in source and destination text respectively.  True
+     means they are represented by 2-byte sequence, false means they are
      represented by 1-byte as is (see the comment in character.h).  */
-  unsigned src_multibyte : 1;
-  unsigned dst_multibyte : 1;
+  bool_bf src_multibyte : 1;
+  bool_bf dst_multibyte : 1;
 
   /* How may heading bytes we can skip for decoding.  This is set to
      -1 in setup_coding_system, and updated by detect_coding.  So,
@@ -510,10 +510,14 @@ struct coding_system
 
   /* True if the source of conversion is not in the member
      `charbuf', but at `src_object'.  */
-  unsigned chars_at_source : 1;
+  bool_bf chars_at_source : 1;
 
-  /* Set to 1 if charbuf contains an annotation.  */
-  unsigned annotated : 1;
+  /* Nonzero if the result of conversion is in `destination'
+     buffer rather than in `dst_object'.  */
+  bool_bf raw_destination : 1;
+
+  /* Set to true if charbuf contains an annotation.  */
+  bool_bf annotated : 1;
 
   unsigned char carryover[64];
   int carryover_bytes;
@@ -539,28 +543,29 @@ struct coding_system
 #define CODING_REQUIRE_DETECTION_MASK          0x1000
 #define CODING_RESET_AT_BOL_MASK               0x2000
 
-/* Return 1 if the coding context CODING requires annotation
+/* Return nonzero if the coding context CODING requires annotation
    handling.  */
 #define CODING_REQUIRE_ANNOTATION(coding) \
   ((coding)->common_flags & CODING_ANNOTATION_MASK)
 
-/* Return 1 if the coding context CODING prefers decoding into unibyte.  */
+/* Return nonzero if the coding context CODING prefers decoding into
+   unibyte.  */
 #define CODING_FOR_UNIBYTE(coding) \
   ((coding)->common_flags & CODING_FOR_UNIBYTE_MASK)
 
-/* Return 1 if the coding context CODING requires specific code to be
+/* Return nonzero if the coding context CODING requires specific code to be
    attached at the tail of converted text.  */
 #define CODING_REQUIRE_FLUSHING(coding) \
   ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK)
 
-/* Return 1 if the coding context CODING requires code conversion on
+/* Return nonzero if the coding context CODING requires code conversion on
    decoding.  */
 #define CODING_REQUIRE_DECODING(coding)        \
   ((coding)->dst_multibyte             \
    || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK)
 
 
-/* Return 1 if the coding context CODING requires code conversion on
+/* Return nonzero if the coding context CODING requires code conversion on
    encoding.
    The non-multibyte part of the condition is to support encoding of
    unibyte strings/buffers generated by string-as-unibyte or
@@ -571,12 +576,12 @@ struct coding_system
    || (coding)->mode & CODING_MODE_SELECTIVE_DISPLAY)
 
 
-/* Return 1 if the coding context CODING requires some kind of code
+/* Return nonzero if the coding context CODING requires some kind of code
    detection.  */
 #define CODING_REQUIRE_DETECTION(coding) \
   ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK)
 
-/* Return 1 if the coding context CODING requires code conversion on
+/* Return nonzero if the coding context CODING requires code conversion on
    decoding or some kind of code detection.  */
 #define CODING_MAY_REQUIRE_DECODING(coding)    \
   (CODING_REQUIRE_DECODING (coding)            \
@@ -600,7 +605,7 @@ struct coding_system
       (j1 = s1 * 2 - ((s1 >= 0xE0) ? 0x161 : 0xE1),    \
        j2 = s2 - ((s2 >= 0x7F) ? 0x20 : 0x1F));                \
     (code) = (j1 << 8) | j2;                           \
-  } while (0)
+  } while (false)
 
 #define SJIS_TO_JIS2(code)                             \
   do {                                                 \
@@ -625,7 +630,7 @@ struct coding_system
        j2 = s2 - ((s2 >= 0x7F ? 0x20 : 0x1F));         \
       }                                                        \
     (code) = (j1 << 8) | j2;                           \
-  } while (0)
+  } while (false)
 
 
 #define JIS_TO_SJIS(code)                              \
@@ -640,7 +645,7 @@ struct coding_system
       (s1 = j1 / 2 + ((j1 < 0x5F) ? 0x70 : 0xB0),      \
        s2 = j2 + 0x7E);                                        \
     (code) = (s1 << 8) | s2;                           \
-  } while (0)
+  } while (false)
 
 #define JIS_TO_SJIS2(code)                             \
   do {                                                 \
@@ -664,44 +669,32 @@ struct coding_system
        s2 = j2 + 0x7E;                                 \
       }                                                        \
     (code) = (s1 << 8) | s2;                           \
-  } while (0)
+  } while (false)
 
 /* Encode the file name NAME using the specified coding system
    for file names, if any.  */
-#define ENCODE_FILE(name)                                                 \
-  (! NILP (Vfile_name_coding_system)                                      \
-   ? code_convert_string_norecord (name, Vfile_name_coding_system, 1)     \
-   : (! NILP (Vdefault_file_name_coding_system)                                   \
-      ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \
-      : name))
-
+#define ENCODE_FILE(NAME)  encode_file_name (NAME)
 
 /* Decode the file name NAME using the specified coding system
    for file names, if any.  */
-#define DECODE_FILE(name)                                                 \
-  (! NILP (Vfile_name_coding_system)                                      \
-   ? code_convert_string_norecord (name, Vfile_name_coding_system, 0)     \
-   : (! NILP (Vdefault_file_name_coding_system)                                   \
-      ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \
-      : name))
-
+#define DECODE_FILE(NAME)  decode_file_name (NAME)
 
 /* Encode the string STR using the specified coding system
    for system functions, if any.  */
 #define ENCODE_SYSTEM(str)                                                \
   (! NILP (Vlocale_coding_system)                                         \
-   ? code_convert_string_norecord (str, Vlocale_coding_system, 1)         \
+   ? code_convert_string_norecord (str, Vlocale_coding_system, true)      \
    : str)
 
 /* Decode the string STR using the specified coding system
    for system functions, if any.  */
 #define DECODE_SYSTEM(str)                                                \
   (! NILP (Vlocale_coding_system)                                         \
-   ? code_convert_string_norecord (str, Vlocale_coding_system, 0)         \
+   ? code_convert_string_norecord (str, Vlocale_coding_system, false)     \
    : str)
 
 /* Note that this encodes utf-8, not utf-8-emacs, so it's not a no-op.  */
-#define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1)
+#define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, true)
 
 /* Extern declarations.  */
 extern Lisp_Object code_conversion_save (bool, bool);
@@ -712,6 +705,8 @@ extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object,
                                         Lisp_Object, bool, bool, bool);
 extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object,
                                                  bool);
+extern Lisp_Object encode_file_name (Lisp_Object);
+extern Lisp_Object decode_file_name (Lisp_Object);
 extern Lisp_Object raw_text_coding_system (Lisp_Object);
 extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object);
 extern Lisp_Object complement_process_encoding_system (Lisp_Object);
@@ -765,7 +760,7 @@ extern Lisp_Object from_unicode_buffer (const wchar_t* wstr);
     (coding)->src_chars = (coding)->src_bytes = (bytes);               \
     decode_coding_object ((coding), Qnil, 0, 0, (bytes), (bytes),      \
                          (dst_object));                                \
-  } while (0)
+  } while (false)
 
 
 extern Lisp_Object preferred_coding_system (void);