changeset 88948:1ff7f42f40ad

(charset_eight_bit, Qeight_bit_control): New variables. (charset_8_bit__control, charset_8_bit_graphic, Qeight_bit_control, Qeight_bit_graphic): These variables deleted. (define_charset_internal): New function. (syms_of_charset): Call define_charset_internal for pre-defined charsets.
author Kenichi Handa <handa@m17n.org>
date Wed, 31 Jul 2002 07:07:59 +0000
parents 894b8bce3208
children 57ca0c34b3be
files src/charset.c
diffstat 1 files changed, 88 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c	Wed Jul 31 07:06:36 2002 +0000
+++ b/src/charset.c	Wed Jul 31 07:07:59 2002 +0000
@@ -69,15 +69,13 @@
 
 /* Special charset symbols.  */
 Lisp_Object Qascii;
-Lisp_Object Qeight_bit_control;
-Lisp_Object Qeight_bit_graphic;
+Lisp_Object Qeight_bit;
 Lisp_Object Qiso_8859_1;
 Lisp_Object Qunicode;
 
 /* The corresponding charsets.  */
 int charset_ascii;
-int charset_8_bit_control;
-int charset_8_bit_graphic;
+int charset_eight_bit;
 int charset_iso_8859_1;
 int charset_unicode;
 
@@ -1016,11 +1014,13 @@
 				     hash_code);
       if (charset_table_used == charset_table_size)
 	{
-	  charset_table_size += 256;
-	  charset_table
-	    = ((struct charset *)
-	       xrealloc (charset_table,
-			 sizeof (struct charset) * charset_table_size));
+	  struct charset *new_table
+	    = (struct charset *) xmalloc (sizeof (struct charset)
+					  * (charset_table_size + 16));
+	  bcopy (charset_table, new_table,
+		 sizeof (struct charset) * charset_table_size);
+	  charset_table_size += 16;
+	  charset_table = new_table;
 	}
       id = charset_table_used++;
       new_definition_p = 1;
@@ -1066,6 +1066,74 @@
   return Qnil;
 }
 
+
+/* Same as Fdefine_charset_internal but arguments are more convenient
+   to call from C (typically in syms_of_charset).  This can define a
+   charset of `offset' method only.  Return the ID of the new
+   charset.  */
+
+static int
+define_charset_internal (name, dimension, code_space, min_code, max_code,
+			 iso_final, iso_revision, emacs_mule_id,
+			 ascii_compatible, supprementary,
+			 code_offset)
+     Lisp_Object name;
+     int dimension;
+     unsigned char *code_space;
+     unsigned min_code, max_code;
+     int iso_final, iso_revision, emacs_mule_id;
+     int ascii_compatible, supprementary;
+     int code_offset;
+{
+  Lisp_Object args[charset_arg_max];
+  Lisp_Object plist[14];
+  Lisp_Object val;
+  int i;
+
+  args[charset_arg_name] = name;
+  args[charset_arg_dimension] = make_number (dimension);
+  val = Fmake_vector (make_number (8), make_number (0));
+  for (i = 0; i < 8; i++)
+    ASET (val, i, make_number (code_space[i]));
+  args[charset_arg_code_space] = val;
+  args[charset_arg_min_code] = make_number (min_code);
+  args[charset_arg_max_code] = make_number (max_code);
+  args[charset_arg_iso_final]
+    = (iso_final < 0 ? Qnil : make_number (iso_final));
+  args[charset_arg_iso_revision] = make_number (iso_revision);
+  args[charset_arg_emacs_mule_id]
+    = (emacs_mule_id < 0 ? Qnil : make_number (emacs_mule_id));
+  args[charset_arg_ascii_compatible_p] = ascii_compatible ? Qt : Qnil;
+  args[charset_arg_supplementary_p] = supprementary ? Qt : Qnil;
+  args[charset_arg_invalid_code] = Qnil;
+  args[charset_arg_code_offset] = make_number (code_offset);
+  args[charset_arg_map] = Qnil;
+  args[charset_arg_subset] = Qnil;
+  args[charset_arg_superset] = Qnil;
+  args[charset_arg_unify_map] = Qnil;
+
+  plist[0] = intern (":name");
+  plist[1] = args[charset_arg_name];
+  plist[2] = intern (":dimension");
+  plist[3] = args[charset_arg_dimension];
+  plist[4] = intern (":code-space");
+  plist[5] = args[charset_arg_code_space];
+  plist[6] = intern (":iso-final-char");
+  plist[7] = args[charset_arg_iso_final];
+  plist[8] = intern (":emacs-mule-id");
+  plist[9] = args[charset_arg_emacs_mule_id];
+  plist[10] = intern (":ascii-compatible-p");
+  plist[11] = args[charset_arg_ascii_compatible_p];
+  plist[12] = intern (":code-offset");
+  plist[13] = args[charset_arg_code_offset];
+
+  args[charset_arg_plist] = Flist (14, plist);
+  Fdefine_charset_internal (charset_arg_max, args);
+
+  return XINT (CHARSET_SYMBOL_ID (name));
+}
+
+
 DEFUN ("define-charset-alias", Fdefine_charset_alias,
        Sdefine_charset_alias, 2, 2, 0,
        doc: /* Define ALIAS as an alias for charset CHARSET.  */)
