changeset 26866:305531847450

(readchar): Adjusted for the change of CHAR_STRING. Delete a code that handles an invalid too-long multibyte sequence because we are now sure that we never encounter with such a sequence. (read_multibyte): Use macro MAX_MULTIBYTE_LENGTH, not MAX_LENGTH_OF_MULTI_BYTE_FORM. (init_obarray): Likewise. (read1): Likewise. Adjusted for the change of CHAR_STRING.
author Kenichi Handa <handa@m17n.org>
date Wed, 15 Dec 1999 00:17:03 +0000
parents 87623e53b7c6
children b633c8e0fee1
files src/lread.c
diffstat 1 files changed, 8 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/src/lread.c	Wed Dec 15 00:16:30 1999 +0000
+++ b/src/lread.c	Wed Dec 15 00:17:03 1999 +0000
@@ -219,31 +219,10 @@
 
       if (! NILP (inbuffer->enable_multibyte_characters))
 	{
-	  unsigned char workbuf[4];
-	  unsigned char *str = workbuf;
-	  int length;
-
 	  /* Fetch the character code from the buffer.  */
 	  unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte);
 	  BUF_INC_POS (inbuffer, pt_byte);
 	  c = STRING_CHAR (p, pt_byte - orig_pt_byte);
-
-	  /* Find the byte-sequence representation of that character.  */
-	  if (SINGLE_BYTE_CHAR_P (c))
-	    length = 1, workbuf[0] = c;
-	  else
-	    length = non_ascii_char_to_string (c, workbuf, &str);
-
-	  /* If the bytes for this character in the buffer
-	     are not identical with what the character code implies,
-	     read the bytes one by one from the buffer.  */
-	  if (length != pt_byte - orig_pt_byte
-	      || (length == 1 ? *str != *p : bcmp (str, p, length)))
-	    {
-	      readchar_backlog = pt_byte - orig_pt_byte;
-	      c = BUF_FETCH_BYTE (inbuffer, orig_pt_byte);
-	      readchar_backlog--;
-	    }
 	}
       else
 	{
@@ -276,31 +255,10 @@
 
       if (! NILP (inbuffer->enable_multibyte_characters))
 	{
-	  unsigned char workbuf[4];
-	  unsigned char *str = workbuf;
-	  int length;
-
 	  /* Fetch the character code from the buffer.  */
 	  unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos);
 	  BUF_INC_POS (inbuffer, bytepos);
 	  c = STRING_CHAR (p, bytepos - orig_bytepos);
-
-	  /* Find the byte-sequence representation of that character.  */
-	  if (SINGLE_BYTE_CHAR_P (c))
-	    length = 1, workbuf[0] = c;
-	  else
-	    length = non_ascii_char_to_string (c, workbuf, &str);
-
-	  /* If the bytes for this character in the buffer
-	     are not identical with what the character code implies,
-	     read the bytes one by one from the buffer.  */
-	  if (length != bytepos - orig_bytepos
-	      || (length == 1 ? *str != *p : bcmp (str, p, length)))
-	    {
-	      readchar_backlog = bytepos - orig_bytepos;
-	      c = BUF_FETCH_BYTE (inbuffer, orig_bytepos);
-	      readchar_backlog--;
-	    }
 	}
       else
 	{
@@ -1399,12 +1357,12 @@
 {
   /* We need the actual character code of this multibyte
      characters.  */
-  unsigned char str[MAX_LENGTH_OF_MULTI_BYTE_FORM];
+  unsigned char str[MAX_MULTIBYTE_LENGTH];
   int len = 0;
 
   str[len++] = c;
   while ((c = READCHAR) >= 0xA0
-	 && len < MAX_LENGTH_OF_MULTI_BYTE_FORM)
+	 && len < MAX_MULTIBYTE_LENGTH)
     str[len++] = c;
   UNREAD (c);
   return STRING_CHAR (str, len);
@@ -1935,7 +1893,7 @@
 	while ((c = READCHAR) >= 0
 	       && c != '\"')
 	  {
-	    if (end - p < MAX_LENGTH_OF_MULTI_BYTE_FORM)
+	    if (end - p < MAX_MULTIBYTE_LENGTH)
 	      {
 		char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
 		p += new - read_buffer;
@@ -1964,19 +1922,11 @@
 
 	    if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
 	      {
-		unsigned char workbuf[4];
-		unsigned char *str = workbuf;
-		int length;
-
 		/* Any modifiers for a multibyte character are invalid.  */
 		if (c & CHAR_MODIFIER_MASK)
 		  error ("Invalid modifier in string");
-		length = non_ascii_char_to_string (c, workbuf, &str);
-		if (length > 1)
-		  force_multibyte = 1;
-
-		bcopy (str, p, length);
-		p += length;
+		p += CHAR_STRING (c, p);
+		force_multibyte = 1;
 	      }
 	    else
 	      {
@@ -2090,7 +2040,7 @@
 		      || c == '[' || c == ']' || c == '#'
 		      ))
 	    {
-	      if (end - p < MAX_LENGTH_OF_MULTI_BYTE_FORM)
+	      if (end - p < MAX_MULTIBYTE_LENGTH)
 		{
 		  register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
 		  p += new - read_buffer;
@@ -2104,16 +2054,7 @@
 		}
 
 	      if (! SINGLE_BYTE_CHAR_P (c))
-		{
-		  unsigned char workbuf[4];
-		  unsigned char *str = workbuf;
-		  int length;
-
-		  length = non_ascii_char_to_string (c, workbuf, &str);
-
-		  bcopy (str, p, length);
-		  p += length;
-		}
+		p += CHAR_STRING (c, p);
 	      else
 		*p++ = c;
 
@@ -2994,7 +2935,7 @@
   Qvariable_documentation = intern ("variable-documentation");
   staticpro (&Qvariable_documentation);
 
-  read_buffer_size = 100 + MAX_LENGTH_OF_MULTI_BYTE_FORM;
+  read_buffer_size = 100 + MAX_MULTIBYTE_LENGTH;
   read_buffer = (char *) malloc (read_buffer_size);
 }