Commit 5da9919f authored by Paul Eggert's avatar Paul Eggert

Use functions, not macros, for up- and down-casing.

parent b313f9d8
......@@ -1027,46 +1027,30 @@ extern int last_per_buffer_idx;
#define PER_BUFFER_VALUE(BUFFER, OFFSET) \
(*(Lisp_Object *)((OFFSET) + (char *) (BUFFER)))
/* Current buffer's map from characters to lower-case characters. */
#define DOWNCASE_TABLE BVAR (current_buffer, downcase_table)
/* Current buffer's map from characters to upper-case characters. */
#define UPCASE_TABLE BVAR (current_buffer, upcase_table)
/* Downcase a character, or make no change if that cannot be done. */
static inline EMACS_INT
downcase (int ch)
/* Downcase a character C, or make no change if that cannot be done. */
static inline int
downcase (int c)
{
Lisp_Object down = CHAR_TABLE_REF (DOWNCASE_TABLE, ch);
return NATNUMP (down) ? XFASTINT (down) : ch;
Lisp_Object downcase_table = BVAR (current_buffer, downcase_table);
Lisp_Object down = CHAR_TABLE_REF (downcase_table, c);
return NATNUMP (down) ? XFASTINT (down) : c;
}
#define DOWNCASE(CH) downcase (CH)
/* 1 if CH is upper case. */
#define UPPERCASEP(CH) (DOWNCASE (CH) != (CH))
/* 1 if CH is neither upper nor lower case. */
#define NOCASEP(CH) (UPCASE1 (CH) == (CH))
/* 1 if C is upper case. */
static inline int uppercasep (int c) { return downcase (c) != c; }
/* 1 if CH is lower case. */
#define LOWERCASEP(CH) (!UPPERCASEP (CH) && !NOCASEP(CH))
/* Upcase a character, or make no change if that cannot be done. */
#define UPCASE(CH) (!UPPERCASEP (CH) ? UPCASE1 (CH) : (CH))
/* Upcase a character known to be not upper case. */
static inline EMACS_INT
upcase1 (int ch)
/* Upcase a character C known to be not upper case. */
static inline int
upcase1 (int c)
{
Lisp_Object up = CHAR_TABLE_REF (UPCASE_TABLE, ch);
return NATNUMP (up) ? XFASTINT (up) : ch;
Lisp_Object upcase_table = BVAR (current_buffer, upcase_table);
Lisp_Object up = CHAR_TABLE_REF (upcase_table, c);
return NATNUMP (up) ? XFASTINT (up) : c;
}
#define UPCASE1(CH) upcase1 (CH)
/* 1 if C is lower case. */
static inline int lowercasep (int c)
{ return !uppercasep (c) && upcase1 (c) != c; }
/* Upcase a character C, or make no change if that cannot be done. */
static inline int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); }
......@@ -64,13 +64,13 @@ casify_object (enum case_action flag, Lisp_Object obj)
multibyte = 1;
if (! multibyte)
MAKE_CHAR_MULTIBYTE (c1);
c = DOWNCASE (c1);
c = downcase (c1);
if (inword)
XSETFASTINT (obj, c | flags);
else if (c == (XFASTINT (obj) & ~flagbits))
{
if (! inword)
c = UPCASE1 (c1);
c = upcase1 (c1);
if (! multibyte)
MAKE_CHAR_UNIBYTE (c);
XSETFASTINT (obj, c | flags);
......@@ -92,10 +92,10 @@ casify_object (enum case_action flag, Lisp_Object obj)
MAKE_CHAR_MULTIBYTE (c);
c1 = c;
if (inword && flag != CASE_CAPITALIZE_UP)
c = DOWNCASE (c);
else if (!UPPERCASEP (c)
c = downcase (c);
else if (!uppercasep (c)
&& (!inword || flag != CASE_CAPITALIZE_UP))
c = UPCASE1 (c1);
c = upcase1 (c1);
if ((int) flag >= (int) CASE_CAPITALIZE)
inword = (SYNTAX (c) == Sword);
if (c != c1)
......@@ -133,10 +133,10 @@ casify_object (enum case_action flag, Lisp_Object obj)
}
c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, len);
if (inword && flag != CASE_CAPITALIZE_UP)
c = DOWNCASE (c);
else if (!UPPERCASEP (c)
c = downcase (c);
else if (!uppercasep (c)
&& (!inword || flag != CASE_CAPITALIZE_UP))
c = UPCASE1 (c);
c = upcase1 (c);
if ((int) flag >= (int) CASE_CAPITALIZE)
inword = (SYNTAX (c) == Sword);
o += CHAR_STRING (c, o);
......@@ -243,10 +243,10 @@ casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e)
}
c2 = c;
if (inword && flag != CASE_CAPITALIZE_UP)
c = DOWNCASE (c);
else if (!UPPERCASEP (c)
c = downcase (c);
else if (!uppercasep (c)
&& (!inword || flag != CASE_CAPITALIZE_UP))
c = UPCASE1 (c);
c = upcase1 (c);
if ((int) flag >= (int) CASE_CAPITALIZE)
inword = ((SYNTAX (c) == Sword)
&& (inword || !syntax_prefix_flag_p (c)));
......
......@@ -790,8 +790,8 @@ scmp (const char *s1, const char *s2, int len)
if (completion_ignore_case)
{
while (l
&& (DOWNCASE ((unsigned char) *s1++)
== DOWNCASE ((unsigned char) *s2++)))
&& (downcase ((unsigned char) *s1++)
== downcase ((unsigned char) *s2++)))
l--;
}
else
......
......@@ -1374,7 +1374,7 @@ name, or nil if there is no such user. */)
memcpy (r, p, q - p);
r[q - p] = 0;
strcat (r, SSDATA (login));
r[q - p] = UPCASE ((unsigned char) r[q - p]);
r[q - p] = upcase ((unsigned char) r[q - p]);
strcat (r, q + 1);
full = build_string (r);
}
......@@ -4213,7 +4213,7 @@ Case is ignored if `case-fold-search' is non-nil in the current buffer. */)
{
int i1, i2;
/* Check they're chars, not just integers, otherwise we could get array
bounds violations in DOWNCASE. */
bounds violations in downcase. */
CHECK_CHARACTER (c1);
CHECK_CHARACTER (c2);
......@@ -4224,7 +4224,7 @@ Case is ignored if `case-fold-search' is non-nil in the current buffer. */)
/* Do these in separate statements,
then compare the variables.
because of the way DOWNCASE uses temp variables. */
because of the way downcase uses temp variables. */
i1 = XFASTINT (c1);
if (NILP (BVAR (current_buffer, enable_multibyte_characters))
&& ! ASCII_CHAR_P (i1))
......@@ -4237,8 +4237,8 @@ Case is ignored if `case-fold-search' is non-nil in the current buffer. */)
{
MAKE_CHAR_MULTIBYTE (i2);
}
i1 = DOWNCASE (i1);
i2 = DOWNCASE (i2);
i1 = downcase (i1);
i2 = downcase (i2);
return (i1 == i2 ? Qt : Qnil);
}
......
......@@ -178,7 +178,7 @@ report_file_error (const char *string, Lisp_Object data)
str = SSDATA (errstring);
c = STRING_CHAR ((unsigned char *) str);
Faset (errstring, make_number (0), make_number (DOWNCASE (c)));
Faset (errstring, make_number (0), make_number (downcase (c)));
}
xsignal (Qfile_error,
......
......@@ -9836,7 +9836,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
&& /* indec.start >= t && fkey.start >= t && */ keytran.start >= t
&& INTEGERP (key)
&& ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK))
&& UPPERCASEP (XINT (key) & ~CHAR_MODIFIER_MASK))
&& uppercasep (XINT (key) & ~CHAR_MODIFIER_MASK))
|| (XINT (key) & shift_modifier)))
{
Lisp_Object new_key;
......@@ -9847,7 +9847,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
if (XINT (key) & shift_modifier)
XSETINT (new_key, XINT (key) & ~shift_modifier);
else
XSETINT (new_key, (DOWNCASE (XINT (key) & ~CHAR_MODIFIER_MASK)
XSETINT (new_key, (downcase (XINT (key) & ~CHAR_MODIFIER_MASK)
| (XINT (key) & CHAR_MODIFIER_MASK)));
/* We have to do this unconditionally, regardless of whether
......@@ -9875,13 +9875,13 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
|| (INTEGERP (key)
&& (KEY_TO_CHAR (key)
< XCHAR_TABLE (BVAR (current_buffer, downcase_table))->size)
&& UPPERCASEP (KEY_TO_CHAR (key))))
&& uppercasep (KEY_TO_CHAR (key))))
{
Lisp_Object new_key
= (modifiers & shift_modifier
? apply_modifiers (modifiers & ~shift_modifier,
XCAR (breakdown))
: make_number (DOWNCASE (KEY_TO_CHAR (key)) | modifiers));
: make_number (downcase (KEY_TO_CHAR (key)) | modifiers));
original_uppercase = key;
original_uppercase_position = t - 1;
......
......@@ -495,7 +495,7 @@ status_message (struct Lisp_Process *p)
string = (code_convert_string_norecord
(string, Vlocale_coding_system, 0));
c1 = STRING_CHAR (SDATA (string));
c2 = DOWNCASE (c1);
c2 = downcase (c1);
if (c1 != c2)
Faset (string, make_number (0), make_number (c2));
}
......
......@@ -340,7 +340,7 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
|| ((c) >= 'A' && (c) <= 'Z')) \
: SYNTAX (c) == Sword)
# define ISLOWER(c) (LOWERCASEP (c))
# define ISLOWER(c) lowercasep (c)
# define ISPUNCT(c) (IS_REAL_ASCII (c) \
? ((c) > ' ' && (c) < 0177 \
......@@ -351,7 +351,7 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
# define ISSPACE(c) (SYNTAX (c) == Swhitespace)
# define ISUPPER(c) (UPPERCASEP (c))
# define ISUPPER(c) uppercasep (c)
# define ISWORD(c) (SYNTAX (c) == Sword)
......
......@@ -2469,7 +2469,7 @@ since only regular expressions have distinguished subexpressions. */)
else
FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, pos, pos_byte);
if (LOWERCASEP (c))
if (lowercasep (c))
{
/* Cannot be all caps if any original char is lower case */
......@@ -2479,7 +2479,7 @@ since only regular expressions have distinguished subexpressions. */)
else
some_multiletter_word = 1;
}
else if (UPPERCASEP (c))
else if (uppercasep (c))
{
some_uppercase = 1;
if (SYNTAX (prevc) != Sword)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment