summaryrefslogtreecommitdiff
path: root/src/casefiddle.c
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2006-07-20 12:09:16 +0000
committerKenichi Handa <handa@m17n.org>2006-07-20 12:09:16 +0000
commit0d64f689595195a896eb9fdb433ce9b337c14518 (patch)
tree62791ea518b4add6a62f4b7dcb499fa5de395393 /src/casefiddle.c
parent63db3c1b3ffa669435b10aa362115ef664990ab2 (diff)
downloademacs-0d64f689595195a896eb9fdb433ce9b337c14518.tar.gz
(casify_object): Sync with HEAD.
Diffstat (limited to 'src/casefiddle.c')
-rw-r--r--src/casefiddle.c124
1 files changed, 61 insertions, 63 deletions
diff --git a/src/casefiddle.c b/src/casefiddle.c
index ba9b3e3adf4..8eb3cc69fca 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -45,83 +45,81 @@ casify_object (flag, obj)
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))
- {
- if (! inword)
- c = UPCASE1 (c1);
- if (! multibyte)
- MAKE_CHAR_UNIBYTE (c);
- XSETFASTINT (obj, c | flags);
- }
- return obj;
+ 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);
+ 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)
+ 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 (multibyte)
- c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, 0, len);
- 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)
{
- c = SREF (obj, i_byte);
- len = 1;
- MAKE_CHAR_MULTIBYTE (c);
+ MAKE_CHAR_UNIBYTE (c);
+ SSET (obj, i_byte, 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)
+ else if (ASCII_CHAR_P (c1) && ASCII_CHAR_P (c))
+ SSET (obj, i_byte, c);
+ else
{
- 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,