From 25a48bd06bd5979d201cddde99e2dec1eb54c184 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 5 Feb 2011 02:20:15 -0800 Subject: [PATCH] xstrcasecmp: conform to C89 pointer rules --- src/ChangeLog | 5 +++++ src/dispextern.h | 3 +-- src/font.c | 6 +++--- src/fontset.c | 2 +- src/ftfont.c | 6 +++--- src/image.c | 4 ++-- src/process.c | 4 ++-- src/xfaces.c | 32 +++++++++++++++++--------------- src/xfont.c | 4 ++-- 9 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 48d3983e253..02644342d46 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2011-02-05 Paul Eggert + 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 (define_charset_internal): Switch between char * and unsigned char *. diff --git a/src/dispextern.h b/src/dispextern.h index 26e0bb61f17..6d54ebefd84 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3151,7 +3151,7 @@ char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object, int *); int ascii_face_of_lisp_face (struct frame *, int); 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_basic_face (struct frame *, 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 /* not DISPEXTERN_H_INCLUDED */ - diff --git a/src/font.c b/src/font.c index 907271566da..394c0055328 100644 --- a/src/font.c +++ b/src/font.c @@ -315,7 +315,7 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror if (SYMBOLP (val)) { - unsigned char *s; + char *s; Lisp_Object args[2], elt; /* 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) | (i << 4) | (j - 1)); /* Try also with case-folding match. */ - s = SDATA (SYMBOL_NAME (val)); + s = SSDATA (SYMBOL_NAME (val)); for (i = 0; i < len; i++) for (j = 1; j < ASIZE (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) | (i << 4) | (j - 1)); } diff --git a/src/fontset.c b/src/fontset.c index f94bc954fa4..f297fd10a71 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -1166,7 +1166,7 @@ fs_query_fontset (Lisp_Object name, int name_pattern) this_name = FONTSET_NAME (fontset); if (name_pattern == 1 ? fast_string_match_ignore_case (name, this_name) >= 0 - : !xstrcasecmp (SDATA (name), SDATA (this_name))) + : !xstrcasecmp (SSDATA (name), SSDATA (this_name))) return i; } return -1; diff --git a/src/ftfont.c b/src/ftfont.c index a20f2013e5a..576bc42a6ff 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -1022,12 +1022,12 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) if (! NILP (adstyle) && (NILP (this_adstyle) - || xstrcasecmp (SDATA (SYMBOL_NAME (adstyle)), - SDATA (SYMBOL_NAME (this_adstyle))) != 0)) + || xstrcasecmp (SSDATA (SYMBOL_NAME (adstyle)), + SSDATA (SYMBOL_NAME (this_adstyle))) != 0)) continue; if (langname && ! NILP (this_adstyle) - && xstrcasecmp (langname, SDATA (SYMBOL_NAME (this_adstyle)))) + && xstrcasecmp (langname, SSDATA (SYMBOL_NAME (this_adstyle)))) continue; } entity = ftfont_pattern_entity (fontset->fonts[i], diff --git a/src/image.c b/src/image.c index 8303fac4c98..717d41eb91b 100644 --- a/src/image.c +++ b/src/image.c @@ -3906,7 +3906,7 @@ xpm_load_image (struct frame *f, while (num_colors-- > 0) { - unsigned char *color, *max_color; + char *color, *max_color; int key, next_key, max_key = 0; Lisp_Object symbol_color = Qnil, color_val; XColor cdef; @@ -3958,7 +3958,7 @@ xpm_load_image (struct frame *f, 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; else if (x_defined_color (f, SDATA (XCDR (specified_color)), &cdef, 0)) diff --git a/src/process.c b/src/process.c index ca29145bfd4..da97e3de18a 100644 --- a/src/process.c +++ b/src/process.c @@ -6168,10 +6168,10 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */) ; else { - unsigned char *name; + char *name; CHECK_SYMBOL (sigcode); - name = SDATA (SYMBOL_NAME (sigcode)); + name = SSDATA (SYMBOL_NAME (sigcode)); if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3)) name += 3; diff --git a/src/xfaces.c b/src/xfaces.c index f1d21c098f0..e4f9f317b8e 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -716,12 +716,14 @@ x_free_gc (struct frame *f, GC gc) are in ISO8859-1. */ int -xstrcasecmp (const unsigned char *s1, const unsigned char *s2) +xstrcasecmp (const char *s1, const char *s2) { while (*s1 && *s2) { - unsigned char c1 = tolower (*s1); - unsigned char c2 = tolower (*s2); + unsigned char b1 = *s1; + unsigned char b2 = *s2; + unsigned char c1 = tolower (b1); + unsigned char c2 = tolower (b2); if (c1 != c2) return c1 < c2 ? -1 : 1; ++s1, ++s2; @@ -3466,13 +3468,13 @@ face_boolean_x_resource_value (Lisp_Object value, int signal_p) xassert (STRINGP (value)); - if (xstrcasecmp (SDATA (value), "on") == 0 - || xstrcasecmp (SDATA (value), "true") == 0) + if (xstrcasecmp (SSDATA (value), "on") == 0 + || xstrcasecmp (SSDATA (value), "true") == 0) result = Qt; - else if (xstrcasecmp (SDATA (value), "off") == 0 - || xstrcasecmp (SDATA (value), "false") == 0) + else if (xstrcasecmp (SSDATA (value), "off") == 0 + || xstrcasecmp (SSDATA (value), "false") == 0) result = Qnil; - else if (xstrcasecmp (SDATA (value), "unspecified") == 0) + else if (xstrcasecmp (SSDATA (value), "unspecified") == 0) result = Qunspecified; else if (signal_p) 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_STRING (value); - if (xstrcasecmp (SDATA (value), "unspecified") == 0) + if (xstrcasecmp (SSDATA (value), "unspecified") == 0) value = Qunspecified; 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) && lface_fully_specified_p (lface2)); - return (xstrcasecmp (SDATA (lface1[LFACE_FAMILY_INDEX]), - SDATA (lface2[LFACE_FAMILY_INDEX])) == 0 - && xstrcasecmp (SDATA (lface1[LFACE_FOUNDRY_INDEX]), - SDATA (lface2[LFACE_FOUNDRY_INDEX])) == 0 + return (xstrcasecmp (SSDATA (lface1[LFACE_FAMILY_INDEX]), + SSDATA (lface2[LFACE_FAMILY_INDEX])) == 0 + && xstrcasecmp (SSDATA (lface1[LFACE_FOUNDRY_INDEX]), + SSDATA (lface2[LFACE_FOUNDRY_INDEX])) == 0 && EQ (lface1[LFACE_HEIGHT_INDEX], lface2[LFACE_HEIGHT_INDEX]) && EQ (lface1[LFACE_SWIDTH_INDEX], lface2[LFACE_SWIDTH_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]) || (STRINGP (lface1[LFACE_FONTSET_INDEX]) && STRINGP (lface2[LFACE_FONTSET_INDEX]) - && ! xstrcasecmp (SDATA (lface1[LFACE_FONTSET_INDEX]), - SDATA (lface2[LFACE_FONTSET_INDEX])))) + && ! xstrcasecmp (SSDATA (lface1[LFACE_FONTSET_INDEX]), + SSDATA (lface2[LFACE_FONTSET_INDEX])))) ); } diff --git a/src/xfont.c b/src/xfont.c index 51b1c1c6ded..222b4d9edf9 100644 --- a/src/xfont.c +++ b/src/xfont.c @@ -164,8 +164,8 @@ xfont_get_cache (FRAME_PTR f) static int compare_font_names (const void *name1, const void *name2) { - return xstrcasecmp (*(const unsigned char **) name1, - *(const unsigned char **) name2); + return xstrcasecmp (*(const char **) name1, + *(const char **) name2); } /* Decode XLFD as iso-8859-1 into OUTPUT, and return the byte length -- 2.39.5