Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
2003-11-12  Jakub Jelinek  <jakub@redhat.com>

	* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.

2003-11-12  Jakub Jelinek  <jakub@redhat.com>

	* posix/tst-regex.c (umemlen): New variable.
	(test_expr): Add expectedicase argument.  Test case insensitive
	searches as well as backwards searches (case sensitive and
	insensitive) too.
	(run_test): Add icase argument.  Use it to compute regcomp flags.
	(run_test_backwards): New function.
	(main): Cast read to size_t to avoid warning.  Set umemlen.
	Add expectedicase arguments to test_expr.
	* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
	find previous character by walking back instead of converting
	all chars from beginning.

2003-11-12  Jakub Jelinek  <jakub@redhat.com>

	* posix/regex_internal.h (struct re_string_t): Add is_utf8
	and mb_cur_max fields.
	(struct re_dfa_t): Likewise.  Reorder fields to make structure
	smaller on 64-bit arches.
	(re_string_allocate, re_string_construct): Add mb_cur_max and
	is_utf8 arguments.
	(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
	instead of MB_CUR_MAX.
	* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
	instead of MB_CUR_MAX.
	(re_compile_internal): Pass new arguments to re_string_construct.
	(init_dfa): Initialize mb_cur_max and is_utf8 fields.
	(peek_token, peek_token_bracket): Use input->mb_cur_max instead
	of MB_CUR_MAX.
	(parse_expression, parse_bracket_exp, parse_charclass_op): Use
	dfa->mb_cur_max instead of MB_CUR_MAX.
	* posix/regex_internal.c (re_string_construct_common): Add
	mb_cur_max and is_utf8 arguments.  Initialize fields with them.
	(re_string_allocate, re_string_construct): Add mb_cur_max and
	is_utf8 arguments, pass them to re_string_construct_common.
	Use mb_cur_max instead of MB_CUR_MAX.
	(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
	MB_CUR_MAX.
	(re_string_reconstruct): Likewise.
	(re_string_context_at): Use input->mb_cur_max instead of
	MB_CUR_MAX.
	(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
	instead of MB_CUR_MAX.
	* posix/regexec.c (re_search_internal): Likewise.
	Pass new arguments to re_string_allocate.
	(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
	MB_CUR_MAX.
	(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.

2003-11-12  Jakub Jelinek  <jakub@redhat.com>

	* posix/Makefile (tests): Add bug-regex19.
	(bug-regex19-ENV): Add LOCPATH.
	* posix/bug-regex19.c: New test.
  • Loading branch information
Ulrich Drepper committed Nov 12, 2003
1 parent e432c03 commit 3c0fb57
Show file tree
Hide file tree
Showing 9 changed files with 409 additions and 68 deletions.
60 changes: 60 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
2003-11-12 Jakub Jelinek <jakub@redhat.com>

* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.

2003-11-12 Jakub Jelinek <jakub@redhat.com>

* posix/tst-regex.c (umemlen): New variable.
(test_expr): Add expectedicase argument. Test case insensitive
searches as well as backwards searches (case sensitive and
insensitive) too.
(run_test): Add icase argument. Use it to compute regcomp flags.
(run_test_backwards): New function.
(main): Cast read to size_t to avoid warning. Set umemlen.
Add expectedicase arguments to test_expr.
* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
find previous character by walking back instead of converting
all chars from beginning.

2003-11-12 Jakub Jelinek <jakub@redhat.com>

* posix/regex_internal.h (struct re_string_t): Add is_utf8
and mb_cur_max fields.
(struct re_dfa_t): Likewise. Reorder fields to make structure
smaller on 64-bit arches.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments.
(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
instead of MB_CUR_MAX.
* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
(re_compile_internal): Pass new arguments to re_string_construct.
(init_dfa): Initialize mb_cur_max and is_utf8 fields.
(peek_token, peek_token_bracket): Use input->mb_cur_max instead
of MB_CUR_MAX.
(parse_expression, parse_bracket_exp, parse_charclass_op): Use
dfa->mb_cur_max instead of MB_CUR_MAX.
* posix/regex_internal.c (re_string_construct_common): Add
mb_cur_max and is_utf8 arguments. Initialize fields with them.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments, pass them to re_string_construct_common.
Use mb_cur_max instead of MB_CUR_MAX.
(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
MB_CUR_MAX.
(re_string_reconstruct): Likewise.
(re_string_context_at): Use input->mb_cur_max instead of
MB_CUR_MAX.
(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
* posix/regexec.c (re_search_internal): Likewise.
Pass new arguments to re_string_allocate.
(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
MB_CUR_MAX.
(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.

2003-11-12 Jakub Jelinek <jakub@redhat.com>

* posix/Makefile (tests): Add bug-regex19.
(bug-regex19-ENV): Add LOCPATH.
* posix/bug-regex19.c: New test.

2003-11-11 Jakub Jelinek <jakub@redhat.com>

* posix/regcomp.c (re_compile_fastmap_iter): Handle RE_ICASE
Expand Down
4 changes: 4 additions & 0 deletions io/ftw.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ NFTW_NAME (path, func, descriptors, flags)

#include <shlib-compat.h>

int NFTW_NEW_NAME (const char *, NFTW_FUNC_T, int, int);

int
NFTW_NEW_NAME (path, func, descriptors, flags)
const char *path;
Expand All @@ -779,6 +781,8 @@ versioned_symbol (libc, NFTW_NEW_NAME, NFTW_NAME, GLIBC_2_3_3);

/* Older nftw* version just ignored all unknown flags. */

int NFTW_OLD_NAME (const char *, NFTW_FUNC_T, int, int);

int
NFTW_OLD_NAME (path, func, descriptors, flags)
const char *path;
Expand Down
4 changes: 3 additions & 1 deletion posix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ tests := tstgetopt testfnm runtests runptests \
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-regex16 \
bug-regex17 bug-regex18 tst-nice tst-nanosleep transbug
bug-regex17 bug-regex18 bug-regex19 \
tst-nice tst-nanosleep transbug
ifeq (yes,$(build-shared))
test-srcs := globtest
tests += wordexp-test tst-exec tst-spawn
Expand Down Expand Up @@ -155,6 +156,7 @@ bug-regex5-ENV = LOCPATH=$(common-objpfx)localedata
bug-regex6-ENV = LOCPATH=$(common-objpfx)localedata
bug-regex17-ENV = LOCPATH=$(common-objpfx)localedata
bug-regex18-ENV = LOCPATH=$(common-objpfx)localedata
bug-regex19-ENV = LOCPATH=$(common-objpfx)localedata

testcases.h: TESTS TESTS2C.sed
sed -f TESTS2C.sed < $< > $@T
Expand Down
112 changes: 112 additions & 0 deletions posix/bug-regex19.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/* Regular expression tests.
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

#include <sys/types.h>
#include <mcheck.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>

static struct
{
int syntax;
const char *pattern;
const char *string;
int start, res;
} tests[] = {
/* \xc3\x84 LATIN CAPITAL LETTER A WITH DIAERESIS
\xc3\x96 LATIN CAPITAL LETTER O WITH DIAERESIS
\xe2\x80\x94 EM DASH */
/* Should not match. */
{RE_SYNTAX_POSIX_BASIC, "\\<A", "aOAA", 2, -1},
{RE_SYNTAX_POSIX_BASIC, "A\\>", "aAAO", 1, -1},
{RE_SYNTAX_POSIX_BASIC, "\\bA", "aOAA", 2, -1},
{RE_SYNTAX_POSIX_BASIC, "A\\b", "aAAO", 1, -1},
{RE_SYNTAX_POSIX_BASIC, "\\<\xc3\x84", "a\xc3\x96\xc3\x84\xc3\x84", 3, -1},
{RE_SYNTAX_POSIX_BASIC, "\xc3\x84\\>", "a\xc3\x84\xc3\x84\xc3\x96", 1, -1},
#if 0
/* XXX Not used since they fail so far. */
{RE_SYNTAX_POSIX_BASIC, "\\b\xc3\x84", "a\xc3\x96\xc3\x84\xc3\x84", 3, -1},
{RE_SYNTAX_POSIX_BASIC, "\xc3\x84\\b", "a\xc3\x84\xc3\x84\xc3\x96", 1, -1},
#endif
/* Should match. */
{RE_SYNTAX_POSIX_BASIC, "\\<A", "AA", 0, 0},
{RE_SYNTAX_POSIX_BASIC, "\\<A", "a-AA", 2, 2},
{RE_SYNTAX_POSIX_BASIC, "A\\>", "aAA-", 1, 2},
{RE_SYNTAX_POSIX_BASIC, "A\\>", "aAA", 1, 2},
{RE_SYNTAX_POSIX_BASIC, "\\bA", "AA", 0, 0},
{RE_SYNTAX_POSIX_BASIC, "\\bA", "a-AA", 2, 2},
{RE_SYNTAX_POSIX_BASIC, "A\\b", "aAA-", 1, 2},
{RE_SYNTAX_POSIX_BASIC, "A\\b", "aAA", 1, 2},
#if 0
/* XXX Not used since they fail so far. */
{RE_SYNTAX_POSIX_BASIC, "\\<\xc3\x84", "\xc3\x84\xc3\x84", 0, 0},
{RE_SYNTAX_POSIX_BASIC, "\\<\xc3\x84", "a\xe2\x80\x94\xc3\x84\xc3\x84", 4, 4},
{RE_SYNTAX_POSIX_BASIC, "\xc3\x84\\>", "a\xc3\x84\xc3\x84\xe2\x80\x94", 1, 3},
{RE_SYNTAX_POSIX_BASIC, "\xc3\x84\\>", "a\xc3\x84\xc3\x84", 1, 3},
{RE_SYNTAX_POSIX_BASIC, "\\b\xc3\x84", "\xc3\x84\xc3\x84", 0, 0},
{RE_SYNTAX_POSIX_BASIC, "\\b\xc3\x84", "a\xe2\x80\x94\xc3\x84\xc3\x84", 4, 4},
{RE_SYNTAX_POSIX_BASIC, "\xc3\x84\\b", "a\xc3\x84\xc3\x84\xe2\x80\x94", 1, 3},
{RE_SYNTAX_POSIX_BASIC, "\xc3\x84\\b", "a\xc3\x84\xc3\x84", 1, 3}
#endif
};

int
main (void)
{
struct re_pattern_buffer regbuf;
const char *err;
size_t i;
int ret = 0;

mtrace ();

setlocale (LC_ALL, "de_DE.UTF-8");
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
{
int res;
re_set_syntax (tests[i].syntax);
memset (&regbuf, '\0', sizeof (regbuf));
err = re_compile_pattern (tests[i].pattern, strlen (tests[i].pattern),
&regbuf);
if (err != NULL)
{
printf ("re_compile_pattern failed: %s\n", err);
ret = 1;
continue;
}

res = re_search (&regbuf, tests[i].string, strlen (tests[i].string),
tests[i].start,
strlen (tests[i].string) - tests[i].start, NULL);
if (res != tests[i].res)
{
printf ("re_search %zd failed: %d\n", i, res);
ret = 1;
regfree (&regbuf);
continue;
}
regfree (&regbuf);
}

return ret;
}
34 changes: 21 additions & 13 deletions posix/regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
{
re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
int node_cnt;
int icase = (MB_CUR_MAX == 1 && (bufp->syntax & RE_ICASE));
int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
{
int node = init_state->nodes.elems[node_cnt];
Expand All @@ -324,7 +324,7 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
#ifdef RE_ENABLE_I18N
if ((bufp->syntax & RE_ICASE) && !icase)
{
unsigned char *buf = alloca (MB_CUR_MAX), *p;
unsigned char *buf = alloca (dfa->mb_cur_max), *p;
wchar_t wc;
mbstate_t state;

Expand Down Expand Up @@ -376,7 +376,7 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
re_set_fastmap (fastmap, icase, ch);
}
# else
if (MB_CUR_MAX > 1)
if (dfa->mb_cur_max > 1)
for (i = 0; i < SBC_MAX; ++i)
if (__btowc (i) == WEOF)
re_set_fastmap (fastmap, icase, i);
Expand Down Expand Up @@ -744,7 +744,8 @@ re_compile_internal (preg, pattern, length, syntax)
#endif

err = re_string_construct (&regexp, pattern, length, preg->translate,
syntax & RE_ICASE);
syntax & RE_ICASE, dfa->mb_cur_max,
dfa->is_utf8);
if (BE (err != REG_NOERROR, 0))
{
re_free (dfa);
Expand Down Expand Up @@ -812,6 +813,13 @@ init_dfa (dfa, pat_len)
dfa->subexps = re_malloc (re_subexp_t, dfa->subexps_alloc);
dfa->word_char = NULL;

dfa->mb_cur_max = MB_CUR_MAX;
#ifdef _LIBC
if (dfa->mb_cur_max > 1
&& strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)
dfa->is_utf8 = 1;
#endif

if (BE (dfa->nodes == NULL || dfa->state_table == NULL
|| dfa->subexps == NULL, 0))
{
Expand Down Expand Up @@ -1522,7 +1530,7 @@ peek_token (token, input, syntax)

#ifdef RE_ENABLE_I18N
token->mb_partial = 0;
if (MB_CUR_MAX > 1 &&
if (input->mb_cur_max > 1 &&
!re_string_first_byte (input, re_string_cur_idx (input)))
{
token->type = CHARACTER;
Expand Down Expand Up @@ -1738,7 +1746,7 @@ peek_token_bracket (token, input, syntax)
token->opr.c = c;

#ifdef RE_ENABLE_I18N
if (MB_CUR_MAX > 1 &&
if (input->mb_cur_max > 1 &&
!re_string_first_byte (input, re_string_cur_idx (input)))
{
token->type = CHARACTER;
Expand Down Expand Up @@ -1976,7 +1984,7 @@ parse_expression (regexp, preg, token, syntax, nest, err)
return NULL;
}
#ifdef RE_ENABLE_I18N
if (MB_CUR_MAX > 1)
if (dfa->mb_cur_max > 1)
{
while (!re_string_eoi (regexp)
&& !re_string_first_byte (regexp, re_string_cur_idx (regexp)))
Expand Down Expand Up @@ -2111,7 +2119,7 @@ parse_expression (regexp, preg, token, syntax, nest, err)
*err = REG_ESPACE;
return NULL;
}
if (MB_CUR_MAX > 1)
if (dfa->mb_cur_max > 1)
dfa->has_mb_node = 1;
break;
case OP_WORD:
Expand Down Expand Up @@ -2883,7 +2891,7 @@ parse_bracket_exp (regexp, dfa, token, syntax, err)
goto parse_bracket_exp_free_return;
}
#ifdef RE_ENABLE_I18N
if (MB_CUR_MAX > 1)
if (dfa->mb_cur_max > 1)
for (i = 0; i < SBC_MAX; ++i)
if (__btowc (i) == WEOF)
bitset_set (sbcset, i);
Expand Down Expand Up @@ -3042,8 +3050,8 @@ parse_bracket_exp (regexp, dfa, token, syntax, err)

#ifdef RE_ENABLE_I18N
if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes
|| mbcset->nranges || (MB_CUR_MAX > 1 && (mbcset->nchar_classes
|| mbcset->non_match)))
|| mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes
|| mbcset->non_match)))
{
re_token_t alt_token;
bin_tree_t *mbc_tree;
Expand Down Expand Up @@ -3377,7 +3385,7 @@ build_charclass_op (dfa, trans, class_name, extra, not, err)
bitset_set(cset->sbcset, '\0');
*/
mbcset->non_match = 1;
if (MB_CUR_MAX > 1)
if (dfa->mb_cur_max > 1)
for (i = 0; i < SBC_MAX; ++i)
if (__btowc (i) == WEOF)
bitset_set (sbcset, i);
Expand Down Expand Up @@ -3423,7 +3431,7 @@ build_charclass_op (dfa, trans, class_name, extra, not, err)
goto build_word_op_espace;

#ifdef RE_ENABLE_I18N
if (MB_CUR_MAX > 1)
if (dfa->mb_cur_max > 1)
{
re_token_t alt_token;
bin_tree_t *mbc_tree;
Expand Down
Loading

0 comments on commit 3c0fb57

Please sign in to comment.