summaryrefslogtreecommitdiff
path: root/libc/misc/regex
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-10-09 20:06:30 +0000
committerEric Andersen <andersen@codepoet.org>2000-10-09 20:06:30 +0000
commitc1fe19d4c1db610692365472a90f4661e48449c1 (patch)
treed0b0219ffca3c4c4256f55c4aea4513e43d6aecd /libc/misc/regex
parent9efafb8bbc7408b04643dcd53825d971577b4d9d (diff)
Bug ugly formatting update
Diffstat (limited to 'libc/misc/regex')
-rw-r--r--libc/misc/regex/.indent.pro33
-rw-r--r--libc/misc/regex/Makefile11
-rw-r--r--libc/misc/regex/rx.c11347
3 files changed, 5582 insertions, 5809 deletions
diff --git a/libc/misc/regex/.indent.pro b/libc/misc/regex/.indent.pro
new file mode 100644
index 000000000..492ecf1c7
--- /dev/null
+++ b/libc/misc/regex/.indent.pro
@@ -0,0 +1,33 @@
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--break-before-boolean-operator
+--no-blank-lines-after-commas
+--braces-on-if-line
+--braces-on-struct-decl-line
+--comment-indentation25
+--declaration-comment-column25
+--no-comment-delimiters-on-blank-lines
+--cuddle-else
+--continuation-indentation4
+--case-indentation0
+--else-endif-column33
+--space-after-cast
+--line-comments-indentation0
+--declaration-indentation1
+--dont-format-first-column-comments
+--dont-format-comments
+--honour-newlines
+--indent-level4
+/* changed from 0 to 4 */
+--parameter-indentation4
+--line-length78 /* changed from 75 */
+--continue-at-parentheses
+--no-space-after-function-call-names
+--dont-break-procedure-type
+--dont-star-comments
+--leave-optional-blank-lines
+--dont-space-special-semicolon
+--tab-size4
+/* additions by Mark */
+--case-brace-indentation0
+--leave-preprocessor-space
diff --git a/libc/misc/regex/Makefile b/libc/misc/regex/Makefile
index b8b38faa9..006ea75cc 100644
--- a/libc/misc/regex/Makefile
+++ b/libc/misc/regex/Makefile
@@ -26,13 +26,16 @@ LIBC=$(TOPDIR)libc.a
CSRC=rx.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
+OBJS=$(COBJS)
-all: $(COBJS) $(LIBC)
+all: $(OBJS) $(LIBC)
-$(LIBC): $(COBJS)
- $(AR) $(ARFLAGS) $(LIBC) $(COBJS)
+$(LIBC): ar-target
-$(COBJS): Makefile
+ar-target: $(OBJS)
+ $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
+
+$(OBJS): Makefile
clean:
rm -f *.[oa] *~ core
diff --git a/libc/misc/regex/rx.c b/libc/misc/regex/rx.c
index 1abff8cc5..39f77adb6 100644
--- a/libc/misc/regex/rx.c
+++ b/libc/misc/regex/rx.c
@@ -22,7 +22,7 @@ write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA
* Do not put ANYTHING before it!
*/
#if !defined (__GNUC__) && defined (_AIX)
- #pragma alloca
+#pragma alloca
#endif
/* To make linux happy? */
@@ -50,6 +50,7 @@ write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA
#define MIN(a, b) ((a) < (b) ? (a) : (b))
typedef char boolean;
+
#define false 0
#define true 1
@@ -64,17 +65,17 @@ typedef char boolean;
/* Make alloca work the best possible way. */
#ifdef __GNUC__
#define alloca __builtin_alloca
-#else /* not __GNUC__ */
+#else /* not __GNUC__ */
#if HAVE_ALLOCA_H
#include <alloca.h>
-#else /* not __GNUC__ or HAVE_ALLOCA_H */
-#ifndef _AIX /* Already did AIX, up at the top. */
-char *alloca ();
-#endif /* not _AIX */
-#endif /* not HAVE_ALLOCA_H */
-#endif /* not __GNUC__ */
+#else /* not __GNUC__ or HAVE_ALLOCA_H */
+#ifndef _AIX /* Already did AIX, up at the top. */
+char *alloca();
+#endif /* not _AIX */
+#endif /* not HAVE_ALLOCA_H */
+#endif /* not __GNUC__ */
-#endif /* not alloca */
+#endif /* not alloca */
/* Memory management and stuff for emacs. */
@@ -90,14 +91,14 @@ char *alloca ();
#ifdef REGEX_MALLOC
#define REGEX_ALLOCATE malloc
-#else /* not REGEX_MALLOC */
+#else /* not REGEX_MALLOC */
#define REGEX_ALLOCATE alloca
-#endif /* not REGEX_MALLOC */
+#endif /* not REGEX_MALLOC */
#ifdef RX_WANT_RX_DEFS
#define RX_DECL extern
-#define RX_DEF_QUAL
+#define RX_DEF_QUAL
#else
#define RX_WANT_RX_DEFS
#define RX_DECL static
@@ -114,137 +115,132 @@ char *alloca ();
*/
#ifdef __STDC__
RX_DECL struct rx_hash_item
- *rx_hash_find (struct rx_hash *, unsigned long,
- void *, struct rx_hash_rules *);
+*rx_hash_find(struct rx_hash *, unsigned long,
+
+ void *, struct rx_hash_rules *);
RX_DECL struct rx_hash_item
- *rx_hash_find (struct rx_hash *, unsigned long,
- void *, struct rx_hash_rules *);
+*rx_hash_find(struct rx_hash *, unsigned long,
+
+ void *, struct rx_hash_rules *);
RX_DECL struct rx_hash_item
- *rx_hash_store (struct rx_hash *, unsigned long,
- void *, struct rx_hash_rules *);
-RX_DECL void rx_hash_free (struct rx_hash_item *,
- struct rx_hash_rules *);
-RX_DECL void rx_free_hash_table (struct rx_hash *, rx_hash_freefn,
- struct rx_hash_rules *);
-RX_DECL rx_Bitset
- rx_cset (struct rx *);
-RX_DECL rx_Bitset
- rx_copy_cset (struct rx *, rx_Bitset);
-RX_DECL void rx_free_cset (struct rx *, rx_Bitset);
+*rx_hash_store(struct rx_hash *, unsigned long,
+
+ void *, struct rx_hash_rules *);
+RX_DECL void rx_hash_free(struct rx_hash_item *, struct rx_hash_rules *);
+RX_DECL void rx_free_hash_table(struct rx_hash *, rx_hash_freefn,
+
+ struct rx_hash_rules *);
+RX_DECL rx_Bitset rx_cset(struct rx *);
+RX_DECL rx_Bitset rx_copy_cset(struct rx *, rx_Bitset);
+RX_DECL void rx_free_cset(struct rx *, rx_Bitset);
static struct rx_hash_item
- *compiler_hash_item_alloc (struct rx_hash_rules *, void *);
+*compiler_hash_item_alloc(struct rx_hash_rules *, void *);
static struct rx_hash
- *compiler_hash_alloc (struct rx_hash_rules *);
-static void compiler_free_hash (struct rx_hash *,
- struct rx_hash_rules *);
-static void compiler_free_hash_item (struct rx_hash_item *,
- struct rx_hash_rules *);
+*compiler_hash_alloc(struct rx_hash_rules *);
+static void compiler_free_hash(struct rx_hash *, struct rx_hash_rules *);
+static void compiler_free_hash_item(struct rx_hash_item *,
+
+ struct rx_hash_rules *);
RX_DECL struct rexp_node
- *rexp_node (struct rx *, enum rexp_node_type);
+*rexp_node(struct rx *, enum rexp_node_type);
RX_DECL struct rexp_node
- *rx_mk_r_cset (struct rx *, rx_Bitset);
+*rx_mk_r_cset(struct rx *, rx_Bitset);
RX_DECL struct rexp_node
- *rx_mk_r_concat (struct rx *, struct rexp_node *,
- struct rexp_node *);
+*rx_mk_r_concat(struct rx *, struct rexp_node *, struct rexp_node *);
RX_DECL struct rexp_node
- *rx_mk_r_alternate (struct rx *, struct rexp_node *,
- struct rexp_node *);
+*rx_mk_r_alternate(struct rx *, struct rexp_node *, struct rexp_node *);
RX_DECL struct rexp_node
- *rx_mk_r_alternate (struct rx *, struct rexp_node *,
- struct rexp_node *);
+*rx_mk_r_alternate(struct rx *, struct rexp_node *, struct rexp_node *);
RX_DECL struct rexp_node
- *rx_mk_r_opt (struct rx *, struct rexp_node *);
+*rx_mk_r_opt(struct rx *, struct rexp_node *);
RX_DECL struct rexp_node
- *rx_mk_r_star (struct rx *, struct rexp_node *);
+*rx_mk_r_star(struct rx *, struct rexp_node *);
RX_DECL struct rexp_node
- *rx_mk_r_2phase_star (struct rx *, struct rexp_node *,
- struct rexp_node *);
+*rx_mk_r_2phase_star(struct rx *, struct rexp_node *, struct rexp_node *);
RX_DECL struct rexp_node
- *rx_mk_r_side_effect (struct rx *, rx_side_effect);
+*rx_mk_r_side_effect(struct rx *, rx_side_effect);
+
//RX_DECL struct rexp_node
// *rx_mk_r_data (struct rx *, void *);
-RX_DECL void rx_free_rexp (struct rx *, struct rexp_node *);
+RX_DECL void rx_free_rexp(struct rx *, struct rexp_node *);
RX_DECL struct rexp_node
- *rx_copy_rexp (struct rx *, struct rexp_node *);
+*rx_copy_rexp(struct rx *, struct rexp_node *);
RX_DECL struct rx_nfa_state
- *rx_nfa_state (struct rx *);
-RX_DECL void rx_free_nfa_state (struct rx_nfa_state *);
+*rx_nfa_state(struct rx *);
+RX_DECL void rx_free_nfa_state(struct rx_nfa_state *);
RX_DECL struct rx_nfa_state
- *rx_id_to_nfa_state (struct rx *, int);
+*rx_id_to_nfa_state(struct rx *, int);
RX_DECL struct rx_nfa_edge
- *rx_nfa_edge (struct rx *, enum rx_nfa_etype,
- struct rx_nfa_state *,
- struct rx_nfa_state *);
-RX_DECL void rx_free_nfa_edge (struct rx_nfa_edge *);
+*rx_nfa_edge(struct rx *, enum rx_nfa_etype,
+
+ struct rx_nfa_state *, struct rx_nfa_state *);
+RX_DECL void rx_free_nfa_edge(struct rx_nfa_edge *);
static struct rx_possible_future
- *rx_possible_future (struct rx *, struct rx_se_list *);
-static void rx_free_possible_future (struct rx_possible_future *);
-RX_DECL void rx_free_nfa (struct rx *);
-RX_DECL int rx_build_nfa (struct rx *, struct rexp_node *,
- struct rx_nfa_state **,
- struct rx_nfa_state **);
-RX_DECL void rx_name_nfa_states (struct rx *);
-static int se_list_cmp (void *, void *);
-static int se_list_equal (void *, void *);
+*rx_possible_future(struct rx *, struct rx_se_list *);
+static void rx_free_possible_future(struct rx_possible_future *);
+RX_DECL void rx_free_nfa(struct rx *);
+RX_DECL int rx_build_nfa(struct rx *, struct rexp_node *,
+ struct rx_nfa_state **, struct rx_nfa_state **);
+RX_DECL void rx_name_nfa_states(struct rx *);
+static int se_list_cmp(void *, void *);
+static int se_list_equal(void *, void *);
static struct rx_se_list
- *hash_cons_se_prog (struct rx *, struct rx_hash *,
- void *, struct rx_se_list *);
+*hash_cons_se_prog(struct rx *, struct rx_hash *,
+
+ void *, struct rx_se_list *);
static struct rx_se_list
- *hash_se_prog (struct rx *, struct rx_hash *,
- struct rx_se_list *);
-static int nfa_set_cmp (void *, void *);
-static int nfa_set_equal (void *, void *);
+*hash_se_prog(struct rx *, struct rx_hash *, struct rx_se_list *);
+static int nfa_set_cmp(void *, void *);
+static int nfa_set_equal(void *, void *);
static struct rx_nfa_state_set
- *nfa_set_cons (struct rx *, struct rx_hash *,
- struct rx_nfa_state *,
- struct rx_nfa_state_set *);
+*nfa_set_cons(struct rx *, struct rx_hash *,
+
+ struct rx_nfa_state *, struct rx_nfa_state_set *);
static struct rx_nfa_state_set
- *nfa_set_enjoin (struct rx *, struct rx_hash *,
- struct rx_nfa_state *,
- struct rx_nfa_state_set *);
+*nfa_set_enjoin(struct rx *, struct rx_hash *,
+
+ struct rx_nfa_state *, struct rx_nfa_state_set *);
#endif
#ifndef emacs
#ifdef SYNTAX_TABLE
extern char *re_syntax_table;
-#else /* not SYNTAX_TABLE */
+#else /* not SYNTAX_TABLE */
#ifndef RX_WANT_RX_DEFS
RX_DECL char re_syntax_table[CHAR_SET_SIZE];
#endif
#ifdef __STDC__
-static void
-init_syntax_once (void)
+static void init_syntax_once(void)
#else
-static void
-init_syntax_once ()
+static void init_syntax_once()
#endif
{
- register int c;
- static int done = 0;
+ register int c;
+ static int done = 0;
- if (done)
- return;
+ if (done)
+ return;
- bzero (re_syntax_table, sizeof re_syntax_table);
+ bzero(re_syntax_table, sizeof re_syntax_table);
- for (c = 'a'; c <= 'z'; c++)
- re_syntax_table[c] = Sword;
+ for (c = 'a'; c <= 'z'; c++)
+ re_syntax_table[c] = Sword;
- for (c = 'A'; c <= 'Z'; c++)
- re_syntax_table[c] = Sword;
+ for (c = 'A'; c <= 'Z'; c++)
+ re_syntax_table[c] = Sword;
- for (c = '0'; c <= '9'; c++)
- re_syntax_table[c] = Sword;
+ for (c = '0'; c <= '9'; c++)
+ re_syntax_table[c] = Sword;
- re_syntax_table['_'] = Sword;
+ re_syntax_table['_'] = Sword;
- done = 1;
+ done = 1;
}
-#endif /* not SYNTAX_TABLE */
-#endif /* not emacs */
+#endif /* not SYNTAX_TABLE */
+#endif /* not emacs */
/* Compile with `-DRX_DEBUG' and use the following flags.
*
@@ -257,7 +253,7 @@ init_syntax_once ()
int rx_debug_compile = 0;
int rx_debug_trace = 0;
-static struct re_pattern_buffer * dbug_rxb = 0;
+static struct re_pattern_buffer *dbug_rxb = 0;
/*
@@ -265,903 +261,845 @@ static struct re_pattern_buffer * dbug_rxb = 0;
*/
#ifdef __STDC__
typedef void (*side_effect_printer) (struct rx *, void *, FILE *);
-static void print_cset (struct rx *, rx_Bitset, FILE *);
-static void print_rexp (struct rx *, struct rexp_node *, int,
- side_effect_printer, FILE *);
-static void print_nfa (struct rx *, struct rx_nfa_state *,
- side_effect_printer, FILE *);
-static void re_seprint (struct rx *, void *, FILE *);
-void print_compiled_pattern (struct re_pattern_buffer *);
-void print_fastmap (char *);
+static void print_cset(struct rx *, rx_Bitset, FILE *);
+static void print_rexp(struct rx *, struct rexp_node *, int,
+ side_effect_printer, FILE *);
+static void print_nfa(struct rx *, struct rx_nfa_state *,
+ side_effect_printer, FILE *);
+static void re_seprint(struct rx *, void *, FILE *);
+void print_compiled_pattern(struct re_pattern_buffer *);
+void print_fastmap(char *);
#else
typedef void (*side_effect_printer) ();
-static void print_cset ();
+static void print_cset();
#endif
#ifdef __STDC__
static void
-print_rexp (struct rx *rx,
- struct rexp_node *node, int depth,
- side_effect_printer seprint, FILE * fp)
-#else
-static void
-print_rexp (rx, node, depth, seprint, fp)
- struct rx *rx;
- struct rexp_node *node;
- int depth;
- side_effect_printer seprint;
- FILE * fp;
-#endif
-{
- if (!node)
- return;
- else
- {
- switch (node->type)
- {
- case r_cset:
- {
- fprintf (fp, "%*s", depth, "");
- print_cset (rx, node->params.cset, fp);
- fputc ('\n', fp);
- break;
- }
-
- case r_opt:
- case r_star:
- fprintf (fp, "%*s%s\n", depth, "",
- node->type == r_opt ? "opt" : "star");
- print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp);
- break;
-
- case r_2phase_star:
- fprintf (fp, "%*s2phase star\n", depth, "");
- print_rexp (rx, node->params.pair.right, depth + 3, seprint, fp);
- print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp);
- break;
-
+print_rexp(struct rx *rx,
+ struct rexp_node *node, int depth,
+ side_effect_printer seprint, FILE * fp)
+#else
+static void print_rexp(rx, node, depth, seprint, fp)
+struct rx *rx;
+struct rexp_node *node;
+int depth;
+side_effect_printer seprint;
+FILE *fp;
+#endif
+{
+ if (!node)
+ return;
+ else {
+ switch (node->type) {
+ case r_cset:
+ {
+ fprintf(fp, "%*s", depth, "");
+ print_cset(rx, node->params.cset, fp);
+ fputc('\n', fp);
+ break;
+ }
- case r_alternate:
- case r_concat:
- fprintf (fp, "%*s%s\n", depth, "",
- node->type == r_alternate ? "alt" : "concat");
- print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp);
- print_rexp (rx, node->params.pair.right, depth + 3, seprint, fp);
- break;
- case r_side_effect:
- fprintf (fp, "%*sSide effect: ", depth, "");
- seprint (rx, node->params.side_effect, fp);
- fputc ('\n', fp);
+ case r_opt:
+ case r_star:
+ fprintf(fp, "%*s%s\n", depth, "",
+ node->type == r_opt ? "opt" : "star");
+ print_rexp(rx, node->params.pair.left, depth + 3, seprint, fp);
+ break;
+
+ case r_2phase_star:
+ fprintf(fp, "%*s2phase star\n", depth, "");
+ print_rexp(rx, node->params.pair.right, depth + 3, seprint,
+ fp);
+ print_rexp(rx, node->params.pair.left, depth + 3, seprint, fp);
+ break;
+
+
+ case r_alternate:
+ case r_concat:
+ fprintf(fp, "%*s%s\n", depth, "",
+ node->type == r_alternate ? "alt" : "concat");
+ print_rexp(rx, node->params.pair.left, depth + 3, seprint, fp);
+ print_rexp(rx, node->params.pair.right, depth + 3, seprint,
+ fp);
+ break;
+ case r_side_effect:
+ fprintf(fp, "%*sSide effect: ", depth, "");
+ seprint(rx, node->params.side_effect, fp);
+ fputc('\n', fp);
+ }
}
- }
}
#ifdef __STDC__
static void
-print_nfa (struct rx * rx,
- struct rx_nfa_state * n,
- side_effect_printer seprint, FILE * fp)
-#else
-static void
-print_nfa (rx, n, seprint, fp)
- struct rx * rx;
- struct rx_nfa_state * n;
- side_effect_printer seprint;
- FILE * fp;
-#endif
-{
- while (n)
- {
- struct rx_nfa_edge *e = n->edges;
- struct rx_possible_future *ec = n->futures;
- fprintf (fp, "node %d %s\n", n->id,
- n->is_final ? "final" : (n->is_start ? "start" : ""));
- while (e)
- {
- fprintf (fp, " edge to %d, ", e->dest->id);
- switch (e->type)
- {
- case ne_epsilon:
- fprintf (fp, "epsilon\n");
- break;
- case ne_side_effect:
- fprintf (fp, "side effect ");
- seprint (rx, e->params.side_effect, fp);
- fputc ('\n', fp);
- break;
- case ne_cset:
- fprintf (fp, "cset ");
- print_cset (rx, e->params.cset, fp);
- fputc ('\n', fp);
- break;
- }
- e = e->next;
- }
+print_nfa(struct rx *rx,
+ struct rx_nfa_state *n, side_effect_printer seprint, FILE * fp)
+#else
+static void print_nfa(rx, n, seprint, fp)
+struct rx *rx;
+struct rx_nfa_state *n;
+side_effect_printer seprint;
+FILE *fp;
+#endif
+{
+ while (n) {
+ struct rx_nfa_edge *e = n->edges;
+ struct rx_possible_future *ec = n->futures;
+
+ fprintf(fp, "node %d %s\n", n->id,
+ n->is_final ? "final" : (n->is_start ? "start" : ""));
+ while (e) {
+ fprintf(fp, " edge to %d, ", e->dest->id);
+ switch (e->type) {
+ case ne_epsilon:
+ fprintf(fp, "epsilon\n");
+ break;
+ case ne_side_effect:
+ fprintf(fp, "side effect ");
+ seprint(rx, e->params.side_effect, fp);
+ fputc('\n', fp);
+ break;
+ case ne_cset:
+ fprintf(fp, "cset ");
+ print_cset(rx, e->params.cset, fp);
+ fputc('\n', fp);
+ break;
+ }
+ e = e->next;
+ }
- while (ec)
- {
- int x;
- struct rx_nfa_state_set * s;
- struct rx_se_list * l;
- fprintf (fp, " eclosure to {");
- for (s = ec->destset; s; s = s->cdr)
- fprintf (fp, "%d ", s->car->id);
- fprintf (fp, "} (");
- for (l = ec->effects; l; l = l->cdr)
- {
- seprint (rx, l->car, fp);
- fputc (' ', fp);
- }
- fprintf (fp, ")\n");
- ec = ec->next;
+ while (ec) {
+ int x;
+ struct rx_nfa_state_set *s;
+ struct rx_se_list *l;
+
+ fprintf(fp, " eclosure to {");
+ for (s = ec->destset; s; s = s->cdr)
+ fprintf(fp, "%d ", s->car->id);
+ fprintf(fp, "} (");
+ for (l = ec->effects; l; l = l->cdr) {
+ seprint(rx, l->car, fp);
+ fputc(' ', fp);
+ }
+ fprintf(fp, ")\n");
+ ec = ec->next;
+ }
+ n = n->next;
}
- n = n->next;
- }
}
-static char * efnames [] =
-{
- "bogon",
- "re_se_try",
- "re_se_pushback",
- "re_se_push0",
- "re_se_pushpos",
- "re_se_chkpos",
- "re_se_poppos",
- "re_se_at_dot",
- "re_se_syntax",
- "re_se_not_syntax",
- "re_se_begbuf",
- "re_se_hat",
- "re_se_wordbeg",
- "re_se_wordbound",
- "re_se_notwordbound",
- "re_se_wordend",
- "re_se_endbuf",
- "re_se_dollar",
- "re_se_fail",
+static char *efnames[] = {
+ "bogon",
+ "re_se_try",
+ "re_se_pushback",
+ "re_se_push0",
+ "re_se_pushpos",
+ "re_se_chkpos",
+ "re_se_poppos",
+ "re_se_at_dot",
+ "re_se_syntax",
+ "re_se_not_syntax",
+ "re_se_begbuf",
+ "re_se_hat",
+ "re_se_wordbeg",
+ "re_se_wordbound",
+ "re_se_notwordbound",
+ "re_se_wordend",
+ "re_se_endbuf",
+ "re_se_dollar",
+ "re_se_fail",
};
-static char * efnames2[] =
-{
- "re_se_win",
- "re_se_lparen",
- "re_se_rparen",
- "re_se_backref",
- "re_se_iter",
- "re_se_end_iter",
- "re_se_tv"
+static char *efnames2[] = {
+ "re_se_win",
+ "re_se_lparen",
+ "re_se_rparen",
+ "re_se_backref",
+ "re_se_iter",
+ "re_se_end_iter",
+ "re_se_tv"
};
-static char * inx_names[] =
-{
- "rx_backtrack_point",
- "rx_do_side_effects",
- "rx_cache_miss",
- "rx_next_char",
- "rx_backtrack",
- "rx_error_inx",
- "rx_num_instructions"
+static char *inx_names[] = {
+ "rx_backtrack_point",
+ "rx_do_side_effects",
+ "rx_cache_miss",
+ "rx_next_char",
+ "rx_backtrack",
+ "rx_error_inx",
+ "rx_num_instructions"
};
#ifdef __STDC__
-static void
-re_seprint (struct rx * rx, void * effect, FILE * fp)
+static void re_seprint(struct rx *rx, void *effect, FILE * fp)
#else
-static void
-re_seprint (rx, effect, fp)
- struct rx * rx;
- void * effect;
- FILE * fp;
-#endif
-{
- if ((int)effect < 0)
- fputs (efnames[-(int)effect], fp);
- else if (dbug_rxb)
- {
- struct re_se_params * p = &dbug_rxb->se_params[(int)effect];
- fprintf (fp, "%s(%d,%d)", efnames2[p->se], p->op1, p->op2);
- }
- else
- fprintf (fp, "[complex op # %d]", (int)effect);
+static void re_seprint(rx, effect, fp)
+struct rx *rx;
+void *effect;
+FILE *fp;
+#endif
+{
+ if ((int) effect < 0)
+ fputs(efnames[-(int) effect], fp);
+ else if (dbug_rxb) {
+ struct re_se_params *p = &dbug_rxb->se_params[(int) effect];
+
+ fprintf(fp, "%s(%d,%d)", efnames2[p->se], p->op1, p->op2);
+ } else
+ fprintf(fp, "[complex op # %d]", (int) effect);
}
/* These are so the regex.c regression tests will compile. */
-void
-print_compiled_pattern (rxb)
- struct re_pattern_buffer * rxb;
+void print_compiled_pattern(rxb)
+struct re_pattern_buffer *rxb;
{
}
-void
-print_fastmap (fm)
- char * fm;
+void print_fastmap(fm)
+char *fm;
{
}
-#endif /* RX_DEBUG */
-
+#endif /* RX_DEBUG */
+
/* This page: Bitsets. Completely unintersting. */
//RX_DECL int rx_bitset_is_equal (int, rx_Bitset, rx_Bitset);
-RX_DECL int rx_bitset_is_subset (int, rx_Bitset, rx_Bitset);
+RX_DECL int rx_bitset_is_subset(int, rx_Bitset, rx_Bitset);
+
//RX_DECL int rx_bitset_empty (int, rx_Bitset);
-RX_DECL void rx_bitset_null (int, rx_Bitset);
-RX_DECL void rx_bitset_complement (int, rx_Bitset);
-RX_DECL void rx_bitset_complement (int, rx_Bitset);
-RX_DECL void rx_bitset_assign (int, rx_Bitset, rx_Bitset);
-RX_DECL void rx_bitset_union (int, rx_Bitset, rx_Bitset);
-RX_DECL void rx_bitset_intersection (int, rx_Bitset, rx_Bitset);
-RX_DECL void rx_bitset_difference (int, rx_Bitset, rx_Bitset);
+RX_DECL void rx_bitset_null(int, rx_Bitset);
+RX_DECL void rx_bitset_complement(int, rx_Bitset);
+RX_DECL void rx_bitset_complement(int, rx_Bitset);
+RX_DECL void rx_bitset_assign(int, rx_Bitset, rx_Bitset);
+RX_DECL void rx_bitset_union(int, rx_Bitset, rx_Bitset);
+RX_DECL void rx_bitset_intersection(int, rx_Bitset, rx_Bitset);
+RX_DECL void rx_bitset_difference(int, rx_Bitset, rx_Bitset);
+
//RX_DECL void rx_bitset_revdifference (int, rx_Bitset, rx_Bitset);
#ifdef emacs
-RX_DECL void rx_bitset_xor (int, rx_Bitset, rx_Bitset);
+RX_DECL void rx_bitset_xor(int, rx_Bitset, rx_Bitset);
#endif
-RX_DECL unsigned long
- rx_bitset_hash (int, rx_Bitset);
+RX_DECL unsigned long rx_bitset_hash(int, rx_Bitset);
#if 0
#ifdef __STDC__
-RX_DECL int
-rx_bitset_is_equal (int size, rx_Bitset a, rx_Bitset b)
+RX_DECL int rx_bitset_is_equal(int size, rx_Bitset a, rx_Bitset b)
#else
-RX_DECL int
-rx_bitset_is_equal (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
+RX_DECL int rx_bitset_is_equal(size, a, b)
+int size;
+rx_Bitset a;
+rx_Bitset b;
#endif
{
- int x;
- RX_subset s = b[0];
- b[0] = ~a[0];
+ int x;
+ RX_subset s = b[0];
+
+ b[0] = ~a[0];
- for (x = rx_bitset_numb_subsets(size) - 1; a[x] == b[x]; --x)
- ;
+ for (x = rx_bitset_numb_subsets(size) - 1; a[x] == b[x]; --x);
- b[0] = s;
- return !x && s == a[0];
+ b[0] = s;
+ return !x && s == a[0];
}
#endif
#ifdef __STDC__
-RX_DECL int
-rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b)
+RX_DECL int rx_bitset_is_subset(int size, rx_Bitset a, rx_Bitset b)
#else
-RX_DECL int
-rx_bitset_is_subset (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
+RX_DECL int rx_bitset_is_subset(size, a, b)
+int size;
+rx_Bitset a;
+rx_Bitset b;
#endif
{
- int x = rx_bitset_numb_subsets(size) - 1;
- while (x-- && (a[x] & b[x]) == a[x]);
- return x == -1;
+ int x = rx_bitset_numb_subsets(size) - 1;
+
+ while (x-- && (a[x] & b[x]) == a[x]);
+ return x == -1;
}
#if 0
#ifdef __STDC__
-RX_DECL int
-rx_bitset_empty (int size, rx_Bitset set)
+RX_DECL int rx_bitset_empty(int size, rx_Bitset set)
#else
-RX_DECL int
-rx_bitset_empty (size, set)
- int size;
- rx_Bitset set;
+RX_DECL int rx_bitset_empty(size, set)
+int size;
+rx_Bitset set;
#endif
{
- int x;
- RX_subset s = set[0];
- set[0] = 1;
- for (x = rx_bitset_numb_subsets(size) - 1; !set[x]; --x)
- ;
- set[0] = s;
- return !s;
+ int x;
+ RX_subset s = set[0];
+
+ set[0] = 1;
+ for (x = rx_bitset_numb_subsets(size) - 1; !set[x]; --x);
+ set[0] = s;
+ return !s;
}
#endif
#ifdef __STDC__
-RX_DECL void
-rx_bitset_null (int size, rx_Bitset b)
+RX_DECL void rx_bitset_null(int size, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_null (size, b)
- int size;
- rx_Bitset b;
+RX_DECL void rx_bitset_null(size, b)
+int size;
+rx_Bitset b;
#endif
{
- bzero (b, rx_sizeof_bitset(size));
+ bzero(b, rx_sizeof_bitset(size));
}
#ifdef __STDC__
-RX_DECL void
-rx_bitset_universe (int size, rx_Bitset b)
+RX_DECL void rx_bitset_universe(int size, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_universe (size, b)
- int size;
- rx_Bitset b;
+RX_DECL void rx_bitset_universe(size, b)
+int size;
+rx_Bitset b;
#endif
{
- int x = rx_bitset_numb_subsets (size);
- while (x--)
- *b++ = ~(RX_subset)0;
+ int x = rx_bitset_numb_subsets(size);
+
+ while (x--)
+ *b++ = ~(RX_subset) 0;
}
#ifdef __STDC__
-RX_DECL void
-rx_bitset_complement (int size, rx_Bitset b)
+RX_DECL void rx_bitset_complement(int size, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_complement (size, b)
- int size;
- rx_Bitset b;
+RX_DECL void rx_bitset_complement(size, b)
+int size;
+rx_Bitset b;
#endif
{
- int x = rx_bitset_numb_subsets (size);
- while (x--)
- {
- *b = ~*b;
- ++b;
- }
+ int x = rx_bitset_numb_subsets(size);
+
+ while (x--) {
+ *b = ~*b;
+ ++b;
+ }
}
#ifdef __STDC__
-RX_DECL void
-rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b)
+RX_DECL void rx_bitset_assign(int size, rx_Bitset a, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_assign (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
+RX_DECL void rx_bitset_assign(size, a, b)
+int size;
+rx_Bitset a;
+rx_Bitset b;
#endif
{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] = b[x];
+ int x;
+
+ for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
+ a[x] = b[x];
}
#ifdef __STDC__
-RX_DECL void
-rx_bitset_union (int size, rx_Bitset a, rx_Bitset b)
+RX_DECL void rx_bitset_union(int size, rx_Bitset a, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_union (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
+RX_DECL void rx_bitset_union(size, a, b)
+int size;
+rx_Bitset a;
+rx_Bitset b;
#endif
{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] |= b[x];
+ int x;
+
+ for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
+ a[x] |= b[x];
}
#ifdef __STDC__
-RX_DECL void
-rx_bitset_intersection (int size,
- rx_Bitset a, rx_Bitset b)
+RX_DECL void rx_bitset_intersection(int size, rx_Bitset a, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_intersection (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
+RX_DECL void rx_bitset_intersection(size, a, b)
+int size;
+rx_Bitset a;
+rx_Bitset b;
#endif
{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] &= b[x];
+ int x;
+
+ for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
+ a[x] &= b[x];
}
#ifdef __STDC__
-RX_DECL void
-rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b)
+RX_DECL void rx_bitset_difference(int size, rx_Bitset a, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_difference (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
+RX_DECL void rx_bitset_difference(size, a, b)
+int size;
+rx_Bitset a;
+rx_Bitset b;
#endif
{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] &= ~ b[x];
+ int x;
+
+ for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
+ a[x] &= ~b[x];
}
#if 0
#ifdef __STDC__
-RX_DECL void
-rx_bitset_revdifference (int size,
- rx_Bitset a, rx_Bitset b)
+RX_DECL void rx_bitset_revdifference(int size, rx_Bitset a, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_revdifference (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
+RX_DECL void rx_bitset_revdifference(size, a, b)
+int size;
+rx_Bitset a;
+rx_Bitset b;
#endif
{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] = ~a[x] & b[x];
+ int x;
+
+ for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
+ a[x] = ~a[x] & b[x];
}
#endif
#ifdef emacs
#ifdef __STDC__
-RX_DECL void
-rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b)
+RX_DECL void rx_bitset_xor(int size, rx_Bitset a, rx_Bitset b)
#else
-RX_DECL void
-rx_bitset_xor (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] ^= b[x];
-}
-#endif
-
-
-#ifdef __STDC__
-RX_DECL unsigned long
-rx_bitset_hash (int size, rx_Bitset b)
-#else
-RX_DECL unsigned long
-rx_bitset_hash (size, b)
- int size;
- rx_Bitset b;
-#endif
-{
- int x;
- unsigned long hash = (unsigned long)rx_bitset_hash;
-
- for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
- hash ^= rx_bitset_subset_val(b, x);
-
- return hash;
-}
-
-RX_DECL RX_subset rx_subset_singletons [RX_subset_bits] =
-{
- 0x1,
- 0x2,
- 0x4,
- 0x8,
- 0x10,
- 0x20,
- 0x40,
- 0x80,
- 0x100,
- 0x200,
- 0x400,
- 0x800,
- 0x1000,
- 0x2000,
- 0x4000,
- 0x8000,
- 0x10000,
- 0x20000,
- 0x40000,
- 0x80000,
- 0x100000,
- 0x200000,
- 0x400000,
- 0x800000,
- 0x1000000,
- 0x2000000,
- 0x4000000,
- 0x8000000,
- 0x10000000,
- 0x20000000,
- 0x40000000,
- 0x80000000
+RX_DECL void rx_bitset_xor(size, a, b)
+int size;
+rx_Bitset a;
+rx_Bitset b;
+#endif
+{
+ int x;
+
+ for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
+ a[x] ^= b[x];
+}
+#endif
+
+
+#ifdef __STDC__
+RX_DECL unsigned long rx_bitset_hash(int size, rx_Bitset b)
+#else
+RX_DECL unsigned long rx_bitset_hash(size, b)
+int size;
+rx_Bitset b;
+#endif
+{
+ int x;
+ unsigned long hash = (unsigned long) rx_bitset_hash;
+
+ for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
+ hash ^= rx_bitset_subset_val(b, x);
+
+ return hash;
+}
+
+RX_DECL RX_subset rx_subset_singletons[RX_subset_bits] = {
+ 0x1,
+ 0x2,
+ 0x4,
+ 0x8,
+ 0x10,
+ 0x20,