aboutsummaryrefslogtreecommitdiff
path: root/gl/regex_internal.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/regex_internal.c')
-rw-r--r--gl/regex_internal.c101
1 files changed, 52 insertions, 49 deletions
diff --git a/gl/regex_internal.c b/gl/regex_internal.c
index 7acec79d..17eafaa9 100644
--- a/gl/regex_internal.c
+++ b/gl/regex_internal.c
@@ -1,6 +1,6 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
- Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+ Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -36,7 +36,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
re_string_reconstruct before using the object. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
{
@@ -64,7 +64,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
/* This function allocate the buffers, and initialize them. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_string_construct (re_string_t *pstr, const char *str, Idx len,
RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
{
@@ -127,7 +127,7 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
/* Helper functions for re_string_allocate, and re_string_construct. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
{
#ifdef RE_ENABLE_I18N
@@ -267,7 +267,7 @@ build_wcs_buffer (re_string_t *pstr)
but for REG_ICASE. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
build_wcs_upper_buffer (re_string_t *pstr)
{
mbstate_t prev_st;
@@ -430,8 +430,8 @@ build_wcs_upper_buffer (re_string_t *pstr)
src_idx += mbclen;
continue;
}
- else
- memcpy (pstr->mbs + byte_idx, p, mbclen);
+ else
+ memcpy (pstr->mbs + byte_idx, p, mbclen);
}
else
memcpy (pstr->mbs + byte_idx, p, mbclen);
@@ -569,7 +569,7 @@ re_string_translate_buffer (re_string_t *pstr)
convert to upper case in case of REG_ICASE, apply translation. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
{
Idx offset;
@@ -964,7 +964,7 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
/* Functions for set operation. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_alloc (re_node_set *set, Idx size)
{
set->alloc = size;
@@ -976,7 +976,7 @@ re_node_set_alloc (re_node_set *set, Idx size)
}
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_init_1 (re_node_set *set, Idx elem)
{
set->alloc = 1;
@@ -992,7 +992,7 @@ re_node_set_init_1 (re_node_set *set, Idx elem)
}
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
{
set->alloc = 2;
@@ -1022,7 +1022,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
}
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
{
dest->nelem = src->nelem;
@@ -1047,7 +1047,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
Note: We assume dest->elems is NULL, when dest->alloc is 0. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
const re_node_set *src2)
{
@@ -1062,7 +1062,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc);
if (BE (new_elems == NULL, 0))
- return REG_ESPACE;
+ return REG_ESPACE;
dest->elems = new_elems;
dest->alloc = new_alloc;
}
@@ -1112,20 +1112,20 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
if (delta > 0 && REG_VALID_INDEX (id))
for (;;)
{
- if (dest->elems[is] > dest->elems[id])
- {
- /* Copy from the top. */
- dest->elems[id + delta--] = dest->elems[is--];
- if (delta == 0)
- break;
- }
- else
- {
- /* Slide from the bottom. */
- dest->elems[id + delta] = dest->elems[id];
- if (! REG_VALID_INDEX (--id))
- break;
- }
+ if (dest->elems[is] > dest->elems[id])
+ {
+ /* Copy from the top. */
+ dest->elems[id + delta--] = dest->elems[is--];
+ if (delta == 0)
+ break;
+ }
+ else
+ {
+ /* Slide from the bottom. */
+ dest->elems[id + delta] = dest->elems[id];
+ if (! REG_VALID_INDEX (--id))
+ break;
+ }
}
/* Copy remaining SRC elements. */
@@ -1138,7 +1138,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
const re_node_set *src2)
{
@@ -1191,7 +1191,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_merge (re_node_set *dest, const re_node_set *src)
{
Idx is, id, sbase, delta;
@@ -1221,11 +1221,11 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
REG_VALID_INDEX (is) && REG_VALID_INDEX (id); )
{
if (dest->elems[id] == src->elems[is])
- is--, id--;
+ is--, id--;
else if (dest->elems[id] < src->elems[is])
- dest->elems[--sbase] = src->elems[is--];
+ dest->elems[--sbase] = src->elems[is--];
else /* if (dest->elems[id] > src->elems[is]) */
- --id;
+ --id;
}
if (REG_VALID_INDEX (is))
@@ -1247,21 +1247,21 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
for (;;)
{
if (dest->elems[is] > dest->elems[id])
- {
+ {
/* Copy from the top. */
- dest->elems[id + delta--] = dest->elems[is--];
+ dest->elems[id + delta--] = dest->elems[is--];
if (delta == 0)
break;
}
else
- {
- /* Slide from the bottom. */
- dest->elems[id + delta] = dest->elems[id];
+ {
+ /* Slide from the bottom. */
+ dest->elems[id + delta] = dest->elems[id];
if (! REG_VALID_INDEX (--id))
{
/* Copy remaining SRC elements. */
memcpy (dest->elems, dest->elems + sbase,
- delta * sizeof (Idx));
+ delta * sizeof (Idx));
break;
}
}
@@ -1275,7 +1275,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
Return true if successful. */
static bool
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_insert (re_node_set *set, Idx elem)
{
Idx idx;
@@ -1308,12 +1308,12 @@ re_node_set_insert (re_node_set *set, Idx elem)
{
idx = 0;
for (idx = set->nelem; idx > 0; idx--)
- set->elems[idx] = set->elems[idx - 1];
+ set->elems[idx] = set->elems[idx - 1];
}
else
{
for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
- set->elems[idx] = set->elems[idx - 1];
+ set->elems[idx] = set->elems[idx - 1];
}
/* Insert the new element. */
@@ -1327,7 +1327,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
Return true if successful. */
static bool
-internal_function
+internal_function __attribute_warn_unused_result__
re_node_set_insert_last (re_node_set *set, Idx elem)
{
/* Realloc if we need. */
@@ -1473,7 +1473,7 @@ calc_state_hash (const re_node_set *nodes, unsigned int context)
optimization. */
static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
const re_node_set *nodes)
{
@@ -1521,7 +1521,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
optimization. */
static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
const re_node_set *nodes, unsigned int context)
{
@@ -1562,6 +1562,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
indicates the error code if failed. */
static reg_errcode_t
+__attribute_warn_unused_result__
register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
re_hashval_t hash)
{
@@ -1616,7 +1617,7 @@ free_state (re_dfastate_t *state)
Return the new state if succeeded, otherwise return NULL. */
static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
re_hashval_t hash)
{
@@ -1666,7 +1667,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
Return the new state if succeeded, otherwise return NULL. */
static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
unsigned int context, re_hashval_t hash)
{
@@ -1715,7 +1716,9 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
free_state (newstate);
return NULL;
}
- re_node_set_init_copy (newstate->entrance_nodes, nodes);
+ if (re_node_set_init_copy (newstate->entrance_nodes, nodes)
+ != REG_NOERROR)
+ return NULL;
nctx_nodes = 0;
newstate->has_constraint = 1;
}