From 233bac703ee5849cb18d02330ccb97038ffc6439 Mon Sep 17 00:00:00 2001 From: katherine Date: Thu, 30 May 2019 20:38:25 -0700 Subject: uthash location header warning --- src/parse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/parse.c') diff --git a/src/parse.c b/src/parse.c index 752e0b8..8b8f699 100644 --- a/src/parse.c +++ b/src/parse.c @@ -447,11 +447,13 @@ struct parse_result_s parse(FILE *f, const char *fname) ERR_AT(t.line, t.col, "unexpected token `%s`", t.val); } + /* err >0 rules */ if (r.vars == NULL) { fprintf(stderr, "\x1B[1m%s:\x1B[0m ", fname); ERR("config must specify at fewest one variable rule"); } + /* err undefined type */ HASH_ITER(hh, r.vars, vcur, vtmp) { switch (vcur->type) { case PARSE_TYPE_DEFTYPE: @@ -474,6 +476,7 @@ struct parse_result_s parse(FILE *f, const char *fname) } } + /* warn type use */ HASH_ITER(hh, r.deftypes, dcur, dtmp) { if (!dcur->is_used) { WARN_AT(dcur->line, dcur->col, @@ -482,12 +485,17 @@ struct parse_result_s parse(FILE *f, const char *fname) } } - if (!r.location_seen) { - fprintf(stderr, "\x1B[1m%s:\x1B[0m ", fname); - WARN("no uthash location header specified. using ``"); - strcpy(r.location, ""); + /* warn hash location */ + HASH_ITER(hh, r.vars, vcur, vtmp) { + if (vcur->type >= PARSE_TYPE_HASH_BOOL && !r.location_seen) { + fprintf(stderr, "\x1B[1m%s:\x1B[0m ", fname); + WARN("no uthash location header specified. using ``"); + strcpy(r.location, ""); + break; + } } + /* warn/err suffix */ if (!r.suffix_seen) { j = 0; -- cgit v1.2.3