/*
- * $Id: GNUregex.c,v 1.13 2003/01/23 00:37:00 robertc Exp $
+ * $Id: GNUregex.c,v 1.14 2003/06/19 22:25:18 robertc Exp $
*/
/* Extended regular expression matching and search library,
} /* regex_compile */
\f
/* Subroutines for `regex_compile'. */
+static void store_op1(re_opcode_t op, unsigned char *loc, int arg);
+static void store_op2( re_opcode_t op, unsigned char *loc, int arg1, int arg2);
+static void insert_op1(re_opcode_t op, unsigned char *loc, int arg, unsigned char *end);
+static void insert_op2(re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned char *end);
+static boolean at_begline_loc_p(const char * pattern, const char *p, reg_syntax_t syntax);
+static boolean at_endline_loc_p(const char *p, const char *pend, int syntax);
+static boolean group_in_compile_stack(compile_stack_type compile_stack, regnum_t regnum);
+static reg_errcode_t compile_range(const char **p_ptr, const char *pend, char *translate, reg_syntax_t syntax, unsigned char *b);
/* 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;
+void store_op1(re_opcode_t op, unsigned char *loc, int arg)
{
*loc = (unsigned char) op;
STORE_NUMBER(loc + 1, 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;
+void
+store_op2( re_opcode_t op, unsigned char *loc, int arg1, int arg2)
{
*loc = (unsigned char) op;
STORE_NUMBER(loc + 1, arg1);
/* Copy the bytes from LOC to END to open up three bytes of space at LOC
* 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;
+void
+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;
/* 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;
+void
+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;
* after an alternative or a begin-subexpression. We assume there is at
* least one character before the ^. */
-static boolean
-at_begline_loc_p(pattern, p, syntax)
- const char *pattern, *p;
- reg_syntax_t syntax;
+boolean
+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] == '\\';
/* The dual of at_begline_loc_p. This one is for $. We assume there is
* at least one character after the $, i.e., `P < PEND'. */
-static boolean
-at_endline_loc_p(p, pend, syntax)
- const char *p, *pend;
- int syntax;
+boolean
+at_endline_loc_p(const char *p, const char *pend, int syntax)
{
const char *next = p;
boolean next_backslash = *next == '\\';
/* Returns true if REGNUM is in one of COMPILE_STACK's elements and
* false if it's not. */
-static boolean
-group_in_compile_stack(compile_stack, regnum)
- compile_stack_type compile_stack;
- regnum_t regnum;
+boolean
+group_in_compile_stack(compile_stack_type compile_stack, regnum_t regnum)
{
int this_element;
* We use these short variable names so we can use the same macros as
* `regex_compile' itself. */
-static reg_errcode_t
-compile_range(p_ptr, pend, translate, syntax, b)
- const char **p_ptr, *pend;
- char *translate;
- reg_syntax_t syntax;
- unsigned char *b;
+reg_errcode_t
+compile_range(const char **p_ptr, const char *pend, char *translate, reg_syntax_t syntax, unsigned char *b)
{
unsigned this_char;
\f
/* Declarations and macros for re_match_2. */
-static int bcmp_translate();
-static boolean alt_match_null_string_p(), common_op_match_null_string_p(),
- group_match_null_string_p();
+static boolean group_match_null_string_p();
/* Structure for per-register (a.k.a. per-group) information.
* This must not be longer than one word, because we push this value
unsigned ever_matched_something:1;
} bits;
} register_info_type;
+static boolean alt_match_null_string_p(unsigned char *p, unsigned char *end, register_info_type *reg_info);
+static boolean common_op_match_null_string_p( unsigned char **p, unsigned char *end, register_info_type *reg_info);
+static int bcmp_translate(unsigned char const *s1, unsigned char const *s2, register int len, char *translate);
#define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p)
#define IS_ACTIVE(R) ((R).bits.is_active)
} /* re_match_2 */
\f
/* Subroutine definitions for re_match_2. */
+static boolean group_match_null_string_p(unsigned char **p, unsigned char *end, register_info_type *reg_info);
/* We are passed P pointing to a register number after a start_memory.
*
* 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;
+boolean
+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. */
* It expects P to be the first byte of a single alternative and END one
* 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;
+boolean
+alt_match_null_string_p(unsigned char *p, unsigned char *end, register_info_type *reg_info)
{
int mcnt;
unsigned char *p1 = p;
*
* 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;
+boolean
+common_op_match_null_string_p( unsigned char **p, unsigned char *end, register_info_type *reg_info)
{
int mcnt;
boolean ret;
/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
* bytes; nonzero otherwise. */
-static int
-bcmp_translate(s1, s2, len, translate)
- unsigned char *s1, *s2;
- register int len;
- char *translate;
+int
+bcmp_translate(unsigned char const *s1, unsigned char const*s2, register int len, char *translate)
{
- register unsigned char *p1 = s1, *p2 = s2;
+ register unsigned char const *p1 = s1, *p2 = s2;
while (len) {
if (translate[*p1++] != translate[*p2++])
return 1;