2005-08-26  Paul Eggert  <eggert@cs.ucla.edu>
	[BZ #1248]
	* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
	bitset_mask, re_string_allocate, re_string_construct,
	re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
	re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
	re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
	re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
	re_node_set_init_union, re_node_set_merge, re_node_set_insert,
	re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
	re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
	re_acquire_state_context): Remove unnecessary forward decls.
	(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
	Put __attribute at function definition, now that the function decl
	has been removed.
	* posix/regex_internal.c (re_string_peek_byte_case,
	re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
	Likewise.
This commit is contained in:
Ulrich Drepper 2005-10-13 21:10:24 +00:00
parent 0fd8ae9c17
commit db26cb7576
3 changed files with 64 additions and 86 deletions

View File

@ -1,3 +1,23 @@
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-08-23 Paul Eggert <eggert@cs.ucla.edu> 2005-08-23 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1231] [BZ #1231]

View File

@ -36,6 +36,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
re_string_reconstruct before using the object. */ re_string_reconstruct before using the object. */
static reg_errcode_t static reg_errcode_t
internal_function
re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len, re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len,
RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa) RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
{ {
@ -63,6 +64,7 @@ re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len,
/* This function allocate the buffers, and initialize them. */ /* This function allocate the buffers, and initialize them. */
static reg_errcode_t static reg_errcode_t
internal_function
re_string_construct (re_string_t *pstr, const char *str, int len, re_string_construct (re_string_t *pstr, const char *str, int len,
RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa) RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
{ {
@ -547,6 +549,7 @@ re_string_translate_buffer (re_string_t *pstr)
convert to upper case in case of REG_ICASE, apply translation. */ convert to upper case in case of REG_ICASE, apply translation. */
static reg_errcode_t static reg_errcode_t
internal_function
re_string_reconstruct (re_string_t *pstr, int idx, int eflags) re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
{ {
int offset = idx - pstr->raw_mbs_idx; int offset = idx - pstr->raw_mbs_idx;
@ -736,6 +739,7 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
} }
static unsigned char static unsigned char
internal_function __attribute ((pure))
re_string_peek_byte_case (const re_string_t *pstr, int idx) re_string_peek_byte_case (const re_string_t *pstr, int idx)
{ {
int ch, off; int ch, off;
@ -771,6 +775,7 @@ re_string_peek_byte_case (const re_string_t *pstr, int idx)
} }
static unsigned char static unsigned char
internal_function __attribute ((pure))
re_string_fetch_byte_case (re_string_t *pstr) re_string_fetch_byte_case (re_string_t *pstr)
{ {
if (BE (!pstr->mbs_allocated, 1)) if (BE (!pstr->mbs_allocated, 1))
@ -807,6 +812,7 @@ re_string_fetch_byte_case (re_string_t *pstr)
} }
static void static void
internal_function
re_string_destruct (re_string_t *pstr) re_string_destruct (re_string_t *pstr)
{ {
#ifdef RE_ENABLE_I18N #ifdef RE_ENABLE_I18N
@ -864,6 +870,7 @@ re_string_context_at (const re_string_t *input, int idx, int eflags)
/* Functions for set operation. */ /* Functions for set operation. */
static reg_errcode_t static reg_errcode_t
internal_function
re_node_set_alloc (re_node_set *set, int size) re_node_set_alloc (re_node_set *set, int size)
{ {
set->alloc = size; set->alloc = size;
@ -875,6 +882,7 @@ re_node_set_alloc (re_node_set *set, int size)
} }
static reg_errcode_t static reg_errcode_t
internal_function
re_node_set_init_1 (re_node_set *set, int elem) re_node_set_init_1 (re_node_set *set, int elem)
{ {
set->alloc = 1; set->alloc = 1;
@ -890,6 +898,7 @@ re_node_set_init_1 (re_node_set *set, int elem)
} }
static reg_errcode_t static reg_errcode_t
internal_function
re_node_set_init_2 (re_node_set *set, int elem1, int elem2) re_node_set_init_2 (re_node_set *set, int elem1, int elem2)
{ {
set->alloc = 2; set->alloc = 2;
@ -919,6 +928,7 @@ re_node_set_init_2 (re_node_set *set, int elem1, int elem2)
} }
static reg_errcode_t static reg_errcode_t
internal_function
re_node_set_init_copy (re_node_set *dest, const re_node_set *src) re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
{ {
dest->nelem = src->nelem; dest->nelem = src->nelem;
@ -943,6 +953,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. */ Note: We assume dest->elems is NULL, when dest->alloc is 0. */
static reg_errcode_t static reg_errcode_t
internal_function
re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
const re_node_set *src2) const re_node_set *src2)
{ {
@ -1033,6 +1044,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. */ DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
static reg_errcode_t static reg_errcode_t
internal_function
re_node_set_init_union (re_node_set *dest, const re_node_set *src1, re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
const re_node_set *src2) const re_node_set *src2)
{ {
@ -1085,6 +1097,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. */ DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
static reg_errcode_t static reg_errcode_t
internal_function
re_node_set_merge (re_node_set *dest, const re_node_set *src) re_node_set_merge (re_node_set *dest, const re_node_set *src)
{ {
int is, id, sbase, delta; int is, id, sbase, delta;
@ -1167,6 +1180,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
return -1 if an error is occured, return 1 otherwise. */ return -1 if an error is occured, return 1 otherwise. */
static int static int
internal_function
re_node_set_insert (re_node_set *set, int elem) re_node_set_insert (re_node_set *set, int elem)
{ {
int idx; int idx;
@ -1223,6 +1237,7 @@ re_node_set_insert (re_node_set *set, int 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
internal_function
re_node_set_insert_last (re_node_set *set, int elem) re_node_set_insert_last (re_node_set *set, int elem)
{ {
/* Realloc if we need. */ /* Realloc if we need. */
@ -1245,6 +1260,7 @@ re_node_set_insert_last (re_node_set *set, int elem)
return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */ return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */
static int static int
internal_function __attribute ((pure))
re_node_set_compare (const re_node_set *set1, const re_node_set *set2) re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
{ {
int i; int i;
@ -1259,6 +1275,7 @@ re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ /* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
static int static int
internal_function __attribute ((pure))
re_node_set_contains (const re_node_set *set, int elem) re_node_set_contains (const re_node_set *set, int elem)
{ {
unsigned int idx, right, mid; unsigned int idx, right, mid;
@ -1280,6 +1297,7 @@ re_node_set_contains (const re_node_set *set, int elem)
} }
static void static void
internal_function
re_node_set_remove_at (re_node_set *set, int idx) re_node_set_remove_at (re_node_set *set, int idx)
{ {
if (idx < 0 || idx >= set->nelem) if (idx < 0 || idx >= set->nelem)
@ -1294,6 +1312,7 @@ re_node_set_remove_at (re_node_set *set, int idx)
Or return -1, if an error will be occured. */ Or return -1, if an error will be occured. */
static int static int
internal_function
re_dfa_add_node (re_dfa_t *dfa, re_token_t token) re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
{ {
int type = token.type; int type = token.type;
@ -1358,6 +1377,7 @@ calc_state_hash (const re_node_set *nodes, unsigned int context)
optimization. */ optimization. */
static re_dfastate_t * static re_dfastate_t *
internal_function
re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
const re_node_set *nodes) const re_node_set *nodes)
{ {
@ -1400,7 +1420,8 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
- We never return non-NULL value in case of any errors, it is for - We never return non-NULL value in case of any errors, it is for
optimization. */ optimization. */
static re_dfastate_t* static re_dfastate_t *
internal_function
re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
const re_node_set *nodes, unsigned int context) const re_node_set *nodes, unsigned int context)
{ {
@ -1470,6 +1491,22 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
return REG_NOERROR; return REG_NOERROR;
} }
static void
free_state (re_dfastate_t *state)
{
re_node_set_free (&state->non_eps_nodes);
re_node_set_free (&state->inveclosure);
if (state->entrance_nodes != &state->nodes)
{
re_node_set_free (state->entrance_nodes);
re_free (state->entrance_nodes);
}
re_node_set_free (&state->nodes);
re_free (state->word_trtable);
re_free (state->trtable);
re_free (state);
}
/* Create the new state which is independ of contexts. /* Create the new state which is independ of contexts.
Return the new state if succeeded, otherwise return NULL. */ Return the new state if succeeded, otherwise return NULL. */
@ -1595,19 +1632,3 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
} }
return newstate; return newstate;
} }
static void
free_state (re_dfastate_t *state)
{
re_node_set_free (&state->non_eps_nodes);
re_node_set_free (&state->inveclosure);
if (state->entrance_nodes != &state->nodes)
{
re_node_set_free (state->entrance_nodes);
re_free (state->entrance_nodes);
}
re_node_set_free (&state->nodes);
re_free (state->word_trtable);
re_free (state->trtable);
re_free (state);
}

View File

@ -145,9 +145,6 @@ typedef const bitset_word_t *re_const_bitset_ptr_t;
#define bitset_empty(set) memset (set, '\0', sizeof (bitset_t)) #define bitset_empty(set) memset (set, '\0', sizeof (bitset_t))
#define bitset_set_all(set) memset (set, '\xff', sizeof (bitset_t)) #define bitset_set_all(set) memset (set, '\xff', sizeof (bitset_t))
#define bitset_copy(dest,src) memcpy (dest, src, sizeof (bitset_t)) #define bitset_copy(dest,src) memcpy (dest, src, sizeof (bitset_t))
static inline void bitset_not (bitset_t set);
static inline void bitset_merge (bitset_t dest, const bitset_t src);
static inline void bitset_mask (bitset_t dest, const bitset_t src);
#define PREV_WORD_CONSTRAINT 0x0001 #define PREV_WORD_CONSTRAINT 0x0001
#define PREV_NOTWORD_CONSTRAINT 0x0002 #define PREV_NOTWORD_CONSTRAINT 0x0002
@ -381,17 +378,6 @@ typedef struct re_dfa_t re_dfa_t;
#endif #endif
#ifndef RE_NO_INTERNAL_PROTOTYPES #ifndef RE_NO_INTERNAL_PROTOTYPES
static reg_errcode_t re_string_allocate (re_string_t *pstr, const char *str,
int len, int init_len,
RE_TRANSLATE_TYPE trans, int icase,
const re_dfa_t *dfa)
internal_function;
static reg_errcode_t re_string_construct (re_string_t *pstr, const char *str,
int len, RE_TRANSLATE_TYPE trans,
int icase, const re_dfa_t *dfa)
internal_function;
static reg_errcode_t re_string_reconstruct (re_string_t *pstr, int idx,
int eflags) internal_function;
static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
int new_buf_len) int new_buf_len)
internal_function; internal_function;
@ -401,23 +387,9 @@ static int build_wcs_upper_buffer (re_string_t *pstr) internal_function;
# endif /* RE_ENABLE_I18N */ # endif /* RE_ENABLE_I18N */
static void build_upper_buffer (re_string_t *pstr) internal_function; static void build_upper_buffer (re_string_t *pstr) internal_function;
static void re_string_translate_buffer (re_string_t *pstr) internal_function; static void re_string_translate_buffer (re_string_t *pstr) internal_function;
static void re_string_destruct (re_string_t *pstr) internal_function;
# ifdef RE_ENABLE_I18N
static int re_string_elem_size_at (const re_string_t *pstr, int idx)
internal_function __attribute ((pure));
static inline int re_string_char_size_at (const re_string_t *pstr, int idx)
internal_function __attribute ((pure));
static inline wint_t re_string_wchar_at (const re_string_t *pstr, int idx)
internal_function __attribute ((pure));
# endif /* RE_ENABLE_I18N */
static unsigned int re_string_context_at (const re_string_t *input, int idx, static unsigned int re_string_context_at (const re_string_t *input, int idx,
int eflags) int eflags)
internal_function __attribute ((pure)); internal_function __attribute ((pure));
static unsigned char re_string_peek_byte_case (const re_string_t *pstr,
int idx)
internal_function __attribute ((pure));
static unsigned char re_string_fetch_byte_case (re_string_t *pstr)
internal_function __attribute ((pure));
#endif #endif
#define re_string_peek_byte(pstr, offset) \ #define re_string_peek_byte(pstr, offset) \
((pstr)->mbs[(pstr)->cur_idx + offset]) ((pstr)->mbs[(pstr)->cur_idx + offset])
@ -677,46 +649,11 @@ struct re_dfa_t
__libc_lock_define (, lock) __libc_lock_define (, lock)
}; };
#ifndef RE_NO_INTERNAL_PROTOTYPES
static reg_errcode_t re_node_set_alloc (re_node_set *set, int size) internal_function;
static reg_errcode_t re_node_set_init_1 (re_node_set *set, int elem) internal_function;
static reg_errcode_t re_node_set_init_2 (re_node_set *set, int elem1,
int elem2) internal_function;
#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
static reg_errcode_t re_node_set_init_copy (re_node_set *dest,
const re_node_set *src) internal_function;
static reg_errcode_t re_node_set_add_intersect (re_node_set *dest,
const re_node_set *src1,
const re_node_set *src2) internal_function;
static reg_errcode_t re_node_set_init_union (re_node_set *dest,
const re_node_set *src1,
const re_node_set *src2) internal_function;
static reg_errcode_t re_node_set_merge (re_node_set *dest,
const re_node_set *src) internal_function;
static int re_node_set_insert (re_node_set *set, int elem) internal_function;
static int re_node_set_insert_last (re_node_set *set,
int elem) internal_function;
static int re_node_set_compare (const re_node_set *set1,
const re_node_set *set2)
internal_function __attribute ((pure));
static int re_node_set_contains (const re_node_set *set, int elem)
internal_function __attribute ((pure));
static void re_node_set_remove_at (re_node_set *set, int idx) internal_function;
#define re_node_set_remove(set,id) \ #define re_node_set_remove(set,id) \
(re_node_set_remove_at (set, re_node_set_contains (set, id) - 1)) (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1))
#define re_node_set_empty(p) ((p)->nelem = 0) #define re_node_set_empty(p) ((p)->nelem = 0)
#define re_node_set_free(set) re_free ((set)->elems) #define re_node_set_free(set) re_free ((set)->elems)
static int re_dfa_add_node (re_dfa_t *dfa, re_token_t token) internal_function;
static re_dfastate_t *re_acquire_state (reg_errcode_t *err, const
re_dfa_t *dfa,
const re_node_set *nodes)
internal_function;
static re_dfastate_t *re_acquire_state_context (reg_errcode_t *err,
const re_dfa_t *dfa,
const re_node_set *nodes,
unsigned int context) internal_function;
static void free_state (re_dfastate_t *state) internal_function;
#endif
typedef enum typedef enum
@ -768,7 +705,7 @@ bitset_mask (bitset_t dest, const bitset_t src)
#if defined RE_ENABLE_I18N && !defined RE_NO_INTERNAL_PROTOTYPES #if defined RE_ENABLE_I18N && !defined RE_NO_INTERNAL_PROTOTYPES
/* Inline functions for re_string. */ /* Inline functions for re_string. */
static inline int static inline int
internal_function internal_function __attribute ((pure))
re_string_char_size_at (const re_string_t *pstr, int idx) re_string_char_size_at (const re_string_t *pstr, int idx)
{ {
int byte_idx; int byte_idx;
@ -781,7 +718,7 @@ re_string_char_size_at (const re_string_t *pstr, int idx)
} }
static inline wint_t static inline wint_t
internal_function internal_function __attribute ((pure))
re_string_wchar_at (const re_string_t *pstr, int idx) re_string_wchar_at (const re_string_t *pstr, int idx)
{ {
if (pstr->mb_cur_max == 1) if (pstr->mb_cur_max == 1)
@ -790,10 +727,10 @@ re_string_wchar_at (const re_string_t *pstr, int idx)
} }
static int static int
internal_function internal_function __attribute ((pure))
re_string_elem_size_at (const re_string_t *pstr, int idx) re_string_elem_size_at (const re_string_t *pstr, int idx)
{ {
#ifdef _LIBC # ifdef _LIBC
const unsigned char *p, *extra; const unsigned char *p, *extra;
const int32_t *table, *indirect; const int32_t *table, *indirect;
int32_t tmp; int32_t tmp;
@ -812,7 +749,7 @@ re_string_elem_size_at (const re_string_t *pstr, int idx)
return p - pstr->mbs - idx; return p - pstr->mbs - idx;
} }
else else
#endif /* _LIBC */ # endif /* _LIBC */
return 1; return 1;
} }
#endif /* RE_ENABLE_I18N */ #endif /* RE_ENABLE_I18N */