summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/regex.c b/regex.c
index 154a5df..02a58fa 100644
--- a/regex.c
+++ b/regex.c
@@ -61,21 +61,12 @@ static void print_literal(const char *s)
static int get_precedence(const struct atom *a)
{
- const struct repeat *r;
-
- switch (a->type) {
- case ATOM_LITERAL:
+ if (a->type == ATOM_LITERAL) {
switch (strlen(a->u.literal)) {
case 0: return -1;
case 1: return precedence[ATOM_EVERYTHING];
default: return precedence[ATOM_SEQUENCE];
}
-
- case ATOM_REPETITION:
- r = &a->u.repeat.counts;
- if (r->min == 1 && r->max == 1)
- return get_precedence(a->u.repeat.child);
- break;
}
return precedence[a->type];
@@ -93,8 +84,6 @@ static void print_child_atom(const struct atom *child, const struct atom *parent
static void print_atom(const struct atom *a)
{
- const struct repeat *r;
-
switch (a->type) {
case ATOM_ALTERNATION:
print_child_atom(a->u.children[0], a);
@@ -108,13 +97,8 @@ static void print_atom(const struct atom *a)
break;
case ATOM_REPETITION:
- r = &a->u.repeat.counts;
- if (r->min == 1 && r->max == 1) {
- print_atom(a->u.repeat.child);
- } else {
- print_child_atom(a->u.repeat.child, a);
- print_repeat(r);
- }
+ print_child_atom(a->u.repeat.child, a);
+ print_repeat(&a->u.repeat.counts);
break;
case ATOM_LITERAL: