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

Eliminate vcc_RTimeVal(), rename vcc_TimeVal() to Vcc_Duration().

Clean up some asserts.
parent f0530c9e
......@@ -278,12 +278,12 @@ vcc_ParseProbeSpec(struct vcc *tl)
Fh(tl, 0, "\t\t\"\\r\\n\",\n");
} else if (vcc_IdIs(t_field, "timeout")) {
Fh(tl, 0, "\t.timeout = ");
vcc_TimeVal(tl, &t);
vcc_Duration(tl, &t);
ERRCHK(tl);
Fh(tl, 0, "%g,\n", t);
} else if (vcc_IdIs(t_field, "interval")) {
Fh(tl, 0, "\t.interval = ");
vcc_TimeVal(tl, &t);
vcc_Duration(tl, &t);
ERRCHK(tl);
Fh(tl, 0, "%g,\n", t);
} else if (vcc_IdIs(t_field, "window")) {
......@@ -470,19 +470,19 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "connect_timeout")) {
Fb(tl, 0, "\t.connect_timeout = ");
vcc_TimeVal(tl, &t);
vcc_Duration(tl, &t);
ERRCHK(tl);
Fb(tl, 0, "%g,\n", t);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "first_byte_timeout")) {
Fb(tl, 0, "\t.first_byte_timeout = ");
vcc_TimeVal(tl, &t);
vcc_Duration(tl, &t);
ERRCHK(tl);
Fb(tl, 0, "%g,\n", t);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "between_bytes_timeout")) {
Fb(tl, 0, "\t.between_bytes_timeout = ");
vcc_TimeVal(tl, &t);
vcc_Duration(tl, &t);
ERRCHK(tl);
Fb(tl, 0, "%g,\n", t);
SkipToken(tl, ';');
......
......@@ -272,8 +272,7 @@ parsedirector_f vcc_ParseRandomDirector;
parsedirector_f vcc_ParseRoundRobinDirector;
/* vcc_expr.c */
void vcc_RTimeVal(struct vcc *tl, double *);
void vcc_TimeVal(struct vcc *tl, double *);
void vcc_Duration(struct vcc *tl, double *);
unsigned vcc_UintVal(struct vcc *tl);
void vcc_Expr(struct vcc *tl, enum var_type typ);
void vcc_Expr_Call(struct vcc *tl, const struct symbol *sym);
......
......@@ -194,17 +194,17 @@ vcc_dir_dns_parse_backend_options(struct vcc *tl)
vcc_NextToken(tl);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "connect_timeout")) {
vcc_TimeVal(tl, &t);
vcc_Duration(tl, &t);
ERRCHK(tl);
b_defaults.connect_timeout = t;
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "first_byte_timeout")) {
vcc_TimeVal(tl, &t);
vcc_Duration(tl, &t);
ERRCHK(tl);
b_defaults.first_byte_timeout = t;
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "between_bytes_timeout")) {
vcc_TimeVal(tl, &t);
vcc_Duration(tl, &t);
ERRCHK(tl);
b_defaults.between_bytes_timeout = t;
SkipToken(tl, ';');
......@@ -333,7 +333,7 @@ vcc_ParseDnsDirector(struct vcc *tl)
vcc_NextToken(tl);
ExpectErr(tl, ';');
} else if (vcc_IdIs(t_field, "ttl")) {
vcc_RTimeVal(tl, &ttl);
vcc_Duration(tl, &ttl);
ExpectErr(tl, ';');
} else if (vcc_IdIs(t_field, "list")) {
vcc_dir_dns_parse_list(tl,&nelem);
......
......@@ -154,26 +154,7 @@ vcc_DoubleVal(struct vcc *tl)
/*--------------------------------------------------------------------*/
void
vcc_RTimeVal(struct vcc *tl, double *d)
{
double v, sc;
int sign = 1;
if (tl->t->tok == '-') {
sign *= -1;
vcc_NextToken(tl);
}
v = vcc_DoubleVal(tl);
ERRCHK(tl);
ExpectErr(tl, ID);
sc = vcc_TimeUnit(tl);
*d = sign * v * sc;
}
/*--------------------------------------------------------------------*/
void
vcc_TimeVal(struct vcc *tl, double *d)
vcc_Duration(struct vcc *tl, double *d)
{
double v, sc;
......@@ -318,6 +299,7 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1,
struct expr *e;
int nl = 1;
AN(e1);
e = vcc_new_expr();
while (*p != '\0') {
if (*p != '\v') {
......@@ -332,7 +314,6 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1,
case '+': VSB_cat(e->vsb, "\v+"); break;
case '-': VSB_cat(e->vsb, "\v-"); break;
case '1':
AN(e1);
VSB_cat(e->vsb, VSB_data(e1->vsb));
break;
case '2':
......@@ -345,14 +326,10 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1,
p++;
}
AZ(VSB_finish(e->vsb));
if (e1 != NULL)
e->t1 = e1->t1;
else if (e2 != NULL)
e->t1 = e2->t1;
e->t1 = e1->t1;
e->t2 = e1->t2;
if (e2 != NULL)
e->t2 = e2->t2;
else if (e1 != NULL)
e->t2 = e1->t2;
vcc_delete_expr(e1);
vcc_delete_expr(e2);
e->fmt = fmt;
......@@ -392,7 +369,7 @@ vcc_expr_fmt(struct vsb *d, int ind, const struct expr *e1)
case '+': ind += 2; break;
case '-': ind -= 2; break;
default:
assert(__LINE__ == 0);
WRONG("Illegal format in VCC expression");
}
p++;
}
......@@ -491,7 +468,7 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym)
return;
if (e2->fmt != STRING)
vcc_expr_tostring(&e2, STRING);
*e = vcc_expr_edit(STRING, "\v1,\n\v2)\v-",*e, e2);
*e = vcc_expr_edit(STRING, "\v1,\n\v2)\v-", *e, e2);
SkipToken(tl, ')');
}
......@@ -700,7 +677,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
*/
assert(fmt != VOID);
if (fmt == DURATION) {
vcc_RTimeVal(tl, &d);
vcc_Duration(tl, &d);
ERRCHK(tl);
e1 = vcc_mk_expr(DURATION, "%g", d);
} else if (fmt == BYTES) {
......
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