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