diff options
author | Joel Brobecker <brobecker@gnat.com> | 2011-07-01 18:24:38 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2011-07-01 18:24:38 +0000 |
commit | 51f1c41a30c5b96994e7c1666b57fba7e20f23ce (patch) | |
tree | bb27fcc5cda72dd5a771d4a1335e6d6204aa3d21 /libiberty | |
parent | 094d08d0d5e620edbc7e5a8d072d9970c5f7da21 (diff) | |
download | binutils-redhat-51f1c41a30c5b96994e7c1666b57fba7e20f23ce.tar.gz |
[libiberty/filename_cmp] Darwin has case-insensitive filesystems
include/ChangeLog:
* filenames.h (HAVE_CASE_INSENSITIVE_FILE_SYSTEM): Define
on Darwin, as well as on the systems that use a DOS-like
filesystem.
libiberty/ChangeLog:
* filename_cmp.c (filename_cmp, filename_ncmp): Add handling of
HAVE_CASE_INSENSITIVE_FILE_SYSTEM.
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 5 | ||||
-rw-r--r-- | libiberty/filename_cmp.c | 28 |
2 files changed, 27 insertions, 6 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 809f22bc38..2f8e73497d 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2011-07-01 Joel Brobecker <brobecker@adacore.com> + + * filename_cmp.c (filename_cmp, filename_ncmp): Add handling of + HAVE_CASE_INSENSITIVE_FILE_SYSTEM. + 2011-07-01 Jan Kratochvil <jan.kratochvil@redhat.com> PR debug/49408 diff --git a/libiberty/filename_cmp.c b/libiberty/filename_cmp.c index 0eed12086b..5179f8dd14 100644 --- a/libiberty/filename_cmp.c +++ b/libiberty/filename_cmp.c @@ -50,19 +50,27 @@ and backward slashes are equal. int filename_cmp (const char *s1, const char *s2) { -#ifndef HAVE_DOS_BASED_FILE_SYSTEM +#if !defined(HAVE_DOS_BASED_FILE_SYSTEM) \ + && !defined(HAVE_CASE_INSENSITIVE_FILE_SYSTEM) return strcmp(s1, s2); #else for (;;) { - int c1 = TOLOWER (*s1); - int c2 = TOLOWER (*s2); + int c1 = *s1; + int c2 = *s2; +#if defined (HAVE_CASE_INSENSITIVE_FILE_SYSTEM) + c1 = TOLOWER (c1); + c2 = TOLOWER (c2); +#endif + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* On DOS-based file systems, the '/' and the '\' are equivalent. */ if (c1 == '/') c1 = '\\'; if (c2 == '/') c2 = '\\'; +#endif if (c1 != c2) return (c1 - c2); @@ -100,21 +108,29 @@ and backward slashes are equal. int filename_ncmp (const char *s1, const char *s2, size_t n) { -#ifndef HAVE_DOS_BASED_FILE_SYSTEM +#if !defined(HAVE_DOS_BASED_FILE_SYSTEM) \ + && !defined(HAVE_CASE_INSENSITIVE_FILE_SYSTEM) return strncmp(s1, s2, n); #else if (!n) return 0; for (; n > 0; --n) { - int c1 = TOLOWER (*s1); - int c2 = TOLOWER (*s2); + int c1 = *s1; + int c2 = *s2; +#if defined (HAVE_CASE_INSENSITIVE_FILE_SYSTEM) + c1 = TOLOWER (c1); + c2 = TOLOWER (c2); +#endif + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* On DOS-based file systems, the '/' and the '\' are equivalent. */ if (c1 == '/') c1 = '\\'; if (c2 == '/') c2 = '\\'; +#endif if (c1 == '\0' || c1 != c2) return (c1 - c2); |