mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-10 19:30:10 +00:00
Update.
2004-01-01 Paolo Bonzini <bonzini@gnu.org> * posix/regex_internal.h (re_dfastate_t): Fix size of the CONTEXT bitfield. * posix/regex_internal.c (re_node_set_insert): Rewrite.
This commit is contained in:
parent
a4024b3e6e
commit
8503c987b6
@ -1,3 +1,10 @@
|
|||||||
|
2004-01-01 Paolo Bonzini <bonzini@gnu.org>
|
||||||
|
|
||||||
|
* posix/regex_internal.h (re_dfastate_t): Fix size of the CONTEXT
|
||||||
|
bitfield.
|
||||||
|
|
||||||
|
* posix/regex_internal.c (re_node_set_insert): Rewrite.
|
||||||
|
|
||||||
2004-01-01 Ulrich Drepper <drepper@redhat.com>
|
2004-01-01 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* posix/getconf.c: Update copyright year.
|
* posix/getconf.c: Update copyright year.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Extended regular expression matching and search library.
|
/* Extended regular expression matching and search library.
|
||||||
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
|
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
|
||||||
|
|
||||||
@ -1148,7 +1148,7 @@ re_node_set_merge (dest, src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the new element ELEM to the re_node_set* SET.
|
/* Insert the new element ELEM to the re_node_set* SET.
|
||||||
return 0 if SET already has ELEM,
|
SET should not already have ELEM.
|
||||||
return -1 if an error is occured, return 1 otherwise. */
|
return -1 if an error is occured, return 1 otherwise. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1157,8 +1157,8 @@ re_node_set_insert (set, elem)
|
|||||||
int elem;
|
int elem;
|
||||||
{
|
{
|
||||||
int idx, right, mid;
|
int idx, right, mid;
|
||||||
/* In case of the set is empty. */
|
/* In case the set is empty. */
|
||||||
if (set->elems == NULL || set->alloc == 0)
|
if (set->alloc == 0)
|
||||||
{
|
{
|
||||||
if (BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1))
|
if (BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1))
|
||||||
return 1;
|
return 1;
|
||||||
@ -1166,43 +1166,39 @@ re_node_set_insert (set, elem)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Binary search the spot we will add the new element. */
|
if (BE (set->nelem, 0) == 0)
|
||||||
idx = 0;
|
|
||||||
right = set->nelem;
|
|
||||||
while (idx < right)
|
|
||||||
{
|
{
|
||||||
mid = (idx + right) / 2;
|
/* We already guaranteed above that set->alloc != 0. */
|
||||||
if (set->elems[mid] < elem)
|
set->elems[0] = elem;
|
||||||
idx = mid + 1;
|
++set->nelem;
|
||||||
else
|
return 1;
|
||||||
right = mid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Realloc if we need. */
|
/* Realloc if we need. */
|
||||||
if (set->alloc < set->nelem + 1)
|
if (set->alloc == set->nelem)
|
||||||
{
|
{
|
||||||
int *new_array;
|
int *new_array;
|
||||||
set->alloc = set->alloc * 2;
|
set->alloc = set->alloc * 2;
|
||||||
new_array = re_malloc (int, set->alloc);
|
new_array = re_realloc (set->elems, int, set->alloc);
|
||||||
if (BE (new_array == NULL, 0))
|
if (BE (new_array == NULL, 0))
|
||||||
return -1;
|
return -1;
|
||||||
/* Copy the elements they are followed by the new element. */
|
|
||||||
if (idx > 0)
|
|
||||||
memcpy (new_array, set->elems, sizeof (int) * (idx));
|
|
||||||
/* Copy the elements which follows the new element. */
|
|
||||||
if (set->nelem - idx > 0)
|
|
||||||
memcpy (new_array + idx + 1, set->elems + idx,
|
|
||||||
sizeof (int) * (set->nelem - idx));
|
|
||||||
re_free (set->elems);
|
|
||||||
set->elems = new_array;
|
set->elems = new_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Move the elements which follows the new element. Test the
|
||||||
|
first element separately to skip a check in the inner loop. */
|
||||||
|
if (elem < set->elems[0])
|
||||||
|
{
|
||||||
|
idx = 0;
|
||||||
|
memmove (set->elems + 1, set->elems,
|
||||||
|
sizeof (int) * set->nelem);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Move the elements which follows the new element. */
|
for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
|
||||||
if (set->nelem - idx > 0)
|
set->elems[idx] = set->elems[idx - 1];
|
||||||
memmove (set->elems + idx + 1, set->elems + idx,
|
|
||||||
sizeof (int) * (set->nelem - idx));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the new element. */
|
/* Insert the new element. */
|
||||||
set->elems[idx] = elem;
|
set->elems[idx] = elem;
|
||||||
++set->nelem;
|
++set->nelem;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Extended regular expression matching and search library.
|
/* Extended regular expression matching and search library.
|
||||||
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
|
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
|
||||||
|
|
||||||
@ -471,10 +471,7 @@ struct re_dfastate_t
|
|||||||
re_node_set nodes;
|
re_node_set nodes;
|
||||||
re_node_set *entrance_nodes;
|
re_node_set *entrance_nodes;
|
||||||
struct re_dfastate_t **trtable;
|
struct re_dfastate_t **trtable;
|
||||||
/* If this state is a special state.
|
unsigned int context : 10;
|
||||||
A state is a special state if the state is the halt state, or
|
|
||||||
a anchor. */
|
|
||||||
unsigned int context : 2;
|
|
||||||
unsigned int halt : 1;
|
unsigned int halt : 1;
|
||||||
/* If this state can accept `multi byte'.
|
/* If this state can accept `multi byte'.
|
||||||
Note that we refer to multibyte characters, and multi character
|
Note that we refer to multibyte characters, and multi character
|
||||||
|
Loading…
Reference in New Issue
Block a user