]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/esi/Expression.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / esi / Expression.cc
index b81b5e2d624f9cf5c5f34794470c41d08b81377b..60162975a6b8555c0ed0ea00373559af0d90f5ff 100644 (file)
  */
 
 #include "squid.h"
+#include "Debug.h"
 #include "esi/Expression.h"
+#include "profiler/Profiler.h"
+
+#if HAVE_MATH_H
+#include <math.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
 
 /* stack precedence rules:
  * before pushing an operator onto the stack, the
@@ -174,7 +183,7 @@ membercompare(stackmember a, stackmember b)
             return 0;
         } else {
             /* TODO: numeric to string conversion ? */
-            debugs(86, 1, "strcmp with non-string");
+            debugs(86, DBG_IMPORTANT, "strcmp with non-string");
             return -2;
         }
     } else if (a.valuestored == ESI_LITERAL_FLOAT) {
@@ -194,7 +203,7 @@ membercompare(stackmember a, stackmember b)
                 return 1;
         } else {
             /* TODO: attempt numeric converson again? */
-            debugs(86, 1, "floatcomp with non float or int");
+            debugs(86, DBG_IMPORTANT, "floatcomp with non float or int");
             return -2;
         }
     } else if (a.valuestored == ESI_LITERAL_INT) {
@@ -214,7 +223,7 @@ membercompare(stackmember a, stackmember b)
                 return 1;
         } else {
             /* TODO: attempt numeric converson again? */
-            debugs(86, 1, "intcomp vs non float non int");
+            debugs(86, DBG_IMPORTANT, "intcomp vs non float non int");
             return -2;
         }
     }
