summaryrefslogtreecommitdiff
path: root/includes.c
diff options
context:
space:
mode:
Diffstat (limited to 'includes.c')
-rw-r--r--includes.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/includes.c b/includes.c
index 103c8fd..cbef99a 100644
--- a/includes.c
+++ b/includes.c
@@ -51,19 +51,18 @@ static struct majefile * find_inc(const struct majefile *file, const regex_t * r
struct majefile *find_includes(const struct majefile *source)
{
- regex_t re;
- int rc = regcomp(&re,
- "#[[:space:]]*include[[:space:]]+.*\"(.*)\"",
- REG_EXTENDED | REG_NEWLINE);
- if (rc != 0) {
- fprintf(stderr, "maje: regcomp() failed\n");
- abort();
+ static regex_t re = { .re_nsub = (size_t)-1 };
+ if (re.re_nsub == (size_t)-1) {
+ if (regcomp(&re,
+ "#[[:space:]]*include[[:space:]]+.*\"(.*)\"",
+ REG_EXTENDED | REG_NEWLINE) != 0) {
+ fprintf(stderr, "maje: regcomp(#include) failed\n");
+ abort();
+ }
}
struct majefile *ret = find_inc(source, &re);
- regfree(&re);
-
if (ret != NULL) {
while (ret->prev != NULL) {
ret = ret->prev;