[master] fd8fdc2 Make sure we have no floating point round-off issues with vcl version.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Feb 5 10:26:14 UTC 2018
commit fd8fdc215d8d7040ec75dcc224bfd05b90f6dbd6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Feb 5 10:10:56 2018 +0000
Make sure we have no floating point round-off issues with vcl version.
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 699b9ff..776a52f 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -66,7 +66,7 @@ struct symbol;
struct source {
VTAILQ_ENTRY(source) list;
- float syntax;
+ int syntax;
char *name;
const char *b;
const char *e;
@@ -183,7 +183,7 @@ VTAILQ_HEAD(inifinhead, inifin);
struct vcc {
unsigned magic;
#define VCC_MAGIC 0x24ad719d
- float syntax;
+ int syntax;
char *builtin_vcl;
struct vfil_path *vcl_path;
diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c
index 7bcd732..e11a16b 100644
--- a/lib/libvcc/vcc_parse.c
+++ b/lib/libvcc/vcc_parse.c
@@ -282,14 +282,14 @@ vcc_ParseVcl(struct vcc *tl)
tok1 = tl->t;
Expect(tl, CNUM);
- tok1->src->syntax = *tl->t->b - '0';
+ tok1->src->syntax = (*tl->t->b - '0') * 10;
vcc_NextToken(tl);
Expect(tl, '.');
vcc_NextToken(tl);
Expect(tl, CNUM);
tok2 = tl->t;
- tok1->src->syntax += .1 * (*tl->t->b - '0');
+ tok1->src->syntax += (*tl->t->b - '0');
vcc_NextToken(tl);
if (tok1->e - tok1->b != 1 || tok2->e - tok2->b != 1) {
@@ -314,7 +314,7 @@ vcc_ParseVcl(struct vcc *tl)
VSB_printf(tl->sb,
"VCL version %.1f higher than"
" the top level version %.1f\n",
- tok1->src->syntax, tl->syntax);
+ .1 * tok1->src->syntax, .1 * tl->syntax);
vcc_ErrWhere2(tl, tok0, tl->t);
ERRCHK(tl);
}
@@ -357,7 +357,7 @@ vcc_Parse(struct vcc *tl)
VSB_printf(tl->sb,
"VCL version declaration missing\n"
"Update your VCL to Version 4 syntax, and add\n"
- "\tvcl 4.0;\n"
+ "\tvcl 4.1;\n"
"on the first line of the VCL files.\n"
);
vcc_ErrWhere(tl, tl->t);
@@ -367,7 +367,7 @@ vcc_Parse(struct vcc *tl)
vcc_ParseVcl(tl);
if (tok->src->syntax != 4.0) {
VSB_printf(tl->sb, "VCL version %.1f not supported.\n",
- tok->src->syntax);
+ .1 * tok->src->syntax);
vcc_ErrWhere2(tl, tok, tl->t);
ERRCHK(tl);
}
More information about the varnish-commit
mailing list