emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109781: * character.c, charset.c, ch


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109781: * character.c, charset.c, chartab.c: Use bool for booleans.
Date: Sun, 26 Aug 2012 01:41:36 -0700
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109781
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sun 2012-08-26 01:41:36 -0700
message:
  * character.c, charset.c, chartab.c: Use bool for booleans.
  
  * character.c (lisp_string_width, string_count_byte8)
  (string_escape_byte8):
  * charset.c (charset_map_loaded, load_charset_map, read_hex):
  (load_charset_map_from_file, map_charset_chars)
  (Fdefine_charset_internal, define_charset_internal)
  (Fdeclare_equiv_charset, find_charsets_in_text)
  (Ffind_charset_region, char_charset, Fiso_charset):
  * chartab.c (sub_char_table_ref, sub_char_table_ref_and_range)
  (sub_char_table_set, sub_char_table_set_range)
  (char_table_set_range, optimize_sub_char_table)
  (map_sub_char_table):
  Use bool for boolean.
  * character.c (str_to_unibyte): Omit last boolean argument; it was
  always 0.  All callers changed.
  * character.h, charset.h: Adjust to match previous changes.
  * character.h (char_printable_p): Remove decl of nonexistent function.
  * charset.h (struct charset): Members code_linear_p, iso_chars_96,
  ascii_compatible_p, supplementary_p, compact_codes_p, unified_p
  are all boolean, so make them single-bit bitfields.
modified:
  src/ChangeLog
  src/character.c
  src/character.h
  src/charset.c
  src/charset.h
  src/chartab.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-08-26 05:21:04 +0000
+++ b/src/ChangeLog     2012-08-26 08:41:36 +0000
@@ -1,5 +1,26 @@
 2012-08-26  Paul Eggert  <address@hidden>
 
+       * character.c, charset.c, chartab.c: Use bool for booleans.
+       * character.c (lisp_string_width, string_count_byte8)
+       (string_escape_byte8):
+       * charset.c (charset_map_loaded, load_charset_map, read_hex):
+       (load_charset_map_from_file, map_charset_chars)
+       (Fdefine_charset_internal, define_charset_internal)
+       (Fdeclare_equiv_charset, find_charsets_in_text)
+       (Ffind_charset_region, char_charset, Fiso_charset):
+       * chartab.c (sub_char_table_ref, sub_char_table_ref_and_range)
+       (sub_char_table_set, sub_char_table_set_range)
+       (char_table_set_range, optimize_sub_char_table)
+       (map_sub_char_table):
+       Use bool for boolean.
+       * character.c (str_to_unibyte): Omit last boolean argument; it was
+       always 0.  All callers changed.
+       * character.h, charset.h: Adjust to match previous changes.
+       * character.h (char_printable_p): Remove decl of nonexistent function.
+       * charset.h (struct charset): Members code_linear_p, iso_chars_96,
+       ascii_compatible_p, supplementary_p, compact_codes_p, unified_p
+       are all boolean, so make them single-bit bitfields.
+
        * lisp.h (ASET): Remove attempt to detect side effects.
        It was meant to be temporary and it often doesn't work,
        because when IDX has side effects the behavior of IDX==IDX

=== modified file 'src/character.c'
--- a/src/character.c   2012-08-14 17:10:38 +0000
+++ b/src/character.c   2012-08-26 08:41:36 +0000
@@ -427,7 +427,7 @@
   /* This set multibyte to 0 even if STRING is multibyte when it
      contains only ascii and eight-bit-graphic, but that's
      intentional.  */
-  int multibyte = len < SBYTES (string);
+  bool multibyte = len < SBYTES (string);
   unsigned char *str = SDATA (string);
   ptrdiff_t i = 0, i_byte = 0;
   ptrdiff_t width = 0;
@@ -765,13 +765,10 @@
    corresponding byte and store in DST.  CHARS is the number of
    characters in SRC.  The value is the number of bytes stored in DST.
    Usually, the value is the same as CHARS, but is less than it if SRC
-   contains a non-ASCII, non-eight-bit character.  If ACCEPT_LATIN_1
-   is nonzero, a Latin-1 character is accepted and converted to a byte
-   of that character code.
-   Note: Currently the arg ACCEPT_LATIN_1 is not used.  */
+   contains a non-ASCII, non-eight-bit character.  */
 
 ptrdiff_t
