aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-07-06 14:07:46 -0700
committerPaul Eggert2012-07-06 14:07:46 -0700
commitfee5959dd8b389bc222618a35b042a92a1358c21 (patch)
tree936ae7da59bfa6d4c15f03929bbf6090190ea23a /src
parentfd573f31dcaec9cd5170ba33af10d7c71c56822c (diff)
downloademacs-fee5959dd8b389bc222618a35b042a92a1358c21.tar.gz
emacs-fee5959dd8b389bc222618a35b042a92a1358c21.zip
Use c_strcasecmp for ASCII case-insensitive comparison.
Fixes: debbugs:11786
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/dispextern.h12
-rw-r--r--src/nsfns.m5
-rw-r--r--src/nsterm.m5
-rw-r--r--src/xfaces.c24
5 files changed, 20 insertions, 33 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 96458770122..3f8cbdff476 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
12012-07-06 Paul Eggert <eggert@cs.ucla.edu> 12012-07-06 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Use c_strcasecmp for ASCII case-insensitive comparison (Bug#11786).
4 * dispextern.h, nsfns.m, nsterm.m: Include <c-strcase.h>.
5 * dispextern.h (xstrcasecmp): Rewrite using c_strcasecmp.
6 * nsfns.m (x_get_string_resource): Use c_strncasecmp, not strncasecmp.
7 * nsterm.m (ns_default): Use c_strcasecmp, not strcasecmp.
8 * xfaces.c (xstrcasecmp) [!HAVE_STRCASECMP]: Remove.
9
3 * xfont.c (compare_font_names): Redo to omit the need for casts. 10 * xfont.c (compare_font_names): Redo to omit the need for casts.
4 11
52012-07-06 Andreas Schwab <schwab@linux-m68k.org> 122012-07-06 Andreas Schwab <schwab@linux-m68k.org>
diff --git a/src/dispextern.h b/src/dispextern.h
index 4672d108e93..7d9f913e4f1 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -46,6 +46,13 @@ typedef struct {
46#include "msdos.h" 46#include "msdos.h"
47#endif 47#endif
48 48
49#include <c-strcase.h>
50static inline int
51xstrcasecmp (char const *a, char const *b)
52{
53 return c_strcasecmp (a, b);
54}
55
49#ifdef HAVE_X_WINDOWS 56#ifdef HAVE_X_WINDOWS
50typedef struct x_display_info Display_Info; 57typedef struct x_display_info Display_Info;
51typedef XImage * XImagePtr; 58typedef XImage * XImagePtr;
@@ -3198,11 +3205,6 @@ void unload_color (struct frame *, unsigned long);
3198char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object, 3205char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object,
3199 int *); 3206 int *);
3200void prepare_face_for_display (struct frame *, struct face *); 3207void prepare_face_for_display (struct frame *, struct face *);
3201#ifdef HAVE_STRCASECMP
3202#define xstrcasecmp(x,y) strcasecmp ((x), (y))
3203#else
3204int xstrcasecmp (const char *, const char *);
3205#endif
3206int lookup_named_face (struct frame *, Lisp_Object, int); 3208int lookup_named_face (struct frame *, Lisp_Object, int);
3207int lookup_basic_face (struct frame *, int); 3209int lookup_basic_face (struct frame *, int);
3208int smaller_face (struct frame *, int, int); 3210int smaller_face (struct frame *, int, int);
diff --git a/src/nsfns.m b/src/nsfns.m
index 5303a5ec313..47943e5d98a 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -33,6 +33,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
33#include <signal.h> 33#include <signal.h>
34#include <math.h> 34#include <math.h>
35#include <setjmp.h> 35#include <setjmp.h>
36#include <c-strcase.h>
36 37
37#include "lisp.h" 38#include "lisp.h"
38#include "blockinput.h" 39#include "blockinput.h"
@@ -2226,8 +2227,8 @@ x_get_string_resource (XrmDatabase rdb, char *name, char *class)
2226 2227
2227 res = ns_get_defaults_value (toCheck); 2228 res = ns_get_defaults_value (toCheck);
2228 return !res ? NULL : 2229 return !res ? NULL :
2229 (!strncasecmp (res, "YES", 3) ? "true" : 2230 (!c_strncasecmp (res, "YES", 3) ? "true" :
2230 (!strncasecmp (res, "NO", 2) ? "false" : res)); 2231 (!c_strncasecmp (res, "NO", 2) ? "false" : res));
2231} 2232}
2232 2233
2233 2234
diff --git a/src/nsterm.m b/src/nsterm.m
index ae536638c33..1cd4c1c4271 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -36,6 +36,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
36#include <signal.h> 36#include <signal.h>
37#include <unistd.h> 37#include <unistd.h>
38#include <setjmp.h> 38#include <setjmp.h>
39#include <c-strcase.h>
39 40
40#include "lisp.h" 41#include "lisp.h"
41#include "blockinput.h" 42#include "blockinput.h"
@@ -3848,9 +3849,9 @@ ns_default (const char *parameter, Lisp_Object *result,
3848 { 3849 {
3849 double f; 3850 double f;
3850 char *pos; 3851 char *pos;
3851 if (strcasecmp (value, "YES") == 0) 3852 if (c_strcasecmp (value, "YES") == 0)
3852 *result = yesval; 3853 *result = yesval;
3853 else if (strcasecmp (value, "NO") == 0) 3854 else if (c_strcasecmp (value, "NO") == 0)
3854 *result = noval; 3855 *result = noval;
3855 else if (is_float && (f = strtod (value, &pos), pos != value)) 3856 else if (is_float && (f = strtod (value, &pos), pos != value))
3856 *result = make_float (f); 3857 *result = make_float (f);
diff --git a/src/xfaces.c b/src/xfaces.c
index a1062a44232..bc42cb4312a 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -715,30 +715,6 @@ x_free_gc (struct frame *f, GC gc)
715} 715}
716#endif /* HAVE_NS */ 716#endif /* HAVE_NS */
717 717
718#ifndef HAVE_STRCASECMP
719/* Like strcasecmp/stricmp. Used to compare parts of font names which
720 are in ISO8859-1. */
721
722int
723xstrcasecmp (const char *s1, const char *s2)
724{
725 while (*s1 && *s2)
726 {
727 unsigned char b1 = *s1;
728 unsigned char b2 = *s2;
729 unsigned char c1 = tolower (b1);
730 unsigned char c2 = tolower (b2);
731 if (c1 != c2)
732 return c1 < c2 ? -1 : 1;
733 ++s1, ++s2;
734 }
735
736 if (*s1 == 0)
737 return *s2 == 0 ? 0 : -1;
738 return 1;
739}
740#endif /* HAVE_STRCASECMP */
741
742/* If FRAME is nil, return a pointer to the selected frame. 718/* If FRAME is nil, return a pointer to the selected frame.
743 Otherwise, check that FRAME is a live frame, and return a pointer 719 Otherwise, check that FRAME is a live frame, and return a pointer
744 to it. NPARAM is the parameter number of FRAME, for 720 to it. NPARAM is the parameter number of FRAME, for