aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/prc/prc.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/prc/prc.c b/src/prc/prc.c
index 83c4baf..cbdc2d2 100644
--- a/src/prc/prc.c
+++ b/src/prc/prc.c
@@ -360,15 +360,20 @@ static int qbe(struct state *s, const char *src)
return -1;
}
-static int runsuffix(struct state *s, const char *src, const char *suffix,
- int (*f)(struct state *, const char *))
+static int hassuffix(const char *s, const char *suffix)
{
- const char *sep = strchr(src, '.');
+ const char *sep = strchr(s, '.');
if (sep)
- return strcmp(++sep, suffix) ? 0 : f(s, src);
+ return !strcmp(++sep, suffix);
- return f(s, src);
+ return 0;
+}
+
+static int runsuffix(struct state *s, const char *src, const char *suffix,
+ int (*f)(struct state *, const char *))
+{
+ return hassuffix(src, suffix) ? f(s, src) : 0;
}
static int waitall(const struct procs *pr)
@@ -395,8 +400,19 @@ static int runprc1(struct state *s)
const struct input *srcs = &s->sources;
for (size_t i = 0; i < srcs->n; i++)
- if (runsuffix(s, srcs->v[i], "prose", prc1))
+ {
+ static const char *suf[] = {"o", "qbe", "s"};
+ const char *src = srcs->v[i];
+
+ for (size_t i = 0; i < sizeof suf / sizeof *suf; i++)
+ if (hassuffix(src, suf[i]))
+ goto end;
+
+ if (prc1(s, src))
return -1;
+end:
+ ;
+ }
return waitall(&s->srcprocs);
}