-str_to_unibyte (const unsigned char *src, unsigned char *dst, ptrdiff_t chars, 
int accept_latin_1)
+str_to_unibyte (const unsigned char *src, unsigned char *dst, ptrdiff_t chars)
 {
   ptrdiff_t i;
 
@@ -781,8 +778,7 @@
 
       if (CHAR_BYTE8_P (c))
        c = CHAR_TO_BYTE8 (c);
-      else if (! ASCII_CHAR_P (c)
-              && (! accept_latin_1 || c >= 0x100))
+      else if (! ASCII_CHAR_P (c))
        return i;
       *dst++ = c;
     }
@@ -793,7 +789,7 @@
 static ptrdiff_t
 string_count_byte8 (Lisp_Object string)
 {
-  int multibyte = STRING_MULTIBYTE (string);
+  bool multibyte = STRING_MULTIBYTE (string);
   ptrdiff_t nbytes = SBYTES (string);
   unsigned char *p = SDATA (string);
   unsigned char *pend = p + nbytes;
@@ -825,7 +821,7 @@
 {
   ptrdiff_t nchars = SCHARS (string);
   ptrdiff_t nbytes = SBYTES (string);
-  int multibyte = STRING_MULTIBYTE (string);
+  bool multibyte = STRING_MULTIBYTE (string);
   ptrdiff_t byte8_count;
   const unsigned char *src, *src_end;
   unsigned char *dst;

=== modified file 'src/character.h'
--- a/src/character.h   2012-08-02 07:31:34 +0000
+++ b/src/character.h   2012-08-26 08:41:36 +0000
@@ -676,7 +676,6 @@
                         const unsigned char **, int *);
 
 extern int translate_char (Lisp_Object, int c);
-extern int char_printable_p (int c);
 extern void parse_str_as_multibyte (const unsigned char *,
                                    ptrdiff_t, ptrdiff_t *, ptrdiff_t *);
 extern ptrdiff_t count_size_as_multibyte (const unsigned char *, ptrdiff_t);
@@ -685,7 +684,7 @@
 extern ptrdiff_t str_to_multibyte (unsigned char *, ptrdiff_t, ptrdiff_t);
 extern ptrdiff_t str_as_unibyte (unsigned char *, ptrdiff_t);
 extern ptrdiff_t str_to_unibyte (const unsigned char *, unsigned char *,
-                                 ptrdiff_t, int);
+                                 ptrdiff_t);
 extern ptrdiff_t strwidth (const char *, ptrdiff_t);
 extern ptrdiff_t c_string_width (const unsigned char *, ptrdiff_t, int,
                                 ptrdiff_t *, ptrdiff_t *);

=== modified file 'src/charset.c'
--- a/src/charset.c     2012-08-20 08:07:38 +0000
+++ b/src/charset.c     2012-08-26 08:41:36 +0000
@@ -215,7 +215,7 @@
 
 /* Set to 1 to warn that a charset map is loaded and thus a buffer
    text and a string data may be relocated.  */
