[master] 7d8e4a4f0 Refactor SYMTAB_*
Nils Goroll
nils.goroll at uplex.de
Wed Feb 17 19:20:03 UTC 2021
commit 7d8e4a4f0d4548a8f0a58d29a870f0c075ee3426
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Feb 17 20:10:29 2021 +0100
Refactor SYMTAB_*
suggested by phk
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 5447021e4..2bdc7e480 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -382,7 +382,11 @@ extern const struct symxref XREF_NONE[1];
extern const struct symxref XREF_DEF[1];
extern const struct symxref XREF_REF[1];
-struct symmode { const char *name; };
+struct symmode {
+ const char *name;
+ unsigned noerr;
+ unsigned partial;
+};
extern const struct symmode SYMTAB_NOERR[1];
extern const struct symmode SYMTAB_CREATE[1];
extern const struct symmode SYMTAB_EXISTING[1];
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index 4df46f977..0423c3c14 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -250,11 +250,26 @@ vcc_sym_in_tab(struct vcc *tl, struct symtab *st,
const struct symxref XREF_NONE[1] = {{"xref_none"}};
const struct symxref XREF_DEF[1] = {{"xref_def"}};
const struct symxref XREF_REF[1] = {{"xref_ref"}};
-const struct symmode SYMTAB_NOERR[1] = {{"sym_noerror"}};
-const struct symmode SYMTAB_CREATE[1] = {{"sym_create"}};
-const struct symmode SYMTAB_EXISTING[1] = {{"Symbol not found"}};
-const struct symmode SYMTAB_PARTIAL[1] = {{"Symbol not found"}};
-const struct symmode SYMTAB_PARTIAL_NOERR[1] = {{"Symbol not found"}};
+
+const struct symmode SYMTAB_NOERR[1] = {{
+ .name = "sym_noerror",
+ .noerr = 1
+ }};
+const struct symmode SYMTAB_CREATE[1] = {{
+ .name = "sym_create"
+ }};
+const struct symmode SYMTAB_EXISTING[1] = {{
+ .name = "Symbol not found"
+ }};
+const struct symmode SYMTAB_PARTIAL[1] = {{
+ .name = "Symbol not found",
+ .partial = 1
+ }};
+const struct symmode SYMTAB_PARTIAL_NOERR[1] = {{
+ .name = "Symbol not found",
+ .partial = 1,
+ .noerr = 1
+ }};
struct symbol *
VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind,
@@ -300,15 +315,15 @@ VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind,
break;
tn = tn1;
}
- if (sym != NULL && sym->kind == SYM_VMOD && e == SYMTAB_PARTIAL)
+ if (sym != NULL && sym->kind == SYM_VMOD && e->partial)
e = SYMTAB_EXISTING;
- if (sym != NULL && (e == SYMTAB_PARTIAL || e == SYMTAB_PARTIAL_NOERR)) {
+ if (sym != NULL && e->partial) {
st = st2;
tn = tn2;
} else if (st != st2) {
sym = NULL;
}
- if (sym == NULL && (e == SYMTAB_NOERR || e == SYMTAB_PARTIAL_NOERR))
+ if (sym == NULL && e->noerr)
return (sym);
AN(st);
AN(tn);
More information about the varnish-commit
mailing list