about summary refs log tree commit diff
path: root/posix/regex_internal.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-10-13 20:08:58 +0000
committerUlrich Drepper <drepper@redhat.com>2005-10-13 20:08:58 +0000
commite2f55264073bcb6b3f63a241bd01eb7d48846c16 (patch)
tree1f73fed81b1c703dab82e38d91fecd25f24ed635 /posix/regex_internal.c
parent72c7a71de49af5e025f5c064079b25631af6c457 (diff)
downloadglibc-e2f55264073bcb6b3f63a241bd01eb7d48846c16.tar.gz
glibc-e2f55264073bcb6b3f63a241bd01eb7d48846c16.tar.xz
glibc-e2f55264073bcb6b3f63a241bd01eb7d48846c16.zip
[BZ #1231]
2005-08-23  Paul Eggert  <eggert@cs.ucla.edu>
	[BZ #1231]
	* posix/regex_internal.c (re_string_skip_chars, register_state,
	calc_state_hash): Remove forward decls.
	* posix/regexec.c (acquire_init_state_context, check_halt_node_context,
	proceed_next_node, pop_fail_stack, sub_epsilon_src_nodes,
	clean_state_log_if_needed): Likewise.

	* posix/regex.c: No need to use K&R definitions for static functions.
	* posix/regex_internal.c: Likewise.
Diffstat (limited to 'posix/regex_internal.c')
-rw-r--r--posix/regex_internal.c169
1 files changed, 48 insertions, 121 deletions
diff --git a/posix/regex_internal.c b/posix/regex_internal.c
index 2b3725f3dd..016304c426 100644
--- a/posix/regex_internal.c
+++ b/posix/regex_internal.c
@@ -22,13 +22,6 @@ static void re_string_construct_common (const char *str, int len,
 					re_string_t *pstr,
 					RE_TRANSLATE_TYPE trans, int icase,
 					const re_dfa_t *dfa) internal_function;
-#ifdef RE_ENABLE_I18N
-static int re_string_skip_chars (re_string_t *pstr, int new_raw_idx,
-				 wint_t *last_wc) internal_function;
-#endif /* RE_ENABLE_I18N */
-static reg_errcode_t register_state (const re_dfa_t *dfa,
-				     re_dfastate_t *newstate,
-				     unsigned int hash) internal_function;
 static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
 					  const re_node_set *nodes,
 					  unsigned int hash) internal_function;
@@ -36,8 +29,6 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
 					  const re_node_set *nodes,
 					  unsigned int context,
 					  unsigned int hash) internal_function;
-static inline unsigned int calc_state_hash (const re_node_set *nodes,
-					    unsigned int context) internal_function;
 
 /* Functions for string operation.  */
 
