diff options
| author | Paul Eggert | 2012-07-06 14:07:46 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-06 14:07:46 -0700 |
| commit | fee5959dd8b389bc222618a35b042a92a1358c21 (patch) | |
| tree | 936ae7da59bfa6d4c15f03929bbf6090190ea23a /lib-src | |
| parent | fd573f31dcaec9cd5170ba33af10d7c71c56822c (diff) | |
| download | emacs-fee5959dd8b389bc222618a35b042a92a1358c21.tar.gz emacs-fee5959dd8b389bc222618a35b042a92a1358c21.zip | |
Use c_strcasecmp for ASCII case-insensitive comparison.
Fixes: debbugs:11786
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 7 | ||||
| -rw-r--r-- | lib-src/etags.c | 61 |
2 files changed, 10 insertions, 58 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 11f2a688cd2..56f1551e8ba 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-07-06 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Use c_strcasecmp for ASCII case-insensitive comparison (Bug#11786). | ||
| 4 | * etags.c: Include c-strcase.h. | ||
| 5 | (etags_strcasecmp, etags_strncasecmp): Remove. | ||
| 6 | All uses replaced with c_strcasecmp and c_strncasecmp. | ||
| 7 | |||
| 1 | 2012-07-06 Andreas Schwab <schwab@linux-m68k.org> | 8 | 2012-07-06 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 9 | ||
| 3 | * make-docfile.c (write_globals): Warn about duplicate function | 10 | * make-docfile.c (write_globals): Warn about duplicate function |
diff --git a/lib-src/etags.c b/lib-src/etags.c index 2e05e37e80f..5bdf3402e55 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -144,6 +144,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; | |||
| 144 | #include <errno.h> | 144 | #include <errno.h> |
| 145 | #include <sys/types.h> | 145 | #include <sys/types.h> |
| 146 | #include <sys/stat.h> | 146 | #include <sys/stat.h> |
| 147 | #include <c-strcase.h> | ||
| 147 | 148 | ||
| 148 | #include <assert.h> | 149 | #include <assert.h> |
| 149 | #ifdef NDEBUG | 150 | #ifdef NDEBUG |
| @@ -174,9 +175,9 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; | |||
| 174 | #endif | 175 | #endif |
| 175 | 176 | ||
| 176 | #define streq(s,t) (assert ((s)!=NULL || (t)!=NULL), !strcmp (s, t)) | 177 | #define streq(s,t) (assert ((s)!=NULL || (t)!=NULL), !strcmp (s, t)) |
| 177 | #define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t)) | 178 | #define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !c_strcasecmp (s, t)) |
| 178 | #define strneq(s,t,n) (assert ((s)!=NULL || (t)!=NULL), !strncmp (s, t, n)) | 179 | #define strneq(s,t,n) (assert ((s)!=NULL || (t)!=NULL), !strncmp (s, t, n)) |
| 179 | #define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !etags_strncasecmp (s, t, n)) | 180 | #define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !c_strncasecmp (s, t, n)) |
| 180 | 181 | ||
| 181 | #define CHARS 256 /* 2^sizeof(char) */ | 182 | #define CHARS 256 /* 2^sizeof(char) */ |
| 182 | #define CHAR(x) ((unsigned int)(x) & (CHARS - 1)) | 183 | #define CHAR(x) ((unsigned int)(x) & (CHARS - 1)) |
| @@ -375,16 +376,6 @@ static char *savenstr (const char *, int); | |||
| 375 | static char *savestr (const char *); | 376 | static char *savestr (const char *); |
| 376 | static char *etags_strchr (const char *, int); | 377 | static char *etags_strchr (const char *, int); |
| 377 | static char *etags_strrchr (const char *, int); | 378 | static char *etags_strrchr (const char *, int); |
| 378 | #ifdef HAVE_STRCASECMP | ||
| 379 | #define etags_strcasecmp(x,y) strcasecmp ((x), (y)) | ||
| 380 | #else | ||
| 381 | static int etags_strcasecmp (const char *, const char *); | ||
| 382 | #endif | ||
| 383 | #ifdef HAVE_STRNCASECMP | ||
| 384 | #define etags_strncasecmp(x,y,z) strncasecmp ((x), (y), (z)) | ||
| 385 | #else | ||
| 386 | static int etags_strncasecmp (const char *, const char *, int); | ||
| 387 | #endif | ||
| 388 | static char *etags_getcwd (void); | 379 | static char *etags_getcwd (void); |
| 389 | static char *relative_filename (char *, char *); | 380 | static char *relative_filename (char *, char *); |
| 390 | static char *absolute_filename (char *, char *); | 381 | static char *absolute_filename (char *, char *); |
| @@ -6314,52 +6305,6 @@ etags_strchr (register const char *sp, register int c) | |||
| 6314 | return NULL; | 6305 | return NULL; |
| 6315 | } | 6306 | } |
| 6316 | 6307 | ||
| 6317 | #ifndef HAVE_STRCASECMP | ||
| 6318 | /* | ||
| 6319 | * Compare two strings, ignoring case for alphabetic characters. | ||
| 6320 | * | ||
| 6321 | * Same as BSD's strcasecmp, included for portability. | ||
| 6322 | */ | ||
| 6323 | static int | ||
| 6324 | etags_strcasecmp (register const char *s1, register const char *s2) | ||
| 6325 | { | ||
| 6326 | while (*s1 != '\0' | ||
| 6327 | && (ISALPHA (*s1) && ISALPHA (*s2) | ||
| 6328 | ? lowcase (*s1) == lowcase (*s2) | ||
| 6329 | : *s1 == *s2)) | ||
| 6330 | s1++, s2++; | ||
| 6331 | |||
| 6332 | return (ISALPHA (*s1) && ISALPHA (*s2) | ||
| 6333 | ? lowcase (*s1) - lowcase (*s2) | ||
| 6334 | : *s1 - *s2); | ||
| 6335 | } | ||
| 6336 | #endif /* HAVE_STRCASECMP */ | ||
| 6337 | |||
| 6338 | #ifndef HAVE_STRNCASECMP | ||
| 6339 | /* | ||
| 6340 | * Compare two strings, ignoring case for alphabetic characters. | ||
| 6341 | * Stop after a given number of characters | ||
| 6342 | * | ||
| 6343 | * Same as BSD's strncasecmp, included for portability. | ||
| 6344 | */ | ||
| 6345 | static int | ||
| 6346 | etags_strncasecmp (register const char *s1, register const char *s2, register int n) | ||
| 6347 | { | ||
| 6348 | while (*s1 != '\0' && n-- > 0 | ||
| 6349 | && (ISALPHA (*s1) && ISALPHA (*s2) | ||
| 6350 | ? lowcase (*s1) == lowcase (*s2) | ||
| 6351 | : *s1 == *s2)) | ||
| 6352 | s1++, s2++; | ||
| 6353 | |||
| 6354 | if (n < 0) | ||
| 6355 | return 0; | ||
| 6356 | else | ||
| 6357 | return (ISALPHA (*s1) && ISALPHA (*s2) | ||
| 6358 | ? lowcase (*s1) - lowcase (*s2) | ||
| 6359 | : *s1 - *s2); | ||
| 6360 | } | ||
| 6361 | #endif /* HAVE_STRCASECMP */ | ||
| 6362 | |||
| 6363 | /* Skip spaces (end of string is not space), return new pointer. */ | 6308 | /* Skip spaces (end of string is not space), return new pointer. */ |
| 6364 | static char * | 6309 | static char * |
| 6365 | skip_spaces (char *cp) | 6310 | skip_spaces (char *cp) |