@@ -1984,8 +2052,7 @@
 
   DEFSYM (Qascii, "ascii");
   DEFSYM (Qunicode, "unicode");
-  DEFSYM (Qeight_bit_control, "eight-bit-control");
-  DEFSYM (Qeight_bit_graphic, "eight-bit-graphic");
+  DEFSYM (Qeight_bit, "eight-bit");
   DEFSYM (Qiso_8859_1, "iso-8859-1");
 
   DEFSYM (Qgl, "gl");
@@ -2047,82 +2114,16 @@
 	       doc: /* List of all charsets ever defined.  */);
   Vcharset_list = Qnil;
 
-  /* Make the prerequisite charset `ascii' and `unicode'.  */
-  {
-    Lisp_Object args[charset_arg_max];
-    Lisp_Object plist[14];
-    Lisp_Object val;
-
-    plist[0] = intern (":name");
-    plist[2] = intern (":dimension");
-    plist[4] = intern (":code-space");
-    plist[6] = intern (":iso-final-char");
-    plist[8] = intern (":emacs-mule-id");
-    plist[10] = intern (":ascii-compatible-p");
-    plist[12] = intern (":code-offset");
-
-    args[charset_arg_name] = Qascii;
-    args[charset_arg_dimension] = make_number (1);
-    val = Fmake_vector (make_number (8), make_number (0));
-    ASET (val, 1, make_number (127));
-    args[charset_arg_code_space] = val;
-    args[charset_arg_min_code] = Qnil;
-    args[charset_arg_max_code] = Qnil;
-    args[charset_arg_iso_final] = make_number ('B');
-    args[charset_arg_iso_revision] = Qnil;
-    args[charset_arg_emacs_mule_id] = make_number (0);
-    args[charset_arg_ascii_compatible_p] = Qt;
-    args[charset_arg_supplementary_p] = Qnil;
-    args[charset_arg_invalid_code] = Qnil;
-    args[charset_arg_code_offset] = make_number (0);
-    args[charset_arg_map] = Qnil;
-    args[charset_arg_subset] = Qnil;
-    args[charset_arg_superset] = Qnil;
-    args[charset_arg_unify_map] = Qnil;
-    /* The actual plist is set by mule-conf.el.  */
-    plist[1] = args[charset_arg_name];
-    plist[3] = args[charset_arg_dimension];
-    plist[5] = args[charset_arg_code_space];
-    plist[7] = args[charset_arg_iso_final];
-    plist[9] = args[charset_arg_emacs_mule_id];
-    plist[11] = args[charset_arg_ascii_compatible_p];
-    plist[13] = args[charset_arg_code_offset];
-    args[charset_arg_plist] = Flist (14, plist);
-    Fdefine_charset_internal (charset_arg_max, args);
-    charset_ascii = XINT (CHARSET_SYMBOL_ID (Qascii));
-
-    args[charset_arg_name] = Qunicode;
-    args[charset_arg_dimension] = make_number (3);
-    val = Fmake_vector (make_number (8), make_number (0));
-    ASET (val, 1, make_number (255));
-    ASET (val, 3, make_number (255));
-    ASET (val, 5, make_number (16));
-    args[charset_arg_code_space] = val;
-    args[charset_arg_min_code] = Qnil;
-    args[charset_arg_max_code] = Qnil;
-    args[charset_arg_iso_final] = Qnil;
-    args[charset_arg_iso_revision] = Qnil;
-    args[charset_arg_emacs_mule_id] = Qnil;
-    args[charset_arg_ascii_compatible_p] = Qt;
-    args[charset_arg_supplementary_p] = Qnil;
-    args[charset_arg_invalid_code] = Qnil;
-    args[charset_arg_code_offset] = make_number (0);
-    args[charset_arg_map] = Qnil;
-    args[charset_arg_subset] = Qnil;
-    args[charset_arg_superset] = Qnil;
-    args[charset_arg_unify_map] = Qnil;
-    /* The actual plist is set by mule-conf.el.  */
-    plist[1] = args[charset_arg_name];
-    plist[3] = args[charset_arg_dimension];
-    plist[5] = args[charset_arg_code_space];
-    plist[7] = args[charset_arg_iso_final];
-    plist[9] = args[charset_arg_emacs_mule_id];
-    plist[11] = args[charset_arg_ascii_compatible_p];
-    plist[13] = args[charset_arg_code_offset];
-    args[charset_arg_plist] = Flist (14, plist);
-    Fdefine_charset_internal (charset_arg_max, args);
-    charset_unicode = XINT (CHARSET_SYMBOL_ID (Qunicode));
-  }
+  charset_ascii
+    = define_charset_internal (Qascii, 1, "\x00\x7F\x00\x00\x00\x00",
+			       0, 127, 'B', -1, 0, 1, 0, 0);
+  charset_unicode
+    = define_charset_internal (Qunicode, 3, "\x00\x7F\x00\x7F\x00\x10",
+			       0, MAX_UNICODE_CHAR, -1, 0, -1, 1, 0, 0);
+  charset_eight_bit
+    = define_charset_internal (Qeight_bit, 1, "\x80\xFF\x00\x00\x00\x00",
+			       128, 255, -1, 0, -1, 0, 0,
+			       MAX_5_BYTE_CHAR + 1);
 }
 
 #endif /* emacs */