[master] 9ee6786 Comment why symbol handling is slightly special

Poul-Henning Kamp phk at FreeBSD.org
Wed Feb 21 17:01:08 UTC 2018


commit 9ee6786691d2671e550fd2a8187dbe49b2399af1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 21 11:38:36 2018 +0000

    Comment why symbol handling is slightly special

diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index 8b5d1e6..6b6969d 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -65,36 +65,36 @@ vcc_ParseImport(struct vcc *tl)
 	const char * const *spec;
 	struct symbol *sym;
 	struct symbol *msym;
-	const struct symbol *osym;
 	const char *p;
-	// int *modlen;
 	const struct vmod_data *vmd;
 
 	t1 = tl->t;
 	SkipToken(tl, ID);		/* "import" */
 
+
 	ExpectErr(tl, ID);
 	mod = tl->t;
-	osym = VCC_SymbolGet(tl, SYM_NONE, SYMTAB_NOERR, XREF_NONE);
-	vcc_NextToken(tl);
+	msym = VCC_SymbolGet(tl, SYM_NONE, SYMTAB_NOERR, XREF_NONE);
 
-	if (osym != NULL && osym->kind != SYM_VMOD) {
+	if (msym != NULL && msym->kind != SYM_VMOD) {
+		/*
+		 * We need to make sure the entire std.* namespace is empty
+		 */
 		VSB_printf(tl->sb, "Module %.*s conflicts with other symbol.\n",
 		    PF(mod));
 		vcc_ErrWhere2(tl, t1, tl->t);
 		return;
 	}
-	if (osym != NULL) {
+	if (msym != NULL) {
 		VSB_printf(tl->sb, "Module %.*s already imported.\n",
 		    PF(mod));
 		vcc_ErrWhere2(tl, t1, tl->t);
 		VSB_printf(tl->sb, "Previous import was here:\n");
-		vcc_ErrWhere2(tl, osym->def_b, osym->def_e);
+		vcc_ErrWhere2(tl, msym->def_b, msym->def_e);
 		return;
 	}
 
-	bprintf(fn, "%.*s", PF(mod));
-	msym = VCC_MkSym(tl, fn, SYM_VMOD, VCL_LOW, VCL_HIGH);
+	msym = VCC_SymbolGet(tl, SYM_VMOD, SYMTAB_CREATE, XREF_NONE);
 	ERRCHK(tl);
 	AN(msym);
 	msym->def_b = t1;


More information about the varnish-commit mailing list