-int charset_map_loaded;
+bool charset_map_loaded;
 
 struct charset_map_entries
 {
@@ -256,7 +256,7 @@
 {
   Lisp_Object vec IF_LINT (= Qnil), table IF_LINT (= Qnil);
   unsigned max_code = CHARSET_MAX_CODE (charset);
-  int ascii_compatible_p = charset->ascii_compatible_p;
+  bool ascii_compatible_p = charset->ascii_compatible_p;
   int min_char, max_char, nonascii_min_char;
   int i;
   unsigned char *fast_map = charset->fast_map;
@@ -423,7 +423,7 @@
    paying attention to comment character '#'.  */
 
 static inline unsigned
-read_hex (FILE *fp, int *eof, int *overflow)
+read_hex (FILE *fp, bool *eof, bool *overflow)
 {
   int c;
   unsigned n;
@@ -512,7 +512,7 @@
     {
       unsigned from, to, c;
       int idx;
-      int eof = 0, overflow = 0;
+      bool eof = 0, overflow = 0;
 
       from = read_hex (fp, &eof, &overflow);
       if (eof)
@@ -717,10 +717,8 @@
                   Lisp_Object arg, struct charset *charset, unsigned from, 
unsigned to)
 {
   Lisp_Object range;
-  int partial;
-
-  partial = (from > CHARSET_MIN_CODE (charset)
-            || to < CHARSET_MAX_CODE (charset));
+  bool partial = (from > CHARSET_MIN_CODE (charset)
+                 || to < CHARSET_MAX_CODE (charset));
 
   if (CHARSET_METHOD (charset) == CHARSET_METHOD_OFFSET)
     {
@@ -855,7 +853,7 @@
   struct charset charset;
   int id;
   int dimension;
-  int new_definition_p;
+  bool new_definition_p;
   int nchars;
 
   if (nargs != charset_arg_max)
@@ -1250,7 +1248,7 @@
                         const char *code_space_chars,
                         unsigned min_code, unsigned max_code,
                         int iso_final, int iso_revision, int emacs_mule_id,
-                        int ascii_compatible, int supplementary,
+                        bool ascii_compatible, bool supplementary,
                         int code_offset)
 {
   const unsigned char *code_space = (const unsigned char *) code_space_chars;
@@ -1448,7 +1446,7 @@
   (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char, 
Lisp_Object charset)
 {
   int id;
-  int chars_flag;
+  bool chars_flag;
 
   CHECK_CHARSET_GET_ID (charset, id);
   check_iso_charset_parameter (dimension, chars, final_char);
@@ -1499,7 +1497,9 @@
    It may lookup a translation table TABLE if supplied.  */
 
 static void
-find_charsets_in_text (const unsigned char *ptr, ptrdiff_t nchars, ptrdiff_t 
nbytes, Lisp_Object charsets, Lisp_Object table, int multibyte)
+find_charsets_in_text (const unsigned char *ptr, ptrdiff_t nchars,
+                      ptrdiff_t nbytes, Lisp_Object charsets,
+                      Lisp_Object table, bool multibyte)
 {
   const unsigned char *pend = ptr + nbytes;
 
@@ -1549,7 +1549,7 @@
   ptrdiff_t from, from_byte, to, stop, stop_byte;
   int i;
   Lisp_Object val;
-  int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
+  bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
 
   validate_region (&beg, &end);
   from = XFASTINT (beg);
@@ -1735,7 +1735,7 @@
 /* Variable used temporarily by the macro ENCODE_CHAR.  */
 Lisp_Object charset_work;
 
-/* Return a code-point of CHAR in CHARSET.  If CHAR doesn't belong to
+/* Return a code-point of C in CHARSET.  If C doesn't belong to
    CHARSET, return CHARSET_INVALID_CODE (CHARSET).  If STRICT is true,
    use CHARSET's strict_max_char instead of max_char.  */
 
@@ -1978,7 +1978,7 @@
 struct charset *
 char_charset (int c, Lisp_Object charset_list, unsigned int *code_return)
 {
-  int maybe_null = 0;
+  bool maybe_null = 0;
 
   if (NILP (charset_list))
     charset_list = Vcharset_ordered_list;
@@ -2106,7 +2106,7 @@
   (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char)
 {
   int id;
-  int chars_flag;
+  bool chars_flag;
 
   check_iso_charset_parameter (dimension, chars, final_char);
   chars_flag = XFASTINT (chars) == 96;

=== modified file 'src/charset.h'
--- a/src/charset.h     2012-08-02 07:31:34 +0000
+++ b/src/charset.h     2012-08-26 08:41:36 +0000
@@ -173,12 +173,24 @@
      check if a code-point is in a valid range.  */
   unsigned char *code_space_mask;
 
-  /* 1 if there's no gap in code-points.  */
-  int code_linear_p;
-
-  /* If the charset is treated as 94-chars in ISO-2022, the value is 0.
-     If the charset is treated as 96-chars in ISO-2022, the value is 1.  */
-  int iso_chars_96;
+  /* True if there's no gap in code-points.  */
+  unsigned code_linear_p : 1;
+
+  /* True if the charset is treated as 96 chars in ISO-2022
+     as opposed to 94 chars.  */
+  unsigned iso_chars_96 : 1;
+
+  /* True if the charset is compatible with ASCII.  */
+  unsigned ascii_compatible_p : 1;
+
+  /* True if the charset is supplementary.  */
+  unsigned supplementary_p : 1;
+
+  /* True if all the code points are representable by Lisp_Int.  */
+  unsigned compact_codes_p : 1;
+
+  /* True if the charset is unified with Unicode.  */
+  unsigned unified_p : 1;
 
   /* ISO final byte of the charset: 48..127.  It may be -1 if the
      charset doesn't conform to ISO-2022.  */
@@ -192,15 +204,6 @@
      version.  Otherwise, -1.  */
   int emacs_mule_id;
 
-  /* Nonzero if the charset is compatible with ASCII.  */
-  int ascii_compatible_p;
-
-  /* Nonzero if the charset is supplementary.  */
-  int supplementary_p;
-
-  /* Nonzero if all the code points are representable by Lisp_Int.  */
-  int compact_codes_p;
-
   /* The method for encoding/decoding characters of the charset.  */
   enum charset_method method;
 
@@ -239,8 +242,6 @@
   /* Offset value to calculate a character code from code-point, and
      visa versa.  */
   int code_offset;
-
-  int unified_p;
 };
 
 /* Hash table of charset symbols vs. the corresponding attribute
@@ -456,7 +457,7 @@
 
 /* Set to 1 when a charset map is loaded to warn that a buffer text
    and a string data may be relocated.  */
-extern int charset_map_loaded;
+extern bool charset_map_loaded;
 
 
 /* Set CHARSET to the charset highest priority of C, CODE to the
@@ -474,10 +475,10 @@
    macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR).  */
 extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
 
-/* A charset of type iso2022 who has DIMENSION, CHARS, and FINAL
+/* A charset of type iso2022 who has DIMENSION, CHARS_96, and FINAL
    (final character).  */
 #define ISO_CHARSET_TABLE(dimension, chars_96, final)  \
-  iso_charset_table[(dimension) - 1][(chars_96)][(final)]
+  iso_charset_table[(dimension) - 1][chars_96][final]
 
 /* Nonzero if the charset who has FAST_MAP may contain C.  */
 #define CHARSET_FAST_MAP_REF(c, fast_map)              \

=== modified file 'src/chartab.c'
--- a/src/chartab.c     2012-08-18 23:53:43 +0000
+++ b/src/chartab.c     2012-08-26 08:41:36 +0000
@@ -200,7 +200,7 @@
 }
 
 static Lisp_Object
-sub_char_table_ref (Lisp_Object table, int c, int is_uniprop)
+sub_char_table_ref (Lisp_Object table, int c, bool is_uniprop)
 {
   struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
   int depth = XINT (tbl->depth);
@@ -245,7 +245,7 @@
 
 static Lisp_Object
 sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to,
-                             Lisp_Object defalt, int is_uniprop)
+                             Lisp_Object defalt, bool is_uniprop)
 {
   struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
   int depth = XINT (tbl->depth);
@@ -320,7 +320,7 @@
   struct Lisp_Char_Table *tbl = XCHAR_TABLE (table);
   int chartab_idx = CHARTAB_IDX (c, 0, 0), idx;
   Lisp_Object val;
-  int is_uniprop = UNIPROP_TABLE_P (table);
+  bool is_uniprop = UNIPROP_TABLE_P (table);
 
   val = tbl->contents[chartab_idx];
   if (*from < 0)
@@ -382,7 +382,7 @@
 
 
 static void
-sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop)
+sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, bool is_uniprop)
 {
   struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
   int depth = XINT ((tbl)->depth);
@@ -438,7 +438,7 @@
 
 static void
 sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val,
-                         int is_uniprop)
+                         bool is_uniprop)
 {
   struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
   int depth = XINT ((tbl)->depth);
@@ -484,7 +484,7 @@
     char_table_set (table, from, val);
   else
     {
-      int is_uniprop = UNIPROP_TABLE_P (table);
+      bool is_uniprop = UNIPROP_TABLE_P (table);
       int lim = CHARTAB_IDX (to, 0, 0);
       int i, c;
 
@@ -683,7 +683,8 @@
   struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
   int depth = XINT (tbl->depth);
   Lisp_Object elt, this;
-  int i, optimizable;
+  int i;
+  bool optimizable;
 
   elt = XSUB_CHAR_TABLE (table)->contents[0];
   if (SUB_CHAR_TABLE_P (elt))
@@ -762,7 +763,7 @@
   int chars_in_block;
   int from = XINT (XCAR (range)), to = XINT (XCDR (range));
   int i, c;
-  int is_uniprop = UNIPROP_TABLE_P (top);
+  bool is_uniprop = UNIPROP_TABLE_P (top);
   uniprop_decoder_t decoder = UNIPROP_GET_DECODER (top);
 
   if (SUB_CHAR_TABLE_P (table))
@@ -811,7 +812,7 @@
            this = XCHAR_TABLE (top)->defalt;
          if (!EQ (val, this))
            {
-             int different_value = 1;
+             bool different_value = 1;
 
              if (NILP (val))
                {


reply via email to

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