changeset 90534:2811bff46a36

(casify_object): Sync with HEAD.
author Kenichi Handa <handa@m17n.org>
date Thu, 20 Jul 2006 12:09:16 +0000
parents 8a8e69664178
children 5b86e23f4fdb
files src/casefiddle.c
diffstat 1 files changed, 63 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/src/casefiddle.c	Wed Jul 19 00:42:56 2006 +0000
+++ b/src/casefiddle.c	Thu Jul 20 12:09:16 2006 +0000
@@ -45,83 +45,81 @@
   if (NILP (XCHAR_TABLE (current_buffer->downcase_table)->extras[1]))
     Fset_case_table (current_buffer->downcase_table);
 
-  while (1)
+  if (INTEGERP (obj))
     {
-      if (INTEGERP (obj))
+      int flagbits = (CHAR_ALT | CHAR_SUPER | CHAR_HYPER
+		      | CHAR_SHIFT | CHAR_CTL | CHAR_META);
+      int flags = XINT (obj) & flagbits;
+      int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
+
+      /* If the character has higher bits set
+	 above the flags, return it unchanged.
+	 It is not a real character.  */
+      if ((unsigned) XFASTINT (obj) > (unsigned) flagbits)
+	return obj;
+
+      c1 = XFASTINT (obj) & ~flagbits;
+      if (! multibyte)
+	MAKE_CHAR_MULTIBYTE (c1);
+      c = DOWNCASE (c1);
+      if (inword)
+	XSETFASTINT (obj, c | flags);
+      else if (c == (XFASTINT (obj) & ~flagbits))
 	{
-	  int flagbits = (CHAR_ALT | CHAR_SUPER | CHAR_HYPER
-			  | CHAR_SHIFT | CHAR_CTL | CHAR_META);
-	  int flags = XINT (obj) & flagbits;
-	  int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
-
-	  /* If the character has higher bits set
-	     above the flags, return it unchanged.
-	     It is not a real character.  */
-	  if ((unsigned) XFASTINT (obj) > (unsigned) flagbits)
-	    return obj;
-
-	  c1 = XFASTINT (obj) & ~flagbits;
+	  if (! inword)
+	    c = UPCASE1 (c1);
 	  if (! multibyte)
-	    MAKE_CHAR_MULTIBYTE (c1);
-	  c = DOWNCASE (c1);
-	  if (inword)
-	    XSETFASTINT (obj, c | flags);
-	  else if (c == (XFASTINT (obj) & ~flagbits))
+	    MAKE_CHAR_UNIBYTE (c);
+	  XSETFASTINT (obj, c | flags);
+	}
+      return obj;
+    }
+
+  if (STRINGP (obj))
+    {
+      int multibyte = STRING_MULTIBYTE (obj);
+      int i, i_byte, len;
+      int size = SCHARS (obj);
+
+      obj = Fcopy_sequence (obj);
+      for (i = i_byte = 0; i < size; i++, i_byte += len)
+	{
+	  if (multibyte)
+	    c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, 0, len);
+	  else
 	    {
-	      if (! inword)
-		c = UPCASE1 (c1);
-	      if (! multibyte)
-		MAKE_CHAR_UNIBYTE (c);
-	      XSETFASTINT (obj, c | flags);
+	      c = SREF (obj, i_byte);
+	      len = 1;
+	      MAKE_CHAR_MULTIBYTE (c);
 	    }
-	  return obj;
-	}
-
-      if (STRINGP (obj))
-	{
-	  int multibyte = STRING_MULTIBYTE (obj);
-	  int i, i_byte, len;
-	  int size = SCHARS (obj);
-
-	  obj = Fcopy_sequence (obj);
-	  for (i = i_byte = 0; i < size; i++, i_byte += len)
+	  c1 = c;
+	  if (inword && flag != CASE_CAPITALIZE_UP)
+	    c = DOWNCASE (c);
+	  else if (!UPPERCASEP (c)
+		   && (!inword || flag != CASE_CAPITALIZE_UP))
+	    c = UPCASE1 (c1);
+	  if ((int) flag >= (int) CASE_CAPITALIZE)
+	    inword = (SYNTAX (c) == Sword);
+	  if (c != c1)
 	    {
-	      if (multibyte)
-		c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, 0, len);
+	      if (! multibyte)
+		{
+		  MAKE_CHAR_UNIBYTE (c);
+		  SSET (obj, i_byte, c);
+		}
+	      else if (ASCII_CHAR_P (c1) && ASCII_CHAR_P (c))
+		SSET (obj, i_byte,  c);
 	      else
 		{
-		  c = SREF (obj, i_byte);
-		  len = 1;
-		  MAKE_CHAR_MULTIBYTE (c);
-		}
-	      c1 = c;
-	      if (inword && flag != CASE_CAPITALIZE_UP)
-		c = DOWNCASE (c);
-	      else if (!UPPERCASEP (c)
-		       && (!inword || flag != CASE_CAPITALIZE_UP))
-		c = UPCASE1 (c1);
-	      if ((int) flag >= (int) CASE_CAPITALIZE)
-		inword = (SYNTAX (c) == Sword);
-	      if (c != c1)
-		{
-		  if (! multibyte)
-		    {
-		      MAKE_CHAR_UNIBYTE (c);
-		      SSET (obj, i_byte, c);
-		    }
-		  else if (ASCII_CHAR_P (c1) && ASCII_CHAR_P (c))
-		    SSET (obj, i_byte,  c);
-		  else
-		    {
-		      Faset (obj, make_number (i), make_number (c));
-		      i_byte += CHAR_BYTES (c) - len;
-		    }
+		  Faset (obj, make_number (i), make_number (c));
+		  i_byte += CHAR_BYTES (c) - len;
 		}
 	    }
-	  return obj;
 	}
-      obj = wrong_type_argument (Qchar_or_string_p, obj);
+      return obj;
     }
+
+  wrong_type_argument (Qchar_or_string_p, obj);
 }
 
 DEFUN ("upcase", Fupcase, Supcase, 1, 1, 0,