@@ -45,12 +36,8 @@ static inline unsigned int calc_state_hash (const re_node_set *nodes,
    re_string_reconstruct before using the object.  */
 
 static reg_errcode_t
-re_string_allocate (pstr, str, len, init_len, trans, icase, dfa)
-     re_string_t *pstr;
-     const char *str;
-     int len, init_len, icase;
-     RE_TRANSLATE_TYPE trans;
-     const re_dfa_t *dfa;
+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)
 {
   reg_errcode_t ret;
   int init_buf_len;
@@ -76,12 +63,8 @@ re_string_allocate (pstr, str, len, init_len, trans, icase, dfa)
 /* This function allocate the buffers, and initialize them.  */
 
 static reg_errcode_t
-re_string_construct (pstr, str, len, trans, icase, dfa)
-     re_string_t *pstr;
-     const char *str;
-     int len, icase;
-     RE_TRANSLATE_TYPE trans;
-     const re_dfa_t *dfa;
+re_string_construct (re_string_t *pstr, const char *str, int len,
+		     RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
 {
   reg_errcode_t ret;
   memset (pstr, '\0', sizeof (re_string_t));
@@ -142,9 +125,7 @@ re_string_construct (pstr, str, len, trans, icase, dfa)
 /* Helper functions for re_string_allocate, and re_string_construct.  */
 
 static reg_errcode_t
-re_string_realloc_buffers (pstr, new_buf_len)
-     re_string_t *pstr;
-     int new_buf_len;
+re_string_realloc_buffers (re_string_t *pstr, int new_buf_len)
 {
 #ifdef RE_ENABLE_I18N
   if (pstr->mb_cur_max > 1)
@@ -176,13 +157,9 @@ re_string_realloc_buffers (pstr, new_buf_len)
 
 
 static void
-re_string_construct_common (str, len, pstr, trans, icase, dfa)
-     const char *str;
-     int len;
-     re_string_t *pstr;
-     RE_TRANSLATE_TYPE trans;
-     int icase;
-     const re_dfa_t *dfa;
+re_string_construct_common (const char *str, int len, re_string_t *pstr,
+			    RE_TRANSLATE_TYPE trans, int icase,
+			    const re_dfa_t *dfa)
 {
   pstr->raw_mbs = (const unsigned char *) str;
   pstr->len = len;
@@ -211,8 +188,7 @@ re_string_construct_common (str, len, pstr, trans, icase, dfa)
    built and starts from PSTR->VALID_LEN.  */
 
 static void
-build_wcs_buffer (pstr)
-     re_string_t *pstr;
+build_wcs_buffer (re_string_t *pstr)
 {
 #ifdef _LIBC
   unsigned char buf[MB_LEN_MAX];
@@ -279,8 +255,7 @@ build_wcs_buffer (pstr)
    but for REG_ICASE.  */
 
 static int
-build_wcs_upper_buffer (pstr)
-     re_string_t *pstr;
+build_wcs_upper_buffer (re_string_t *pstr)
 {
   mbstate_t prev_st;
   int src_idx, byte_idx, end_idx, remain_len;
@@ -495,10 +470,8 @@ build_wcs_upper_buffer (pstr)
    Return the index.  */
 
 static int
-re_string_skip_chars (pstr, new_raw_idx, last_wc)
-     re_string_t *pstr;
-     int new_raw_idx;
-     wint_t *last_wc;
+internal_function
+re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
 {
   mbstate_t prev_st;
   int rawbuf_idx;
@@ -532,8 +505,7 @@ re_string_skip_chars (pstr, new_raw_idx, last_wc)
    This function is used in case of REG_ICASE.  */
 
 static void
-build_upper_buffer (pstr)
-     re_string_t *pstr;
+build_upper_buffer (re_string_t *pstr)
 {
   int char_idx, end_idx;
   end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
@@ -555,8 +527,7 @@ build_upper_buffer (pstr)
 /* Apply TRANS to the buffer in PSTR.  */
 
 static void
-re_string_translate_buffer (pstr)
-     re_string_t *pstr;
+re_string_translate_buffer (re_string_t *pstr)
 {
   int buf_idx, end_idx;
   end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
@@ -576,9 +547,7 @@ re_string_translate_buffer (pstr)
    convert to upper case in case of REG_ICASE, apply translation.  */
 
 static reg_errcode_t
-re_string_reconstruct (pstr, idx, eflags)
-     re_string_t *pstr;
-     int idx, eflags;
+re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
 {
   int offset = idx - pstr->raw_mbs_idx;
   if (BE (offset < 0, 0))
@@ -767,9 +736,7 @@ re_string_reconstruct (pstr, idx, eflags)
 }
 
 static unsigned char
-re_string_peek_byte_case (pstr, idx)
-     const re_string_t *pstr;
-     int idx;
+re_string_peek_byte_case (const re_string_t *pstr, int idx)
 {
   int ch, off;
 
@@ -804,8 +771,7 @@ re_string_peek_byte_case (pstr, idx)
 }
 
 static unsigned char
-re_string_fetch_byte_case (pstr)
-     re_string_t *pstr;
+re_string_fetch_byte_case (re_string_t *pstr)
 {
   if (BE (!pstr->mbs_allocated, 1))
     return re_string_fetch_byte (pstr);
@@ -841,8 +807,7 @@ re_string_fetch_byte_case (pstr)
 }
 
 static void
-re_string_destruct (pstr)
-     re_string_t *pstr;
+re_string_destruct (re_string_t *pstr)
 {
 #ifdef RE_ENABLE_I18N
   re_free (pstr->wcs);
@@ -855,9 +820,7 @@ re_string_destruct (pstr)
 /* Return the context at IDX in INPUT.  */
 
 static unsigned int
-re_string_context_at (input, idx, eflags)
-     const re_string_t *input;
-     int idx, eflags;
+re_string_context_at (const re_string_t *input, int idx, int eflags)
 {
   int c;
   if (BE (idx < 0, 0))
@@ -901,9 +864,7 @@ re_string_context_at (input, idx, eflags)
 /* Functions for set operation.  */
 
 static reg_errcode_t
-re_node_set_alloc (set, size)
-     re_node_set *set;
-     int size;
+re_node_set_alloc (re_node_set *set, int size)
 {
   set->alloc = size;
   set->nelem = 0;
@@ -914,9 +875,7 @@ re_node_set_alloc (set, size)
 }
 
 static reg_errcode_t
-re_node_set_init_1 (set, elem)
-     re_node_set *set;
-     int elem;
+re_node_set_init_1 (re_node_set *set, int elem)
 {
   set->alloc = 1;
   set->nelem = 1;
@@ -931,9 +890,7 @@ re_node_set_init_1 (set, elem)
 }
 
 static reg_errcode_t
-re_node_set_init_2 (set, elem1, elem2)
-     re_node_set *set;
-     int elem1, elem2;
+re_node_set_init_2 (re_node_set *set, int elem1, int elem2)
 {
   set->alloc = 2;
   set->elems = re_malloc (int, 2);
@@ -962,9 +919,7 @@ re_node_set_init_2 (set, elem1, elem2)
 }
 
 static reg_errcode_t
-re_node_set_init_copy (dest, src)
-     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;
   if (src->nelem > 0)
@@ -988,9 +943,8 @@ re_node_set_init_copy (dest, src)
    Note: We assume dest->elems is NULL, when dest->alloc is 0.  */
 
 static reg_errcode_t
-re_node_set_add_intersect (dest, src1, src2)
-     re_node_set *dest;
-     const re_node_set *src1, *src2;
+re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
+			   const re_node_set *src2)
 {
   int i1, i2, is, id, delta, sbase;
   if (src1->nelem == 0 || src2->nelem == 0)
@@ -1079,9 +1033,8 @@ re_node_set_add_intersect (dest, src1, src2)
    DEST. Return value indicate the error code or REG_NOERROR if succeeded.  */
 
 static reg_errcode_t
-re_node_set_init_union (dest, src1, src2)
-     re_node_set *dest;
-     const re_node_set *src1, *src2;
+re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
+			const re_node_set *src2)
 {
   int i1, i2, id;
   if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
@@ -1132,9 +1085,7 @@ re_node_set_init_union (dest, src1, src2)
    DEST. Return value indicate the error code or REG_NOERROR if succeeded.  */
 
 static reg_errcode_t
-re_node_set_merge (dest, src)
-     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;
   if (src == NULL || src->nelem == 0)
@@ -1216,9 +1167,7 @@ re_node_set_merge (dest, src)
    return -1 if an error is occured, return 1 otherwise.  */
 
 static int
-re_node_set_insert (set, elem)
-     re_node_set *set;
-     int elem;
+re_node_set_insert (re_node_set *set, int elem)
 {
   int idx;
   /* In case the set is empty.  */
@@ -1274,9 +1223,7 @@ re_node_set_insert (set, elem)
    Return -1 if an error is occured, return 1 otherwise.  */
 
 static int
-re_node_set_insert_last (set, elem)
-     re_node_set *set;
-     int elem;
+re_node_set_insert_last (re_node_set *set, int elem)
 {
   /* Realloc if we need.  */
   if (set->alloc == set->nelem)
@@ -1298,8 +1245,7 @@ re_node_set_insert_last (set, elem)
    return 1 if SET1 and SET2 are equivalent, return 0 otherwise.  */
 
 static int
-re_node_set_compare (set1, set2)
-     const re_node_set *set1, *set2;
+re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
 {
   int i;
   if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
@@ -1313,9 +1259,7 @@ re_node_set_compare (set1, set2)
 /* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise.  */
 
 static int
-re_node_set_contains (set, elem)
-     const re_node_set *set;
-     int elem;
+re_node_set_contains (const re_node_set *set, int elem)
 {
   unsigned int idx, right, mid;
   if (set->nelem <= 0)
@@ -1336,9 +1280,7 @@ re_node_set_contains (set, elem)
 }
 
 static void
-re_node_set_remove_at (set, idx)
-     re_node_set *set;
-     int idx;
+re_node_set_remove_at (re_node_set *set, int idx)
 {
   if (idx < 0 || idx >= set->nelem)
     return;
@@ -1352,9 +1294,7 @@ re_node_set_remove_at (set, idx)
    Or return -1, if an error will be occured.  */
 
 static int
-re_dfa_add_node (dfa, token)
-     re_dfa_t *dfa;
-     re_token_t token;
+re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
 {
   int type = token.type;
   if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
@@ -1398,9 +1338,8 @@ re_dfa_add_node (dfa, token)
 }
 
 static inline unsigned int
-calc_state_hash (nodes, context)
-     const re_node_set *nodes;
-     unsigned int context;
+internal_function
+calc_state_hash (const re_node_set *nodes, unsigned int context)
 {
   unsigned int hash = nodes->nelem + context;
   int i;
@@ -1418,11 +1357,9 @@ calc_state_hash (nodes, context)
 	 - We never return non-NULL value in case of any errors, it is for
 	   optimization.  */
 
-static re_dfastate_t*
-re_acquire_state (err, dfa, nodes)
-     reg_errcode_t *err;
-     const re_dfa_t *dfa;
-     const re_node_set *nodes;
+static re_dfastate_t *
+re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
+		  const re_node_set *nodes)
 {
   unsigned int hash;
   re_dfastate_t *new_state;
@@ -1464,11 +1401,8 @@ re_acquire_state (err, dfa, nodes)
 	   optimization.  */
 
 static re_dfastate_t*
-re_acquire_state_context (err, dfa, nodes, context)
-     reg_errcode_t *err;
-     const re_dfa_t *dfa;
-     const re_node_set *nodes;
-     unsigned int context;
+re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
+			  const re_node_set *nodes, unsigned int context)
 {
   unsigned int hash;
   re_dfastate_t *new_state;
@@ -1503,10 +1437,8 @@ re_acquire_state_context (err, dfa, nodes, context)
    indicates the error code if failed.  */
 
 static reg_errcode_t
-register_state (dfa, newstate, hash)
-     const re_dfa_t *dfa;
-     re_dfastate_t *newstate;
-     unsigned int hash;
+register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
+		unsigned int hash)
 {
   struct re_state_table_entry *spot;
   reg_errcode_t err;
@@ -1542,10 +1474,8 @@ register_state (dfa, newstate, hash)
    Return the new state if succeeded, otherwise return NULL.  */
 
 static re_dfastate_t *
-create_ci_newstate (dfa, nodes, hash)
-     const re_dfa_t *dfa;
-     const re_node_set *nodes;
-     unsigned int hash;
+create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+		    unsigned int hash)
 {
   int i;
   reg_errcode_t err;
@@ -1593,10 +1523,8 @@ create_ci_newstate (dfa, nodes, hash)
    Return the new state if succeeded, otherwise return NULL.  */
 
 static re_dfastate_t *
-create_cd_newstate (dfa, nodes, context, hash)
-     const re_dfa_t *dfa;
-     const re_node_set *nodes;
-     unsigned int context, hash;
+create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+		    unsigned int context, unsigned int hash)
 {
   int i, nctx_nodes = 0;
   reg_errcode_t err;
@@ -1669,8 +1597,7 @@ create_cd_newstate (dfa, nodes, context, hash)
 }
 
 static void
-free_state (state)
-     re_dfastate_t *state;
+free_state (re_dfastate_t *state)
 {
   re_node_set_free (&state->non_eps_nodes);
   re_node_set_free (&state->inveclosure);