[master] 0ec2ab17c vcc_token: refactor out check for scientific notation

Nils Goroll nils.goroll at uplex.de
Wed Oct 29 18:51:05 UTC 2025


commit 0ec2ab17c3be935c366185ca9fbbbce8851f8e4f
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Oct 29 19:42:55 2025 +0100

    vcc_token: refactor out check for scientific notation

diff --git a/lib/libvcc/vcc_token.c b/lib/libvcc/vcc_token.c
index 4aeaee991..e494eefb6 100644
--- a/lib/libvcc/vcc_token.c
+++ b/lib/libvcc/vcc_token.c
@@ -473,6 +473,18 @@ vcc_delim_token(struct vcc *tl, struct source *sp, const char *p,
  * We enforce the RFC8941 restrictions on number of digits here.
  */
 
+static int
+vcc_lex_number_token_valid(struct vcc *tl)
+{
+	if (*tl->t->e == 'e' || *tl->t->e == 'E') {
+		VSB_printf(tl->sb, "Unexpected character '%c'.\n", *tl->t->e);
+		tl->t->e++;
+		vcc_ErrWhere(tl, tl->t);
+		return (0);
+	}
+	return (1);
+}
+
 static const char *
 vcc_lex_number(struct vcc *tl, struct source *sp, const char *p)
 {
@@ -503,12 +515,8 @@ vcc_lex_number(struct vcc *tl, struct source *sp, const char *p)
 		vcc_ErrWhere(tl, tl->t);
 		return (NULL);
 	}
-	if (*tl->t->e == 'e' || *tl->t->e == 'E') {
-		VSB_printf(tl->sb, "Unexpected character '%c'.\n", *tl->t->e);
-		tl->t->e++;
-		vcc_ErrWhere(tl, tl->t);
+	if (! vcc_lex_number_token_valid(tl))
 		return (NULL);
-	}
 	tl->t->num = strtod(p, &s);
 	assert(s == tl->t->e);
 	return (r);


More information about the varnish-commit mailing list