]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix regcomp wcscoll, wcscmp namespace (bug 18497).
authorJoseph Myers <joseph@codesourcery.com>
Tue, 9 Jun 2015 21:07:30 +0000 (21:07 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 9 Jun 2015 21:07:30 +0000 (21:07 +0000)
regcomp brings in references to wcscoll, which isn't in all the
standards that contain regcomp.  In turn, wcscoll brings in references
to wcscmp, also not in all those standards.  This patch fixes this by
making those functions into weak aliases of __wcscoll and __wcscmp and
calling those names instead as needed.

Tested for x86_64 and x86 (testsuite, and that disassembly of
installed shared libraries is unchanged by the patch).

[BZ #18497]
* wcsmbs/wcscmp.c [!WCSCMP] (WCSCMP): Define as __wcscmp instead
of wcscmp.
(wcscmp): Define as weak alias of WCSCMP.
* wcsmbs/wcscoll.c (STRCOLL): Define as __wcscoll instead of
wcscoll.
(USE_HIDDEN_DEF): Define.
[!USE_IN_EXTENDED_LOCALE_MODEL] (wcscoll): Define as weak alias of
__wcscoll.  Don't use libc_hidden_weak.
* wcsmbs/wcscoll_l.c (STRCMP): Define as __wcscmp instead of
wcscmp.
* sysdeps/i386/i686/multiarch/wcscmp-c.c
[SHARED] (libc_hidden_def): Define __GI___wcscmp instead of
__GI_wcscmp.
(weak_alias): Undefine and redefine.
* sysdeps/i386/i686/multiarch/wcscmp.S (wcscmp): Rename to
__wcscmp and define as weak alias of __wcscmp.
* sysdeps/x86_64/wcscmp.S (wcscmp): Likewise.
* include/wchar.h (__wcscmp): Declare.  Use libc_hidden_proto.
(__wcscoll): Likewise.
(wcscmp): Don't use libc_hidden_proto.
(wcscoll): Likewise.
* posix/regcomp.c (build_range_exp): Call __wcscoll instead of
wcscoll.
* posix/regexec.c (check_node_accept_bytes): Likewise.
* conform/Makefile (test-xfail-XPG3/regex.h/linknamespace): Remove
variable.
(test-xfail-XPG4/regex.h/linknamespace): Likewise.
(test-xfail-POSIX/regex.h/linknamespace): Likewise.

12 files changed:
ChangeLog
NEWS
conform/Makefile
include/wchar.h
posix/regcomp.c
posix/regexec.c
sysdeps/i386/i686/multiarch/wcscmp-c.c
sysdeps/i386/i686/multiarch/wcscmp.S
sysdeps/x86_64/wcscmp.S
wcsmbs/wcscmp.c
wcsmbs/wcscoll.c
wcsmbs/wcscoll_l.c

index 39622d67b1fd04862de497825996b895b328429c..2501f45873d6cef7896836cb36fcad49cd69582d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
 2015-06-09  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #18497]
+       * wcsmbs/wcscmp.c [!WCSCMP] (WCSCMP): Define as __wcscmp instead
+       of wcscmp.
+       (wcscmp): Define as weak alias of WCSCMP.
+       * wcsmbs/wcscoll.c (STRCOLL): Define as __wcscoll instead of
+       wcscoll.
+       (USE_HIDDEN_DEF): Define.
+       [!USE_IN_EXTENDED_LOCALE_MODEL] (wcscoll): Define as weak alias of
+       __wcscoll.  Don't use libc_hidden_weak.
+       * wcsmbs/wcscoll_l.c (STRCMP): Define as __wcscmp instead of
+       wcscmp.
+       * sysdeps/i386/i686/multiarch/wcscmp-c.c
+       [SHARED] (libc_hidden_def): Define __GI___wcscmp instead of
+       __GI_wcscmp.
+       (weak_alias): Undefine and redefine.
+       * sysdeps/i386/i686/multiarch/wcscmp.S (wcscmp): Rename to
+       __wcscmp and define as weak alias of __wcscmp.
+       * sysdeps/x86_64/wcscmp.S (wcscmp): Likewise.
+       * include/wchar.h (__wcscmp): Declare.  Use libc_hidden_proto.
+       (__wcscoll): Likewise.
+       (wcscmp): Don't use libc_hidden_proto.
+       (wcscoll): Likewise.
+       * posix/regcomp.c (build_range_exp): Call __wcscoll instead of
+       wcscoll.
+       * posix/regexec.c (check_node_accept_bytes): Likewise.
+       * conform/Makefile (test-xfail-XPG3/regex.h/linknamespace): Remove
+       variable.
+       (test-xfail-XPG4/regex.h/linknamespace): Likewise.
+       (test-xfail-POSIX/regex.h/linknamespace): Likewise.
+
        [BZ #18507]
        * sysdeps/unix/sysv/linux/fstatvfs.c (fstatvfs): Rename to
        __fstatvfs and define as weak alias of __fstatvfs.  Use
diff --git a/NEWS b/NEWS
index 03afc5f497754caf5f04631595ad121b05fa10a7..221ec2f8c214b604e5e1bc5ca0bd1dd028c29c84 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,7 +20,7 @@ Version 2.22
   18111, 18116, 18125, 18128, 18138, 18185, 18196, 18197, 18206, 18210,
   18211, 18217, 18220, 18221, 18234, 18244, 18247, 18287, 18319, 18324,
   18333, 18346, 18397, 18409, 18410, 18412, 18418, 18422, 18434, 18444,
-  18468, 18469, 18470, 18483, 18495, 18496, 18498, 18507.
+  18468, 18469, 18470, 18483, 18495, 18496, 18497, 18498, 18507.
 
 * Cache information can be queried via sysconf() function on s390 e.g. with
   _SC_LEVEL1_ICACHE_SIZE as argument.
index 12ccc64b17c5b042a1aad92b313758e5ca647371..8e76bcb302fd8cf48c42d6eb35171c9794c863c2 100644 (file)
@@ -346,20 +346,17 @@ test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes
 
 # Unsorted expected failures.
 test-xfail-XPG3/glob.h/linknamespace = yes
-test-xfail-XPG3/regex.h/linknamespace = yes
 test-xfail-XPG3/unistd.h/linknamespace = yes
 test-xfail-XPG3/wordexp.h/linknamespace = yes
 test-xfail-XPG4/fmtmsg.h/linknamespace = yes
 test-xfail-XPG4/glob.h/linknamespace = yes
 test-xfail-XPG4/netdb.h/linknamespace = yes
-test-xfail-XPG4/regex.h/linknamespace = yes
 test-xfail-XPG4/stdlib.h/linknamespace = yes
 test-xfail-XPG4/syslog.h/linknamespace = yes
 test-xfail-XPG4/unistd.h/linknamespace = yes
 test-xfail-XPG4/wordexp.h/linknamespace = yes
 test-xfail-POSIX/aio.h/linknamespace = yes
 test-xfail-POSIX/mqueue.h/linknamespace = yes
-test-xfail-POSIX/regex.h/linknamespace = yes
 test-xfail-POSIX/semaphore.h/linknamespace = yes
 test-xfail-UNIX98/fmtmsg.h/linknamespace = yes
 test-xfail-UNIX98/mqueue.h/linknamespace = yes
index eb1cb0da047d03dcd7f78a492bbd4fdc4406258b..449ad1d68508ffe5602f20d09ae18d3737984609 100644 (file)
@@ -81,17 +81,22 @@ libc_hidden_proto (vswscanf)
 
 libc_hidden_proto (mbrtowc)
 libc_hidden_proto (wcrtomb)
-libc_hidden_proto (wcscmp)
+extern int __wcscmp (const wchar_t *__s1, const wchar_t *__s2)
+     __THROW __attribute_pure__;
+libc_hidden_proto (__wcscmp)
 libc_hidden_proto (wcsftime)
 libc_hidden_proto (wcsspn)
 libc_hidden_proto (wcschr)
 /* The C++ overloading of wcschr means we have to repeat the type to
    declare __wcschr instead of using typeof, to avoid errors in C++
-   tests.  The same applies to __wmemchr.  */
+   tests; in addition, __THROW cannot be used with a function type
+   from typeof in C++.  The same applies to __wmemchr and, as regards
+   __THROW, to __wcscmp and __wcscoll.  */
 extern wchar_t *__wcschr (const wchar_t *__wcs, wchar_t __wc)
      __THROW __attribute_pure__;
 libc_hidden_proto (__wcschr)
-libc_hidden_proto (wcscoll)
+extern int __wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
+libc_hidden_proto (__wcscoll)
 libc_hidden_proto (wcspbrk)
 
 extern typeof (wmemset) __wmemset;
index 728c48239f0efceec280916a144160a7035b870e..bf8aa1604cad2e0148b38b288d50d4ce8382e176 100644 (file)
@@ -2683,7 +2683,7 @@ build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem,
       return REG_ECOLLATE;
     cmp_buf[0] = start_wc;
     cmp_buf[4] = end_wc;
-    if (wcscoll (cmp_buf, cmp_buf + 4) > 0)
+    if (__wcscoll (cmp_buf, cmp_buf + 4) > 0)
       return REG_ERANGE;
 
     /* Got valid collation sequence values, add them as a new entry.
@@ -2725,8 +2725,8 @@ build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem,
     for (wc = 0; wc < SBC_MAX; ++wc)
       {
        cmp_buf[2] = wc;
-       if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
-           && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
+       if (__wcscoll (cmp_buf, cmp_buf + 2) <= 0
+           && __wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
          bitset_set (sbcset, wc);
       }
   }
index 7022581e1280f3b1b04f9c025c70856c0f5b80e2..70cd6064dd16a85591365716398ddc96ed64b507 100644 (file)
@@ -3968,8 +3968,8 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
            {
              cmp_buf[0] = cset->range_starts[i];
              cmp_buf[4] = cset->range_ends[i];
-             if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
-                 && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
+             if (__wcscoll (cmp_buf, cmp_buf + 2) <= 0
+                 && __wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
                {
                  match_len = char_len;
                  goto check_node_accept_bytes_match;
index 165c56afb8691470345e84c6da26b6d11bc66f06..e3337d77e256426e2e3d3f64e26b018e2619146c 100644 (file)
@@ -4,8 +4,10 @@
 #ifdef SHARED
 # undef libc_hidden_def
 # define libc_hidden_def(name) \
-  __hidden_ver1 (__wcscmp_ia32, __GI_wcscmp, __wcscmp_ia32);
+  __hidden_ver1 (__wcscmp_ia32, __GI___wcscmp, __wcscmp_ia32);
 #endif
+#undef weak_alias
+#define weak_alias(name, alias)
 
 extern __typeof (wcscmp) __wcscmp_ia32;
 
index 43fe0a34caf3d613bbe34175b6d453b17b3f3bc9..92c2c84ad45ac4513333e4eb8f7b9988c471ea08 100644 (file)
@@ -26,8 +26,8 @@
    happened.  */
 #if IS_IN (libc)
        .text
-ENTRY(wcscmp)
-       .type   wcscmp, @gnu_indirect_function
+ENTRY(__wcscmp)
+       .type   __wcscmp, @gnu_indirect_function
        pushl   %ebx
        cfi_adjust_cfa_offset (4)
        cfi_rel_offset (ebx, 0)
@@ -43,5 +43,6 @@ ENTRY(wcscmp)
        cfi_adjust_cfa_offset (-4);
        cfi_restore (ebx)
        ret
-END(wcscmp)
+END(__wcscmp)
+weak_alias (__wcscmp, wcscmp)
 #endif
index 5d6806ca439772f94a432853573d0fb0d613eda5..bd36d9f5d97d338f58772c029866888c179b90d6 100644 (file)
@@ -22,7 +22,7 @@
 /* Note: wcscmp uses signed comparison, not unsighed as in strcmp function. */
 
        .text
-ENTRY (wcscmp)
+ENTRY (__wcscmp)
 /*
        * This implementation uses SSE to compare up to 16 bytes at a time.
 */
@@ -945,5 +945,6 @@ L(equal):
        xor     %rax, %rax
        ret
 
-END (wcscmp)
-libc_hidden_def (wcscmp)
+END (__wcscmp)
+libc_hidden_def (__wcscmp)
+weak_alias (__wcscmp, wcscmp)
index 88efc5b55d740a0e21ac9f23551303bf3bcb3f34..fcfe0c5bcb4477f4f77efb94ef4d65b1cc4a8c69 100644 (file)
@@ -19,7 +19,7 @@
 #include <wchar.h>
 
 #ifndef WCSCMP
-# define WCSCMP wcscmp
+# define WCSCMP __wcscmp
 #endif
 
 /* Compare S1 and S2, returning less than, equal to or
@@ -44,3 +44,4 @@ WCSCMP (s1, s2)
   return c1 < c2 ? -1 : 1;
 }
 libc_hidden_def (WCSCMP)
+weak_alias (WCSCMP, wcscmp)
index c64dd24519cc35e8213dc4b7fbf40cbb40e7da10..717693079b2ff9f5763bea0f9267a0340c41f17b 100644 (file)
 
 #define STRING_TYPE wchar_t
 #define USTRING_TYPE wint_t
-#define STRCOLL wcscoll
+#define STRCOLL __wcscoll
 #define STRCOLL_L __wcscoll_l
+#define USE_HIDDEN_DEF
 
 #include "../string/strcoll.c"
 
 #ifndef USE_IN_EXTENDED_LOCALE_MODEL
-libc_hidden_weak (wcscoll)
+weak_alias (__wcscoll, wcscoll)
 #endif
index 9f60cee9ea0e9333a3cf6d6f44fcd05dadfc3a31..6d9384ad643fa5b8c1ef2e539f785b1874d67141 100644 (file)
@@ -24,7 +24,7 @@
 #define USTRING_TYPE wint_t
 #define STRCOLL __wcscoll_l
 #define STRDIFF __wcsdiff
-#define STRCMP wcscmp
+#define STRCMP __wcscmp
 #define WEIGHT_H "../locale/weightwc.h"
 #define SUFFIX WC
 #define L(arg) L##arg