changeset 17186:65bc06706714

Adjusted for the change of MAX_CHARSET. (str_cmpchar_id): Return -1 if we have no more room for a new composite character. (Fmake_char_internal): Docstring is moved to lisp/mule.el.
author Kenichi Handa <handa@m17n.org>
date Tue, 18 Mar 1997 23:31:34 +0000
parents 0d5a1bae9d73
children 9ab0c08a3359
files src/charset.c
diffstat 1 files changed, 23 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c	Tue Mar 18 23:31:34 1997 +0000
+++ b/src/charset.c	Tue Mar 18 23:31:34 1997 +0000
@@ -80,6 +80,14 @@
    CHARS, and FINAL-CHAR) to Emacs' charset.  */
 int iso_charset_table[2][2][128];
 
+/* Table of pointers to the structure `cmpchar_info' indexed by
+   CMPCHAR-ID.  */
+struct cmpchar_info **cmpchar_table;
+/* The current size of `cmpchar_table'.  */
+static int cmpchar_table_size;
+/* Number of the current composite characters.  */
+int n_cmpchars;
+
 /* Variables used locally in the macro FETCH_MULTIBYTE_CHAR.  */
 unsigned char *_fetch_multibyte_char_p;
 int _fetch_multibyte_char_len;
@@ -293,7 +301,7 @@
        is set to nil.  */
     int i;
 
-    for (i = 0; i < MAX_CHARSET; i++)
+    for (i = 0; i <= MAX_CHARSET; i++)
       if (!NILP (CHARSET_TABLE_ENTRY (i)))
 	{
 	  if (CHARSET_DIMENSION (i) == XINT (dimension)
@@ -307,7 +315,7 @@
 	      break;
 	    }
 	}
-    if (i >= MAX_CHARSET)
+    if (i > MAX_CHARSET)
       /* No such a charset.  */
       CHARSET_TABLE_INFO (charset, CHARSET_REVERSE_CHARSET_IDX)
 	= make_number (-1);
@@ -487,7 +495,7 @@
 
 /* Return number of different charsets in STR of length LEN.  In
    addition, for each found charset N, CHARSETS[N] is set 1.  The
-   caller should allocate CHARSETS (MAX_CHARSET bytes) in advance.  */
+   caller should allocate CHARSETS (MAX_CHARSET + 1 bytes) in advance.  */
 
 int
 find_charset_in_str (str, len, charsets)
@@ -519,7 +527,7 @@
   (beg, end)
      Lisp_Object beg, end;
 {
-  char charsets[MAX_CHARSET];
+  char charsets[MAX_CHARSET + 1];
   int from, to, stop, i;
   Lisp_Object val;
 
@@ -528,7 +536,7 @@
   stop = to = XFASTINT (end);
   if (from < GPT && GPT < to)
     stop = GPT;
-  bzero (charsets, MAX_CHARSET);
+  bzero (charsets, MAX_CHARSET + 1);
   while (1)
     {
       find_charset_in_str (POS_ADDR (from), stop - from, charsets);
@@ -538,7 +546,7 @@
 	break;
     }
   val = Qnil;
-  for (i = MAX_CHARSET - 1; i >= 0; i--)
+  for (i = MAX_CHARSET; i >= 0; i--)
     if (charsets[i])
       val = Fcons (CHARSET_SYMBOL (i), val);
   return val;
@@ -550,27 +558,22 @@
   (str)
      Lisp_Object str;
 {
-  char charsets[MAX_CHARSET];
+  char charsets[MAX_CHARSET + 1];
   int i;
   Lisp_Object val;
 
   CHECK_STRING (str, 0);
-  bzero (charsets, MAX_CHARSET);
+  bzero (charsets, MAX_CHARSET + 1);
   find_charset_in_str (XSTRING (str)->data, XSTRING (str)->size, charsets);
   val = Qnil;
-  for (i = MAX_CHARSET - 1; i >= 0; i--)
+  for (i = MAX_CHARSET; i >= 0; i--)
     if (charsets[i])
       val = Fcons (CHARSET_SYMBOL (i), val);
   return val;
 }
 
 DEFUN ("make-char-internal", Fmake_char_internal, Smake_char_internal, 1, 3, 0,
-  "Return a character of CHARSET and position-codes CODE1 and CODE2.\n\
-CODE1 and CODE2 are optional, but if you don't supply\n\
- sufficient position-codes, return a generic character which stands for\n\
-all characters or group of characters in the character sets.\n\
-A generic character can be an argument of `modify-syntax-entry' and\n\
-`modify-category-entry'.")
+  "")
   (charset, code1, code2)
      Lisp_Object charset, code1, code2;
 {
@@ -910,14 +913,6 @@
 }
 #endif
 
-/* Table of pointers to the structure `cmpchar_info' indexed by
-   CMPCHAR-ID.  */
-struct cmpchar_info **cmpchar_table;
-/* The current size of `cmpchar_table'.  */
-static int cmpchar_table_size;
-/* Number of the current composite characters.  */
-int n_cmpchars;
-
 #define CMPCHAR_HASH_TABLE_SIZE 0xFFF
 
 static int *cmpchar_hash_table[CMPCHAR_HASH_TABLE_SIZE];
@@ -993,6 +988,10 @@
       }
 
   /* We have to register the composite character in cmpchar_table.  */
+  if (n_cmpchars > (CHAR_FIELD2_MASK | CHAR_FIELD3_MASK))
+    /* No, we have no more room for a new composite character.  */
+    return -1;
+
   /* Make the entry in hash table.  */
   if (hashp == NULL)
     {
@@ -1345,7 +1344,7 @@
   Fput (Qcharset_table, Qchar_table_extra_slots, make_number (0));
   Vcharset_table = Fmake_char_table (Qcharset_table, Qnil);
 
-  Vcharset_symbol_table = Fmake_vector (make_number (MAX_CHARSET), Qnil);
+  Vcharset_symbol_table = Fmake_vector (make_number (MAX_CHARSET + 1), Qnil);
 
   /* Setup tables.  */
   for (i = 0; i < 2; i++)