Commit 7300ca4c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Use the new VNUM() in the trivial cases

parent 131ec87b
...@@ -58,29 +58,25 @@ tweak_generic_double(struct vsb *vsb, volatile double *dest, ...@@ -58,29 +58,25 @@ tweak_generic_double(struct vsb *vsb, volatile double *dest,
const char *arg, const char *min, const char *max, const char *fmt) const char *arg, const char *min, const char *max, const char *fmt)
{ {
double u, minv = 0, maxv = 0; double u, minv = 0, maxv = 0;
char *p;
if (arg != NULL) { if (arg != NULL) {
if (min != NULL) { if (min != NULL) {
p = NULL; minv = VNUM(min);
minv = strtod(min, &p); if (isnan(minv)) {
if (*arg == '\0' || *p != '\0') {
VSB_printf(vsb, "Illegal Min: %s\n", min); VSB_printf(vsb, "Illegal Min: %s\n", min);
return (-1); return (-1);
} }
} }
if (max != NULL) { if (max != NULL) {
p = NULL; maxv = VNUM(max);
maxv = strtod(max, &p); if (isnan(maxv)) {
if (*arg == '\0' || *p != '\0') {
VSB_printf(vsb, "Illegal Max: %s\n", max); VSB_printf(vsb, "Illegal Max: %s\n", max);
return (-1); return (-1);
} }
} }
p = NULL; u = VNUM(arg);
u = strtod(arg, &p); if (isnan(u)) {
if (*arg == '\0' || *p != '\0') {
VSB_printf(vsb, "Not a number(%s)\n", arg); VSB_printf(vsb, "Not a number(%s)\n", arg);
return (-1); return (-1);
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "vtc.h" #include "vtc.h"
#include "vav.h" #include "vav.h"
#include "vnum.h"
#include "vtim.h" #include "vtim.h"
#define MAX_TOKENS 200 #define MAX_TOKENS 200
...@@ -433,7 +434,7 @@ cmd_delay(CMD_ARGS) ...@@ -433,7 +434,7 @@ cmd_delay(CMD_ARGS)
return; return;
AN(av[1]); AN(av[1]);
AZ(av[2]); AZ(av[2]);
f = strtod(av[1], NULL); f = VNUM(av[1]);
vtc_log(vl, 3, "delaying %g second(s)", f); vtc_log(vl, 3, "delaying %g second(s)", f);
VTIM_sleep(f); VTIM_sleep(f);
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <math.h>
#include <poll.h> #include <poll.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
#include "vct.h" #include "vct.h"
#include "vgz.h" #include "vgz.h"
#include "vnum.h"
#include "vre.h" #include "vre.h"
#include "vtcp.h" #include "vtcp.h"
...@@ -272,13 +274,13 @@ cmd_http_expect(CMD_ARGS) ...@@ -272,13 +274,13 @@ cmd_http_expect(CMD_ARGS)
// fail inequality comparisons if either side is undef'ed // fail inequality comparisons if either side is undef'ed
retval = 0; retval = 0;
} else if (!strcmp(cmp, "<")) { } else if (!strcmp(cmp, "<")) {
retval = strtod(lhs, NULL) < strtod(rhs, NULL); retval = isless(VNUM(lhs), VNUM(rhs));
} else if (!strcmp(cmp, ">")) { } else if (!strcmp(cmp, ">")) {
retval = strtod(lhs, NULL) > strtod(rhs, NULL); retval = isgreater(VNUM(lhs), VNUM(rhs));
} else if (!strcmp(cmp, "<=")) { } else if (!strcmp(cmp, "<=")) {
retval = strtod(lhs, NULL) <= strtod(rhs, NULL); retval = islessequal(VNUM(lhs), VNUM(rhs));
} else if (!strcmp(cmp, ">=")) { } else if (!strcmp(cmp, ">=")) {
retval = strtod(lhs, NULL) >= strtod(rhs, NULL); retval = isgreaterequal(VNUM(lhs), VNUM(rhs));
} }
if (retval == -1) if (retval == -1)
...@@ -1096,13 +1098,17 @@ static void ...@@ -1096,13 +1098,17 @@ static void
cmd_http_timeout(CMD_ARGS) cmd_http_timeout(CMD_ARGS)
{ {
struct http *hp; struct http *hp;
double d;
(void)cmd; (void)cmd;
(void)vl; (void)vl;
CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
AN(av[1]); AN(av[1]);
AZ(av[2]); AZ(av[2]);
hp->timeout = (int)(strtod(av[1], NULL) * 1000.0); d = VNUM(av[1]);
if (isnan(d))
vtc_log(vl, 0, "timeout is not a number (%s)", av[1]);
hp->timeout = (int)(d * 1000.0);
} }
/********************************************************************** /**********************************************************************
......
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