This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi!
regcomp was ignoring exact return value from build_charclass and always
used REG_ESPACE if it failed. The following patch fixes it and add
testcase which tests what this patch fixed and what the previous patch
fixed too.
2003-01-16 Jakub Jelinek <jakub@redhat.com>
* posix/regcomp.c (parse_bracket_exp): If build_charclass fails,
set *err to the returned error, not to REG_ESPACE unconditionally.
(build_word_op): Likewise.
* posix/Makefile (tests): Add bug-regex16.
* posix/bug-regex16.c: New test.
--- libc/posix/Makefile.jj 2002-12-14 01:08:16.000000000 +0100
+++ libc/posix/Makefile 2003-01-16 20:00:56.000000000 +0100
@@ -75,7 +75,7 @@ tests := tstgetopt testfnm runtests run
tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \
bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \
- bug-regex13 bug-regex14 bug-regex15
+ bug-regex13 bug-regex14 bug-regex15 bug-regex16
ifeq (yes,$(build-shared))
test-srcs := globtest
tests += wordexp-test tst-exec tst-spawn
--- libc/posix/regcomp.c.jj 2003-01-16 18:09:36.000000000 +0100
+++ libc/posix/regcomp.c 2003-01-16 19:47:58.000000000 +0100
@@ -2993,13 +2993,13 @@ parse_bracket_exp (regexp, dfa, token, s
goto parse_bracket_exp_free_return;
break;
case CHAR_CLASS:
- ret = build_charclass (sbcset,
+ *err = build_charclass (sbcset,
#ifdef RE_ENABLE_I18N
- mbcset, &char_class_alloc,
+ mbcset, &char_class_alloc,
#endif /* RE_ENABLE_I18N */
- start_elem.opr.name, syntax);
- if (BE (ret != REG_NOERROR, 0))
- goto parse_bracket_exp_espace;
+ start_elem.opr.name, syntax);
+ if (BE (*err != REG_NOERROR, 0))
+ goto parse_bracket_exp_free_return;
break;
default:
assert (0);
@@ -3380,7 +3380,7 @@ build_word_op (dfa, not, err)
#ifdef RE_ENABLE_I18N
free_charset (mbcset);
#endif /* RE_ENABLE_I18N */
- *err = REG_ESPACE;
+ *err = ret;
return NULL;
}
/* \w match '_' also. */
--- libc/posix/bug-regex16.c.jj 2003-01-16 19:55:02.000000000 +0100
+++ libc/posix/bug-regex16.c 2003-01-16 20:03:24.000000000 +0100
@@ -0,0 +1,35 @@
+/* Test re_compile_pattern error messages. */
+
+#include <stdio.h>
+#include <string.h>
+#include <regex.h>
+
+int
+main (void)
+{
+ struct re_pattern_buffer re;
+ const char *s;
+ int ret = 0;
+
+ re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+ memset (&re, 0, sizeof (re));
+ s = re_compile_pattern ("[[.invalid_collating_symbol.]]", 30, &re);
+ if (s == NULL || strcmp (s, "Invalid collation character"))
+ {
+ printf ("re_compile_pattern returned %s\n", s);
+ ret = 1;
+ }
+ s = re_compile_pattern ("[[=invalid_equivalence_class=]]", 31, &re);
+ if (s == NULL || strcmp (s, "Invalid collation character"))
+ {
+ printf ("re_compile_pattern returned %s\n", s);
+ ret = 1;
+ }
+ s = re_compile_pattern ("[[:invalid_character_class:]]", 29, &re);
+ if (s == NULL || strcmp (s, "Invalid character class name"))
+ {
+ printf ("re_compile_pattern returned %s\n", s);
+ ret = 1;
+ }
+ return ret;
+}
Jakub
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |