Merge: xstrcasecmp: conform to C89 pointer rules

This commit is contained in:
Paul Eggert 2011-02-05 02:22:19 -08:00
commit 1a8ae90761
9 changed files with 36 additions and 30 deletions

View file

@ -1,5 +1,10 @@
2011-02-05 Paul Eggert <eggert@cs.ucla.edu> 2011-02-05 Paul Eggert <eggert@cs.ucla.edu>
xstrcasecmp: conform to C89 pointer rules
* xfaces.c (xstrcasecmp): Change args from const unsigned char *
to const char *, since they're usually low-level C strings, and
this stays compatible with C89 pointer rules. All callers changed.
* charset.c: conform to C89 pointer rules * charset.c: conform to C89 pointer rules
(define_charset_internal): Switch between char * and unsigned char *. (define_charset_internal): Switch between char * and unsigned char *.

View file

@ -3151,7 +3151,7 @@ char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object,
int *); int *);
int ascii_face_of_lisp_face (struct frame *, int); int ascii_face_of_lisp_face (struct frame *, int);
void prepare_face_for_display (struct frame *, struct face *); void prepare_face_for_display (struct frame *, struct face *);
int xstrcasecmp (const unsigned char *, const unsigned char *); int xstrcasecmp (const char *, const char *);
int lookup_named_face (struct frame *, Lisp_Object, int); int lookup_named_face (struct frame *, Lisp_Object, int);
int lookup_basic_face (struct frame *, int); int lookup_basic_face (struct frame *, int);
int smaller_face (struct frame *, int, int); int smaller_face (struct frame *, int, int);
@ -3361,4 +3361,3 @@ extern Lisp_Object x_default_parameter (struct frame *, Lisp_Object,
#endif /* HAVE_WINDOW_SYSTEM */ #endif /* HAVE_WINDOW_SYSTEM */
#endif /* not DISPEXTERN_H_INCLUDED */ #endif /* not DISPEXTERN_H_INCLUDED */

View file

@ -315,7 +315,7 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror
if (SYMBOLP (val)) if (SYMBOLP (val))
{ {
unsigned char *s; char *s;
Lisp_Object args[2], elt; Lisp_Object args[2], elt;
/* At first try exact match. */ /* At first try exact match. */
@ -325,12 +325,12 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror
return ((XINT (AREF (AREF (table, i), 0)) << 8) return ((XINT (AREF (AREF (table, i), 0)) << 8)
| (i << 4) | (j - 1)); | (i << 4) | (j - 1));
/* Try also with case-folding match. */ /* Try also with case-folding match. */
s = SDATA (SYMBOL_NAME (val)); s = SSDATA (SYMBOL_NAME (val));
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
for (j = 1; j < ASIZE (AREF (table, i)); j++) for (j = 1; j < ASIZE (AREF (table, i)); j++)
{ {
elt = AREF (AREF (table, i), j); elt = AREF (AREF (table, i), j);
if (xstrcasecmp (s, SDATA (SYMBOL_NAME (elt))) == 0) if (xstrcasecmp (s, SSDATA (SYMBOL_NAME (elt))) == 0)
return ((XINT (AREF (AREF (table, i), 0)) << 8) return ((XINT (AREF (AREF (table, i), 0)) << 8)
| (i << 4) | (j - 1)); | (i << 4) | (j - 1));
} }

View file

@ -1166,7 +1166,7 @@ fs_query_fontset (Lisp_Object name, int name_pattern)
this_name = FONTSET_NAME (fontset); this_name = FONTSET_NAME (fontset);
if (name_pattern == 1 if (name_pattern == 1
? fast_string_match_ignore_case (name, this_name) >= 0 ? fast_string_match_ignore_case (name, this_name) >= 0
: !xstrcasecmp (SDATA (name), SDATA (this_name))) : !xstrcasecmp (SSDATA (name), SSDATA (this_name)))
return i; return i;
} }
return -1; return -1;

View file

@ -1022,12 +1022,12 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec)
if (! NILP (adstyle) if (! NILP (adstyle)
&& (NILP (this_adstyle) && (NILP (this_adstyle)
|| xstrcasecmp (SDATA (SYMBOL_NAME (adstyle)), || xstrcasecmp (SSDATA (SYMBOL_NAME (adstyle)),
SDATA (SYMBOL_NAME (this_adstyle))) != 0)) SSDATA (SYMBOL_NAME (this_adstyle))) != 0))
continue; continue;
if (langname if (langname
&& ! NILP (this_adstyle) && ! NILP (this_adstyle)
&& xstrcasecmp (langname, SDATA (SYMBOL_NAME (this_adstyle)))) && xstrcasecmp (langname, SSDATA (SYMBOL_NAME (this_adstyle))))
continue; continue;
} }
entity = ftfont_pattern_entity (fontset->fonts[i], entity = ftfont_pattern_entity (fontset->fonts[i],

View file

@ -3906,7 +3906,7 @@ xpm_load_image (struct frame *f,
while (num_colors-- > 0) while (num_colors-- > 0)
{ {
unsigned char *color, *max_color; char *color, *max_color;
int key, next_key, max_key = 0; int key, next_key, max_key = 0;
Lisp_Object symbol_color = Qnil, color_val; Lisp_Object symbol_color = Qnil, color_val;
XColor cdef; XColor cdef;
@ -3958,7 +3958,7 @@ xpm_load_image (struct frame *f,
if (CONSP (specified_color) && STRINGP (XCDR (specified_color))) if (CONSP (specified_color) && STRINGP (XCDR (specified_color)))
{ {
if (xstrcasecmp (SDATA (XCDR (specified_color)), "None") == 0) if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0)
color_val = Qt; color_val = Qt;
else if (x_defined_color (f, SDATA (XCDR (specified_color)), else if (x_defined_color (f, SDATA (XCDR (specified_color)),
&cdef, 0)) &cdef, 0))

View file

@ -6168,10 +6168,10 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
; ;
else else
{ {
unsigned char *name; char *name;
CHECK_SYMBOL (sigcode); CHECK_SYMBOL (sigcode);
name = SDATA (SYMBOL_NAME (sigcode)); name = SSDATA (SYMBOL_NAME (sigcode));
if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3)) if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3))
name += 3; name += 3;

View file

@ -716,12 +716,14 @@ x_free_gc (struct frame *f, GC gc)
are in ISO8859-1. */ are in ISO8859-1. */
int int
xstrcasecmp (const unsigned char *s1, const unsigned char *s2) xstrcasecmp (const char *s1, const char *s2)
{ {
while (*s1 && *s2) while (*s1 && *s2)
{ {
unsigned char c1 = tolower (*s1); unsigned char b1 = *s1;
unsigned char c2 = tolower (*s2); unsigned char b2 = *s2;
unsigned char c1 = tolower (b1);
unsigned char c2 = tolower (b2);
if (c1 != c2) if (c1 != c2)
return c1 < c2 ? -1 : 1; return c1 < c2 ? -1 : 1;
++s1, ++s2; ++s1, ++s2;
@ -3466,13 +3468,13 @@ face_boolean_x_resource_value (Lisp_Object value, int signal_p)
xassert (STRINGP (value)); xassert (STRINGP (value));
if (xstrcasecmp (SDATA (value), "on") == 0 if (xstrcasecmp (SSDATA (value), "on") == 0
|| xstrcasecmp (SDATA (value), "true") == 0) || xstrcasecmp (SSDATA (value), "true") == 0)
result = Qt; result = Qt;
else if (xstrcasecmp (SDATA (value), "off") == 0 else if (xstrcasecmp (SSDATA (value), "off") == 0
|| xstrcasecmp (SDATA (value), "false") == 0) || xstrcasecmp (SSDATA (value), "false") == 0)
result = Qnil; result = Qnil;
else if (xstrcasecmp (SDATA (value), "unspecified") == 0) else if (xstrcasecmp (SSDATA (value), "unspecified") == 0)
result = Qunspecified; result = Qunspecified;
else if (signal_p) else if (signal_p)
signal_error ("Invalid face attribute value from X resource", value); signal_error ("Invalid face attribute value from X resource", value);
@ -3491,7 +3493,7 @@ DEFUN ("internal-set-lisp-face-attribute-from-resource",
CHECK_SYMBOL (attr); CHECK_SYMBOL (attr);
CHECK_STRING (value); CHECK_STRING (value);
if (xstrcasecmp (SDATA (value), "unspecified") == 0) if (xstrcasecmp (SSDATA (value), "unspecified") == 0)
value = Qunspecified; value = Qunspecified;
else if (EQ (attr, QCheight)) else if (EQ (attr, QCheight))
{ {
@ -4051,10 +4053,10 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
{ {
xassert (lface_fully_specified_p (lface1) xassert (lface_fully_specified_p (lface1)
&& lface_fully_specified_p (lface2)); && lface_fully_specified_p (lface2));
return (xstrcasecmp (SDATA (lface1[LFACE_FAMILY_INDEX]), return (xstrcasecmp (SSDATA (lface1[LFACE_FAMILY_INDEX]),
SDATA (lface2[LFACE_FAMILY_INDEX])) == 0 SSDATA (lface2[LFACE_FAMILY_INDEX])) == 0
&& xstrcasecmp (SDATA (lface1[LFACE_FOUNDRY_INDEX]), && xstrcasecmp (SSDATA (lface1[LFACE_FOUNDRY_INDEX]),
SDATA (lface2[LFACE_FOUNDRY_INDEX])) == 0 SSDATA (lface2[LFACE_FOUNDRY_INDEX])) == 0
&& EQ (lface1[LFACE_HEIGHT_INDEX], lface2[LFACE_HEIGHT_INDEX]) && EQ (lface1[LFACE_HEIGHT_INDEX], lface2[LFACE_HEIGHT_INDEX])
&& EQ (lface1[LFACE_SWIDTH_INDEX], lface2[LFACE_SWIDTH_INDEX]) && EQ (lface1[LFACE_SWIDTH_INDEX], lface2[LFACE_SWIDTH_INDEX])
&& EQ (lface1[LFACE_WEIGHT_INDEX], lface2[LFACE_WEIGHT_INDEX]) && EQ (lface1[LFACE_WEIGHT_INDEX], lface2[LFACE_WEIGHT_INDEX])
@ -4063,8 +4065,8 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
&& (EQ (lface1[LFACE_FONTSET_INDEX], lface2[LFACE_FONTSET_INDEX]) && (EQ (lface1[LFACE_FONTSET_INDEX], lface2[LFACE_FONTSET_INDEX])
|| (STRINGP (lface1[LFACE_FONTSET_INDEX]) || (STRINGP (lface1[LFACE_FONTSET_INDEX])
&& STRINGP (lface2[LFACE_FONTSET_INDEX]) && STRINGP (lface2[LFACE_FONTSET_INDEX])
&& ! xstrcasecmp (SDATA (lface1[LFACE_FONTSET_INDEX]), && ! xstrcasecmp (SSDATA (lface1[LFACE_FONTSET_INDEX]),
SDATA (lface2[LFACE_FONTSET_INDEX])))) SSDATA (lface2[LFACE_FONTSET_INDEX]))))
); );
} }

View file

@ -164,8 +164,8 @@ xfont_get_cache (FRAME_PTR f)
static int static int
compare_font_names (const void *name1, const void *name2) compare_font_names (const void *name1, const void *name2)
{ {
return xstrcasecmp (*(const unsigned char **) name1, return xstrcasecmp (*(const char **) name1,
*(const unsigned char **) name2); *(const char **) name2);
} }
/* Decode XLFD as iso-8859-1 into OUTPUT, and return the byte length /* Decode XLFD as iso-8859-1 into OUTPUT, and return the byte length