aboutsummaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-10 05:59:19 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-10 05:59:19 +0000
commit2f76d88d7dba542d15fce687b7d05ef026ab267b (patch)
tree53a637396c32a9ffd910a43a479775d3e332152b /posix
parent2b15132f986df6e8dcc2355f6e3e618550d1922b (diff)
downloadglibc-2f76d88d7dba542d15fce687b7d05ef026ab267b.zip
glibc-2f76d88d7dba542d15fce687b7d05ef026ab267b.tar.gz
glibc-2f76d88d7dba542d15fce687b7d05ef026ab267b.tar.bz2
Update.
* posix/fnmatch_loop.c: Fix computation of alignment. 2001-08-09 Isamu Hasegawa <isamu@yamato.ibm.com> * posix/regex.c (wcs_regex_compile): Use appropriate string to compare with collating element. Fix the padding for the alignment. 2001-08-09 Isamu Hasegawa <isamu@yamato.ibm.com> * locale/programs/ld-collate.c (collate_output): Exclude characters from elem_table. Reduce if clause to write collating elements correctly. * posix/Makefile (tests): Add bug-regex5. * posix/bug-regex5.c: New file. 2001-08-09 Ulrich Drepper <drepper@redhat.com>
Diffstat (limited to 'posix')
-rw-r--r--posix/Makefile3
-rw-r--r--posix/bug-regex5.c61
-rw-r--r--posix/fnmatch_loop.c2
-rw-r--r--posix/regex.c4
4 files changed, 66 insertions, 4 deletions
diff --git a/posix/Makefile b/posix/Makefile
index ff20bec..3575749 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -70,7 +70,7 @@ tests := tstgetopt testfnm runtests runptests \
tst-getlogin tst-mmap tst-getaddrinfo tst-truncate \
tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
- tst-gnuglob tst-regex
+ tst-gnuglob tst-regex bug-regex5
ifeq (yes,$(build-shared))
test-srcs := globtest
tests += wordexp-test tst-exec tst-spawn
@@ -123,6 +123,7 @@ tst-fnmatch-ENV = LOCPATH=$(common-objpfx)localedata
tst-regexloc-ENV = LOCPATH=$(common-objpfx)localedata
bug-regex1-ENV = LOCPATH=$(common-objpfx)localedata
tst-regex-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex5-ENV = LOCPATH=$(common-objpfx)localedata
testcases.h: TESTS TESTS2C.sed
sed -f TESTS2C.sed < $< > $@T
diff --git a/posix/bug-regex5.c b/posix/bug-regex5.c
new file mode 100644
index 0000000..12bbcff
--- /dev/null
+++ b/posix/bug-regex5.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <locale.h>
+#include <locale/localeinfo.h>
+
+int
+main (void)
+{
+ int32_t table_size, idx, i, found;
+ const int32_t *symb_table;
+ const unsigned char *extra;
+ uint32_t nrules;
+ char *ca;
+
+ ca = setlocale (LC_ALL, "da_DK.ISO-8859-1");
+ if (ca == NULL)
+ {
+ printf ("cannot set locale: %m\n");
+ return 1;
+ }
+ printf ("current locale : %s\n", ca);
+
+ nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules == 0)
+ {
+ printf("No rule\n");
+ return 1;
+ }
+
+ table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
+ symb_table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+
+ found = 0;
+ for (i = 0; i < table_size; ++i)
+ {
+ if (symb_table[2 * i] != 0)
+ {
+ char elem[256];
+ idx = symb_table[2 * i + 1];
+ strncpy (elem, extra + idx + 1, extra[idx]);
+ elem[extra[idx]] = '\0';
+ printf ("Found a collating element: %s\n", elem);
+ ++found;
+ }
+ }
+ if (found == 0)
+ {
+ printf ("No collating element!\n");
+ return 1;
+ }
+ else if (found != 4)
+ {
+ printf ("expected 4 collating elements, found %d\n", found);
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
index 4f2e4a3..4c6168a 100644
--- a/posix/fnmatch_loop.c
+++ b/posix/fnmatch_loop.c
@@ -531,7 +531,7 @@ FCT (pattern, string, string_end, no_leading_period, flags)
idx += 1 + extra[idx];
/* Adjust for the alignment. */
- idx = (idx + 3) & ~4;
+ idx = (idx + 3) & ~3;
wextra = (int32_t *) &extra[idx + 4];
# endif
diff --git a/posix/regex.c b/posix/regex.c
index e4ac58b..ee38fdf 100644
--- a/posix/regex.c
+++ b/posix/regex.c
@@ -3055,7 +3055,7 @@ PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
/* First compare the hashing value. */
if (symb_table[2 * elem] == hash
&& c1 == extra[symb_table[2 * elem + 1]]
- && memcmp (str,
+ && memcmp (char_str,
&extra[symb_table[2 * elem + 1]
+ 1], c1) == 0)
{
@@ -3075,7 +3075,7 @@ PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
in the table. */
idx += 1 + extra[idx];
/* Adjust for the alignment. */
- idx = (idx + 3) & ~4;
+ idx = (idx + 3) & ~3;
str[0] = (wchar_t) idx + 4;
}