[master] 0ca8d1771 vxp: bring back fallback to trunc(strtod()) for VEX_INT

Nils Goroll nils.goroll at uplex.de
Wed Jun 5 08:26:06 UTC 2024


commit 0ca8d177178b94622a3a8a939f383d6abc1952c7
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Jun 5 10:13:28 2024 +0200

    vxp: bring back fallback to trunc(strtod()) for VEX_INT
    
    It seems I wrongly assumed strtoll(".", ...) would return 0, so
    bring back the fallack to float parsing similar to what we had
    before 05e10eee3076e4c416ebd460cfa70f4fa8fcdb67.
    
    Should fix regression on FreeBSD from 0dfa3b8c95f67054989a0e9259069e2f2433497a
    
    Also clean up now unneeded include (thank you, Flexelint).
    
    Fixes #4088
    
    I promise, if this is still wrong, I will install FreeBSD ;)

diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c
index 61f9f325c..d6496043e 100644
--- a/lib/libvarnishapi/vsl_query.c
+++ b/lib/libvarnishapi/vsl_query.c
@@ -41,7 +41,6 @@
 #include "miniobj.h"
 
 #include "vbm.h"
-#include "vnum.h"
 #include "vqueue.h"
 #include "vre.h"
 #include "vsb.h"
@@ -211,18 +210,19 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
 		case VEX_INT:
 			lhs_int = strtoll(b, &q, 0);
 			AN(q);
-			if (q != e && *q != '.')
-				return (0);
+			if (q != e && (*q == '.' || *q == 'e')) {
+				lhs_float = strtod(b, &q);
+				lhs_int = trunc(lhs_float);
+				lhs_float = 0.;
+			}
 			break;
 		case VEX_FLOAT:
 			lhs_float = strtod(b, &q);
-			if (q != e)
-				return (0);
 			break;
 		default:
 			WRONG("Wrong RHS type");
 		}
-		if (errno != 0)
+		if (q != e || errno != 0)
 			return (0);
 		break;
 	default:


More information about the varnish-commit mailing list