diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-09-28 07:56:30 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-09-28 07:56:30 +0200 |
| commit | 9140988be4e5bb028b7140aca1a67af1370c72a7 (patch) | |
| tree | 6d762df66c29a8862839543896f13e2035b8aa5e | |
| parent | 204f6f332318056a9b950e71e4a958da0c10ea72 (diff) | |
| download | prc-master.tar.gz | |
| -rw-r--r-- | src/prc/prc.c | 28 |
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); } |
