Commit a911a136 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Refactoring

parent 3bf8fc77
......@@ -433,6 +433,8 @@ void vcc_Duration(struct vcc *tl, double *);
unsigned vcc_UintVal(struct vcc *tl);
int vcc_IsFlag(struct vcc *tl);
int vcc_IsFlagRaw(struct vcc *, const struct token *, const struct token *);
char *vcc_Dup_be(const char *b, const char *e);
int vcc_Has_vcl_prefix(const char *b);
/* vcc_var.c */
sym_wildcard_t vcc_Var_Wildcard;
......
......@@ -244,10 +244,7 @@ vcc_ParseFunction(struct vcc *tl)
p = sym->proc;
if (p == NULL) {
if (vcc_builtin != NULL && bsym == NULL &&
(t->b[0] == 'v'|| t->b[0] == 'V') &&
(t->b[1] == 'c'|| t->b[1] == 'C') &&
(t->b[2] == 'l'|| t->b[2] == 'L') &&
(t->b[3] == '_')) {
vcc_Has_vcl_prefix(t->b)) {
VSB_printf(tl->sb,"The names 'vcl_*'"
" are reserved for subroutines.\n");
vcc_ErrWhere(tl, t);
......
......@@ -125,22 +125,6 @@ VCC_SymName(struct vsb *vsb, const struct symbol *sym)
vcc_symtabname(vsb, sym->symtab);
}
static char *
vcc_dup_be(const char *b, const char *e)
{
char *p;
AN(b);
if (e == NULL)
e = strchr(b, '\0');
AN(e);
assert(e >= b);
p = strndup(b, e - b);
AN(p);
return (p);
}
static struct symtab *
vcc_symtab_new(const char *name)
{
......@@ -177,14 +161,14 @@ vcc_symtab_str(struct symtab *st, const char *b, const char *e)
continue;
if (i == 0 && l == st2->nlen)
break;
st3 = vcc_symtab_new(vcc_dup_be(b, q));
st3 = vcc_symtab_new(vcc_Dup_be(b, q));
st3->parent = st;
VTAILQ_INSERT_BEFORE(st2, st3, list);
st2 = st3;
break;
}
if (st2 == NULL) {
st2 = vcc_symtab_new(vcc_dup_be(b, q));
st2 = vcc_symtab_new(vcc_Dup_be(b, q));
st2->parent = st;
VTAILQ_INSERT_TAIL(&st->children, st2, list);
}
......@@ -287,10 +271,7 @@ VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind,
AN(x);
AN(x->name);
if (tl->syntax >= VCL_41 && e == SYMTAB_CREATE && kind != SYM_SUB &&
(tl->t->b[0] == 'v'|| tl->t->b[0] == 'V') &&
(tl->t->b[1] == 'c'|| tl->t->b[1] == 'C') &&
(tl->t->b[2] == 'l'|| tl->t->b[2] == 'L') &&
(tl->t->b[3] == '_')) {
vcc_Has_vcl_prefix(tl->t->b)) {
VSB_cat(tl->sb, "Symbols named 'vcl_*' are reserved.\nAt:");
vcc_ErrWhere(tl, tl->t);
return (NULL);
......
......@@ -385,3 +385,30 @@ vcc_IsFlag(struct vcc *tl)
vcc_NextToken(tl);
return (retval);
}
char *
vcc_Dup_be(const char *b, const char *e)
{
char *p;
AN(b);
if (e == NULL)
e = strchr(b, '\0');
AN(e);
assert(e >= b);
p = strndup(b, e - b);
AN(p);
return (p);
}
int
vcc_Has_vcl_prefix(const char *b)
{
return (
(b[0] == 'v' || b[0] == 'V') &&
(b[1] == 'c' || b[1] == 'C') &&
(b[2] == 'l' || b[2] == 'L') &&
(b[3] == '_')
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment