Update parameter definitions from K&R to ANSI style.
Add a few case fall-through comments.
---
regex.c | 163 ++++++++++++++++----------------------------------------
1 file changed, 47 insertions(+), 116 deletions(-)
diff --git a/regex.c b/regex.c
index bba0daaa..dde6d78d 100644
--- a/regex.c
+++ b/regex.c
@@ -522,9 +522,7 @@ typedef enum
at SOURCE. */
static void extract_number _RE_ARGS ((unsigned int *dest, unsigned char
*source));
static void
-extract_number (dest, source)
- unsigned int *dest;
- unsigned char *source;
+extract_number (unsigned int *dest, unsigned char *source)
{
unsigned int b1, b2, mask;
@@ -958,8 +956,7 @@ reg_syntax_t re_syntax_options;
defined in regex.h. We return the old syntax. */
reg_syntax_t
-re_set_syntax (syntax)
- reg_syntax_t syntax;
+re_set_syntax (reg_syntax_t syntax)
{
reg_syntax_t ret = re_syntax_options;
@@ -1780,11 +1777,7 @@ static boolean group_in_compile_stack _RE_ARGS
((compile_stack_type
return (free (compile_stack.stack), value) /* __MEM_CHECKED__ */
static reg_errcode_t
-regex_compile (pattern, size, syntax, bufp)
- const char *pattern;
- size_t size;
- reg_syntax_t syntax;
- struct re_pattern_buffer *bufp;
+regex_compile (const char *pattern, size_t size, reg_syntax_t syntax, struct
re_pattern_buffer *bufp)
{
/* We fetch characters from PATTERN here. Even though PATTERN is
`char *' (i.e., signed), we declare these variables as unsigned, so
@@ -2835,10 +2828,7 @@ regex_compile (pattern, size, syntax, bufp)
/* Store OP at LOC followed by two-byte integer parameter ARG. */
static void
-store_op1 (op, loc, arg)
- re_opcode_t op;
- unsigned char *loc;
- int arg;
+store_op1 (re_opcode_t op, unsigned char *loc, int arg)
{
*loc = (unsigned char) op;
STORE_NUMBER (loc + 1, arg);
@@ -2848,10 +2838,7 @@ store_op1 (op, loc, arg)
/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */
static void
-store_op2 (op, loc, arg1, arg2)
- re_opcode_t op;
- unsigned char *loc;
- int arg1, arg2;
+store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2)
{
*loc = (unsigned char) op;
STORE_NUMBER (loc + 1, arg1);
@@ -2863,11 +2850,7 @@ store_op2 (op, loc, arg1, arg2)
for OP followed by two-byte integer parameter ARG. */
static void
-insert_op1 (op, loc, arg, end)
- re_opcode_t op;
- unsigned char *loc;
- int arg;
- unsigned char *end;
+insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end)
{
register unsigned char *pfrom = end;
register unsigned char *pto = end + 3;
@@ -2882,11 +2865,7 @@ insert_op1 (op, loc, arg, end)
/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */
static void
-insert_op2 (op, loc, arg1, arg2, end)
- re_opcode_t op;
- unsigned char *loc;
- int arg1, arg2;
- unsigned char *end;
+insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned
char *end)
{
register unsigned char *pfrom = end;
register unsigned char *pto = end + 5;
@@ -2903,9 +2882,7 @@ insert_op2 (op, loc, arg1, arg2, end)
least one character before the ^. */
static boolean
-at_begline_loc_p (pattern, p, syntax)
- const char *pattern, *p;
- reg_syntax_t syntax;
+at_begline_loc_p (const char *pattern, const char *p, reg_syntax_t syntax)
{
const char *prev = p - 2;
boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
@@ -2922,9 +2899,7 @@ at_begline_loc_p (pattern, p, syntax)
at least one character after the $, i.e., `P < PEND'. */
static boolean
-at_endline_loc_p (p, pend, syntax)
- const char *p, *pend;
- reg_syntax_t syntax;
+at_endline_loc_p (const char *p, const char *pend, reg_syntax_t syntax)
{
const char *next = p;
boolean next_backslash = *next == '\\';
@@ -2944,9 +2919,7 @@ at_endline_loc_p (p, pend, syntax)
false if it's not. */
static boolean
-group_in_compile_stack (compile_stack, regnum)
- compile_stack_type compile_stack;
- regnum_t regnum;
+group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
{
int this_element;
@@ -2972,11 +2945,8 @@ group_in_compile_stack (compile_stack, regnum)
`regex_compile' itself. */
static reg_errcode_t
-compile_range (p_ptr, pend, translate, syntax, b)
- const char **p_ptr, *pend;
- RE_TRANSLATE_TYPE translate;
- reg_syntax_t syntax;
- unsigned char *b;
+compile_range (const char **p_ptr, const char *pend, RE_TRANSLATE_TYPE
translate,
+ reg_syntax_t syntax, unsigned char *b)
{
unsigned this_char;
@@ -3031,8 +3001,7 @@ compile_range (p_ptr, pend, translate, syntax, b)
Returns 0 if we succeed, -2 if an internal error. */
int
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
+re_compile_fastmap (struct re_pattern_buffer *bufp)
{
int j, k;
#ifdef MATCH_MAY_ALLOCATE
@@ -3333,11 +3302,8 @@ re_compile_fastmap (bufp)
freeing the old data. */
void
-re_set_registers (bufp, regs, num_regs, starts, ends)
- struct re_pattern_buffer *bufp;
- struct re_registers *regs;
- unsigned num_regs;
- regoff_t *starts, *ends;
+re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
+ unsigned num_regs, regoff_t *starts, regoff_t *ends)
{
if (num_regs)
{
@@ -3360,11 +3326,8 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
doesn't let you say where to stop matching. */
int
-re_search (bufp, string, size, startpos, range, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int size, startpos, range;
- struct re_registers *regs;
+re_search (struct re_pattern_buffer *bufp, const char *string, int size,
+ int startpos, int range, struct re_registers *regs)
{
return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
regs, size);
@@ -3393,14 +3356,9 @@ re_search (bufp, string, size, startpos, range, regs)
stack overflow). */
int
-re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int size1, size2;
- int startpos;
- int range;
- struct re_registers *regs;
- int stop;
+re_search_2 (struct re_pattern_buffer *bufp, const char *string1, int size1,
+ const char *string2, int size2, int startpos, int range,
+ struct re_registers *regs, int stop)
{
int val;
register char *fastmap = bufp->fastmap;
@@ -3611,11 +3569,8 @@ re_search_2 (bufp, string1, size1, string2, size2,
startpos, range, regs, stop)
/* re_match is like re_match_2 except it takes only a single string. */
int
-re_match (bufp, string, size, pos, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int size, pos;
- struct re_registers *regs;
+re_match (struct re_pattern_buffer *bufp, const char *string, int size, int
pos,
+ struct re_registers *regs)
{
int result = re_match_2_internal (bufp, NULL, 0, string, size,
pos, regs, size);
@@ -3654,13 +3609,9 @@ static int bcmp_translate _RE_ARGS ((const char *s1,
const char *s2,
matched substring. */
int
-re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int size1, size2;
- int pos;
- struct re_registers *regs;
- int stop;
+re_match_2 (struct re_pattern_buffer *bufp, const char *string1, int size1,
+ const char *string2, int size2, int pos, struct re_registers *regs,
+ int stop)
{
int result = re_match_2_internal (bufp, string1, size1, string2, size2,
pos, regs, stop);
@@ -3675,13 +3626,9 @@ re_match_2 (bufp, string1, size1, string2, size2, pos,
regs, stop)
/* This is a separate function so that we can force an alloca cleanup
afterwards. */
static int
-re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int size1, size2;
- int pos;
- struct re_registers *regs;
- int stop;
+re_match_2_internal (struct re_pattern_buffer *bufp, const char *string1,
+ int size1, const char *string2, int size2, int pos,
+ struct re_registers *regs, int stop)
{
/* General temporaries. */
int mcnt;
@@ -4299,6 +4246,7 @@ re_match_2_internal (bufp, string1, size1, string2,
size2, pos, regs, stop)
{
case jump_n:
is_a_jump_n = true;
+ /* fall through */
case pop_failure_jump:
case maybe_pop_jump:
case jump:
@@ -4717,7 +4665,7 @@ re_match_2_internal (bufp, string1, size1, string2,
size2, pos, regs, stop)
DEBUG_PRINT1 (" Match => jump.\n");
goto unconditional_jump;
}
- /* Note fall through. */
+ /* fall through. */
/* The end of a simple repeat has a pop_failure_jump back to
@@ -5032,6 +4980,7 @@ re_match_2_internal (bufp, string1, size1, string2,
size2, pos, regs, stop)
{
case jump_n:
is_a_jump_n = true;
+ /* fall through */
case maybe_pop_jump:
case pop_failure_jump:
case jump:
@@ -5078,9 +5027,8 @@ re_match_2_internal (bufp, string1, size1, string2,
size2, pos, regs, stop)
We don't handle duplicates properly (yet). */
static boolean
-group_match_null_string_p (p, end, reg_info)
- unsigned char **p, *end;
- register_info_type *reg_info;
+group_match_null_string_p (unsigned char **p, unsigned char *end,
+ register_info_type *reg_info)
{
int mcnt;
/* Point to after the args to the start_memory. */
@@ -5187,9 +5135,8 @@ group_match_null_string_p (p, end, reg_info)
byte past the last. The alternative can contain groups. */
static boolean
-alt_match_null_string_p (p, end, reg_info)
- unsigned char *p, *end;
- register_info_type *reg_info;
+alt_match_null_string_p (unsigned char *p, unsigned char *end,
+ register_info_type *reg_info)
{
int mcnt;
unsigned char *p1 = p;
@@ -5224,9 +5171,8 @@ alt_match_null_string_p (p, end, reg_info)
Sets P to one after the op and its arguments, if any. */
static boolean
-common_op_match_null_string_p (p, end, reg_info)
- unsigned char **p, *end;
- register_info_type *reg_info;
+common_op_match_null_string_p (unsigned char **p, unsigned char *end,
+ register_info_type *reg_info)
{
int mcnt;
boolean ret;
@@ -5297,6 +5243,7 @@ common_op_match_null_string_p (p, end, reg_info)
case set_number_at:
p1 += 4;
+ /* fall through */
default:
/* All other opcodes mean we cannot match the empty string. */
@@ -5312,10 +5259,8 @@ common_op_match_null_string_p (p, end, reg_info)
bytes; nonzero otherwise. */
static int
-bcmp_translate (s1, s2, len, translate)
- const char *s1, *s2;
- register int len;
- RE_TRANSLATE_TYPE translate;
+bcmp_translate (const char *s1, const char *s2, register int len,
+ RE_TRANSLATE_TYPE translate)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
@@ -5339,10 +5284,8 @@ bcmp_translate (s1, s2, len, translate)
We call regex_compile to do the actual compilation. */
const char *
-re_compile_pattern (pattern, length, bufp)
- const char *pattern;
- size_t length;
- struct re_pattern_buffer *bufp;
+re_compile_pattern (const char *pattern, size_t length,
+ struct re_pattern_buffer *bufp)
{
reg_errcode_t ret;
@@ -5473,10 +5416,7 @@ re_exec (s)
the return codes and their meanings.) */
int
-regcomp (preg, pattern, cflags)
- regex_t *preg;
- const char *pattern;
- int cflags;
+regcomp (regex_t *preg, const char *pattern, int cflags)
{
reg_errcode_t ret;
reg_syntax_t syntax
@@ -5551,12 +5491,8 @@ regcomp (preg, pattern, cflags)
We return 0 if we find a match and REG_NOMATCH if not. */
int
-regexec (preg, string, nmatch, pmatch, eflags)
- const regex_t *preg;
- const char *string;
- size_t nmatch;
- regmatch_t pmatch[];
- int eflags;
+regexec (const regex_t *preg, const char *string, size_t nmatch,
+ regmatch_t pmatch[], int eflags)
{
int ret;
struct re_registers regs;
@@ -5616,11 +5552,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
from either regcomp or regexec. We don't use PREG here. */
size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- const regex_t *preg;
- char *errbuf;
- size_t errbuf_size;
+regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
{
const char *msg;
size_t msg_size;
@@ -5656,8 +5588,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
/* Free dynamically allocated space used by PREG. */
void
-regfree (preg)
- regex_t *preg;
+regfree (regex_t *preg)
{
if (preg->buffer != NULL)
free (preg->buffer); /* __MEM_CHECKED__ */
--
2.55.0