2012-07-06 Paul Eggert <eggert@cs.ucla.edu>
+ Use c_strcasecmp for ASCII case-insensitive comparison (Bug#11786).
+ This is safer than strcasecmp, which has unspecified behavior
+ outside the POSIX locale and in practice sometimes does not work
+ in multibyte locales. Similarly for c_strncasecmp and strncasecmp.
+ * configure.in (strcasecmp, strncasecmp): Remove checks.
+ * lib/c-ctype.c, lib/c-ctype.h, lib/c-strcase.h, lib/c-strcasecmp.c:
+ * lib/c-strncasecmp.c: New files, taken from gnulib.
+ * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
+
Merge from gnulib, incorporating:
2012-07-06 timespec-sub: avoid duplicate include
Reported by Juanma Barranquero.
+2012-07-06 Paul Eggert <eggert@cs.ucla.edu>
+
+ Use c_strcasecmp for ASCII case-insensitive comparison (Bug#11786).
+ * merge-gnulib (GNULIB_MODULES): Add c-strcase.
+
2012-07-05 Dmitry Antipov <dmantipov@yandex.ru>
* coccinelle/xzalloc.cocci: Semantic patch to convert
GNULIB_URL=git://git.savannah.gnu.org/gnulib.git
GNULIB_MODULES='
- alloca-opt
+ alloca-opt c-strcase
careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512
dtoastr dtotimespec dup2
filemode getloadavg getopt-gnu gettime gettimeofday
difftime posix_memalign \
getpwent endpwent getgrent endgrent \
touchlock \
-strcasecmp strncasecmp \
cfmakeraw cfsetspeed copysign __executable_start)
dnl Cannot use AC_CHECK_FUNCS
+2012-07-06 Paul Eggert <eggert@cs.ucla.edu>
+
+ Use c_strcasecmp for ASCII case-insensitive comparison (Bug#11786).
+ * etags.c: Include c-strcase.h.
+ (etags_strcasecmp, etags_strncasecmp): Remove.
+ All uses replaced with c_strcasecmp and c_strncasecmp.
+
2012-07-06 Andreas Schwab <schwab@linux-m68k.org>
* make-docfile.c (write_globals): Warn about duplicate function
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <c-strcase.h>
#include <assert.h>
#ifdef NDEBUG
#endif
#define streq(s,t) (assert ((s)!=NULL || (t)!=NULL), !strcmp (s, t))
-#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t))
+#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !c_strcasecmp (s, t))
#define strneq(s,t,n) (assert ((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
-#define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !etags_strncasecmp (s, t, n))
+#define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !c_strncasecmp (s, t, n))
#define CHARS 256 /* 2^sizeof(char) */
#define CHAR(x) ((unsigned int)(x) & (CHARS - 1))
static char *savestr (const char *);
static char *etags_strchr (const char *, int);
static char *etags_strrchr (const char *, int);
-#ifdef HAVE_STRCASECMP
-#define etags_strcasecmp(x,y) strcasecmp ((x), (y))
-#else
-static int etags_strcasecmp (const char *, const char *);
-#endif
-#ifdef HAVE_STRNCASECMP
-#define etags_strncasecmp(x,y,z) strncasecmp ((x), (y), (z))
-#else
-static int etags_strncasecmp (const char *, const char *, int);
-#endif
static char *etags_getcwd (void);
static char *relative_filename (char *, char *);
static char *absolute_filename (char *, char *);
return NULL;
}
-#ifndef HAVE_STRCASECMP
-/*
- * Compare two strings, ignoring case for alphabetic characters.
- *
- * Same as BSD's strcasecmp, included for portability.
- */
-static int
-etags_strcasecmp (register const char *s1, register const char *s2)
-{
- while (*s1 != '\0'
- && (ISALPHA (*s1) && ISALPHA (*s2)
- ? lowcase (*s1) == lowcase (*s2)
- : *s1 == *s2))
- s1++, s2++;
-
- return (ISALPHA (*s1) && ISALPHA (*s2)
- ? lowcase (*s1) - lowcase (*s2)
- : *s1 - *s2);
-}
-#endif /* HAVE_STRCASECMP */
-
-#ifndef HAVE_STRNCASECMP
-/*
- * Compare two strings, ignoring case for alphabetic characters.
- * Stop after a given number of characters
- *
- * Same as BSD's strncasecmp, included for portability.
- */
-static int
-etags_strncasecmp (register const char *s1, register const char *s2, register int n)
-{
- while (*s1 != '\0' && n-- > 0
- && (ISALPHA (*s1) && ISALPHA (*s2)
- ? lowcase (*s1) == lowcase (*s2)
- : *s1 == *s2))
- s1++, s2++;
-
- if (n < 0)
- return 0;
- else
- return (ISALPHA (*s1) && ISALPHA (*s2)
- ? lowcase (*s1) - lowcase (*s2)
- : *s1 - *s2);
-}
-#endif /* HAVE_STRCASECMP */
-
/* Skip spaces (end of string is not space), return new pointer. */
static char *
skip_spaces (char *cp)
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdarg stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timespec-add timespec-sub utimens warnings
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-strcase careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdarg stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timespec-add timespec-sub utimens warnings
MOSTLYCLEANFILES += core *.stackdump
## end gnulib module allocator
+## begin gnulib module c-ctype
+
+libgnu_a_SOURCES += c-ctype.h c-ctype.c
+
+## end gnulib module c-ctype
+
+## begin gnulib module c-strcase
+
+libgnu_a_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c
+
+## end gnulib module c-strcase
+
## begin gnulib module careadlinkat
libgnu_a_SOURCES += careadlinkat.c
+2012-07-06 Paul Eggert <eggert@cs.ucla.edu>
+
+ Use c_strcasecmp for ASCII case-insensitive comparison (Bug#11786).
+ * lwlib.c: Include c-strcase.h.
+ (lwlib_strcasecmp): Remove. All uses replaced with c_strcasecmp.
+
2012-06-26 Paul Eggert <eggert@cs.ucla.edu>
Clean out last vestiges of the old HAVE_CONFIG_H stuff.
#include <setjmp.h>
#include <lisp.h>
+#include <c-strcase.h>
#include <sys/types.h>
#include <stdio.h>
return result;
}
-#ifdef HAVE_STRCASECMP
-#define lwlib_strcasecmp(x,y) strcasecmp ((x), (y))
-#else
-
-/* Like strcmp but ignore differences in case. */
-
-static int
-lwlib_strcasecmp (const char *s1, const char *s2)
-{
- while (1)
- {
- int c1 = *s1++;
- int c2 = *s2++;
- if (isupper (c1))
- c1 = tolower (c1);
- if (isupper (c2))
- c2 = tolower (c2);
- if (c1 != c2)
- return (c1 > c2 ? 1 : -1);
- if (c1 == 0)
- return 0;
- }
-}
-#endif /* HAVE_STRCASECMP */
-
static void
safe_free_str (char *s)
{
{
const widget_creation_entry* cur;
for (cur = table; cur->type; cur++)
- if (!lwlib_strcasecmp (type, cur->type))
+ if (!c_strcasecmp (type, cur->type))
return cur->function;
return NULL;
}
AC_REQUIRE([gl_PROG_AR_RANLIB])
# Code from module alloca-opt:
# Code from module allocator:
+ # Code from module c-ctype:
+ # Code from module c-strcase:
# Code from module careadlinkat:
# Code from module clock-time:
# Code from module crypto/md5:
lib/alloca.in.h
lib/allocator.c
lib/allocator.h
+ lib/c-ctype.c
+ lib/c-ctype.h
+ lib/c-strcase.h
+ lib/c-strcasecmp.c
+ lib/c-strncasecmp.c
lib/careadlinkat.c
lib/careadlinkat.h
lib/dosname.h
2012-07-06 Paul Eggert <eggert@cs.ucla.edu>
+ Use c_strcasecmp for ASCII case-insensitive comparison (Bug#11786).
+ * dispextern.h, nsfns.m, nsterm.m: Include <c-strcase.h>.
+ * dispextern.h (xstrcasecmp): Rewrite using c_strcasecmp.
+ * nsfns.m (x_get_string_resource): Use c_strncasecmp, not strncasecmp.
+ * nsterm.m (ns_default): Use c_strcasecmp, not strcasecmp.
+ * xfaces.c (xstrcasecmp) [!HAVE_STRCASECMP]: Remove.
+
* xfont.c (compare_font_names): Redo to omit the need for casts.
2012-07-06 Andreas Schwab <schwab@linux-m68k.org>
#include "msdos.h"
#endif
+#include <c-strcase.h>
+static inline int
+xstrcasecmp (char const *a, char const *b)
+{
+ return c_strcasecmp (a, b);
+}
+
#ifdef HAVE_X_WINDOWS
typedef struct x_display_info Display_Info;
typedef XImage * XImagePtr;
char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object,
int *);
void prepare_face_for_display (struct frame *, struct face *);
-#ifdef HAVE_STRCASECMP
-#define xstrcasecmp(x,y) strcasecmp ((x), (y))
-#else
-int xstrcasecmp (const char *, const char *);
-#endif
int lookup_named_face (struct frame *, Lisp_Object, int);
int lookup_basic_face (struct frame *, int);
int smaller_face (struct frame *, int, int);
#include <signal.h>
#include <math.h>
#include <setjmp.h>
+#include <c-strcase.h>
#include "lisp.h"
#include "blockinput.h"
res = ns_get_defaults_value (toCheck);
return !res ? NULL :
- (!strncasecmp (res, "YES", 3) ? "true" :
- (!strncasecmp (res, "NO", 2) ? "false" : res));
+ (!c_strncasecmp (res, "YES", 3) ? "true" :
+ (!c_strncasecmp (res, "NO", 2) ? "false" : res));
}
#include <signal.h>
#include <unistd.h>
#include <setjmp.h>
+#include <c-strcase.h>
#include "lisp.h"
#include "blockinput.h"
{
double f;
char *pos;
- if (strcasecmp (value, "YES") == 0)
+ if (c_strcasecmp (value, "YES") == 0)
*result = yesval;
- else if (strcasecmp (value, "NO") == 0)
+ else if (c_strcasecmp (value, "NO") == 0)
*result = noval;
else if (is_float && (f = strtod (value, &pos), pos != value))
*result = make_float (f);
}
#endif /* HAVE_NS */
-#ifndef HAVE_STRCASECMP
-/* Like strcasecmp/stricmp. Used to compare parts of font names which
- are in ISO8859-1. */
-
-int
-xstrcasecmp (const char *s1, const char *s2)
-{
- while (*s1 && *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;
- }
-
- if (*s1 == 0)
- return *s2 == 0 ? 0 : -1;
- return 1;
-}
-#endif /* HAVE_STRCASECMP */
-
/* If FRAME is nil, return a pointer to the selected frame.
Otherwise, check that FRAME is a live frame, and return a pointer
to it. NPARAM is the parameter number of FRAME, for