@@ -252,7 +261,7 @@ evalnegate(stackmember * stack, int *depth, int whereAmI, stackmember * candidat
 int
 evalliteral(stackmember * stack, int *depth, int whereAmI, stackmember * candidate)
 {
-    debugs(86, 1, "attempt to evaluate a literal");
+    debugs(86, DBG_IMPORTANT, "attempt to evaluate a literal");
     /* literals can't be evaluated */
     return 1;
 }
@@ -260,12 +269,11 @@ evalliteral(stackmember * stack, int *depth, int whereAmI, stackmember * candida
 int
 evalexpr(stackmember * stack, int *depth, int whereAmI, stackmember * candidate)
 {
-    debugs(86, 1, "attempt to evaluate a sub-expression result");
+    debugs(86, DBG_IMPORTANT, "attempt to evaluate a sub-expression result");
     /* sub-scpr's can't be evaluated */
     return 1;
 }
 
-
 int
 evalor(stackmember * stack, int *depth, int whereAmI, stackmember * candidate)
 {
@@ -411,10 +419,9 @@ evallesseq(stackmember * stack, int *depth, int whereAmI, stackmember * candidat
         /* Something wrong upstream */
         return 1;
 
-    /*  debugs(86, 1, "?= " << srv.value.integral << " "); */
+    /*  debugs(86, DBG_IMPORTANT, "?= " << srv.value.integral << " "); */
     return 0;
 
-
 }
 
 int
@@ -460,10 +467,9 @@ evallessthan(stackmember * stack, int *depth, int whereAmI, stackmember * candid
         /* Something wrong upstream */
         return 1;
 
-    /* debugs(86, 1, "?= " << srv.value.integral << " "); */
+    /* debugs(86, DBG_IMPORTANT, "?= " << srv.value.integral << " "); */
     return 0;
 
-
 }
 
 int
@@ -509,10 +515,9 @@ evalmoreeq(stackmember * stack, int *depth, int whereAmI, stackmember * candidat
         /* Something wrong upstream */
         return 1;
 
-    /* debugs(86, 1, "?= " << srv.value.integral << " "); */
+    /* debugs(86, DBG_IMPORTANT, "?= " << srv.value.integral << " "); */
     return 0;
 
-
 }
 
 int
@@ -558,7 +563,7 @@ evalmorethan(stackmember * stack, int *depth, int whereAmI, stackmember * candid
         /* Something wrong upstream */
         return 1;
 
-    /* debugs(86, 1, "?= " << srv.value.integral << " "); */
+    /* debugs(86, DBG_IMPORTANT, "?= " << srv.value.integral << " "); */
     return 0;
 
 }
@@ -607,7 +612,7 @@ evalequals(stackmember * stack, int *depth, int whereAmI,
         /* Something wrong upstream */
         return 1;
 
-    /* debugs(86, 1, "?= " << srv.value.integral << " "); */
+    /* debugs(86, DBG_IMPORTANT, "?= " << srv.value.integral << " "); */
     return 0;
 }
 
@@ -654,14 +659,14 @@ evalnotequals(stackmember * stack, int *depth, int whereAmI, stackmember * candi
         /* Something wrong upstream */
         return 1;
 
-    /* debugs(86, 1, "?= " << srv.value.integral << " "); */
+    /* debugs(86, DBG_IMPORTANT, "?= " << srv.value.integral << " "); */
     return 0;
 }
 
 int
 evalstartexpr(stackmember * stack, int *depth, int whereAmI, stackmember * candidate)
 {
-    /* debugs(86, 1, "?("); */
+    /* debugs(86, DBG_IMPORTANT, "?("); */
 
     if (whereAmI != *depth - 2)
         /* invalid stack */
@@ -720,7 +725,7 @@ getsymbol(const char *s, char const **endptr)
 
             if (s == end || errno) {
                 /* Couldn't convert to float */
-                debugs(86, 1, "failed to convert '" << s << "' to float ");
+                debugs(86, DBG_IMPORTANT, "failed to convert '" << s << "' to float ");
                 *endptr = origs;
             } else {
                 debugs(86,6, "found " << rv.value.floating << " of length " << end - s);
@@ -737,7 +742,7 @@ getsymbol(const char *s, char const **endptr)
 
             if (s == end || errno) {
                 /* Couldn't convert to int */
-                debugs(86, 1, "failed to convert '" << s << "' to int ");
+                debugs(86, DBG_IMPORTANT, "failed to convert '" << s << "' to int ");
                 *endptr = origs;
             } else {
                 debugs(86,6, "found " << rv.value.integral << " of length " << end - s);
@@ -770,7 +775,7 @@ getsymbol(const char *s, char const **endptr)
             ++t;
 
         if (!*t) {
-            debugs(86, 1, "missing end \' in '" << s << "'");
+            debugs(86, DBG_IMPORTANT, "missing end \' in '" << s << "'");
             *endptr = origs;
         } else {
             *endptr = t + 1;
@@ -823,7 +828,7 @@ getsymbol(const char *s, char const **endptr)
             rv.precedence = 5;
             rv.eval = evalequals;
         } else {
-            debugs(86, 1, "invalid expr '" << s << "'");
+            debugs(86, DBG_IMPORTANT, "invalid expr '" << s << "'");
             *endptr = origs;
         }
     } else if ('<' == *s) {
@@ -871,7 +876,7 @@ getsymbol(const char *s, char const **endptr)
         rv.precedence = 1;
         rv.eval = evalexpr;
     } else {
-        debugs(86, 1, "invalid expr '" << s << "'");
+        debugs(86, DBG_IMPORTANT, "invalid expr '" << s << "'");
         *endptr = origs;
     }
 
@@ -997,7 +1002,7 @@ addmember(stackmember * stack, int *stackdepth, stackmember * candidate)
                 /* cleanup candidate and stack */
                 dumpstack(stack, *stackdepth);
                 cleanmember(candidate);
-                debugs(86, 1, "invalid expression");
+                debugs(86, DBG_IMPORTANT, "invalid expression");
                 return 0;
             }
         } else {
@@ -1031,7 +1036,7 @@ ESIExpression::Evaluate(char const *s)
             s = end;
         } else {
             assert (s == end);
-            debugs(86, 1, "failed parsing expression");
+            debugs(86, DBG_IMPORTANT, "failed parsing expression");
             PROF_stop(esiExpressionEval);
             return 0;
         }
@@ -1045,7 +1050,7 @@ ESIExpression::Evaluate(char const *s)
         if (stack[stackdepth - 2].
                 eval(stack, &stackdepth, stackdepth - 2, &rv)) {
             /* special case - leading operator failed */
-            debugs(86, 1, "invalid expression");
+            debugs(86, DBG_IMPORTANT, "invalid expression");
             PROF_stop(esiExpressionEval);
             return 0;
         }