Commit 368197ad authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

And now it is VNUM's turn...

parent b37c01df
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
#include "vmb.h" #include "vmb.h"
#include "vsm.h" #include "vsm.h"
#include "vav.h" #include "vav.h"
#include "vnum.h"
#include "flopen.h" #include "flopen.h"
#ifndef MAP_HASSEMAPHORE #ifndef MAP_HASSEMAPHORE
...@@ -244,7 +245,7 @@ mgt_SHM_Init(const char *l_arg) ...@@ -244,7 +245,7 @@ mgt_SHM_Init(const char *l_arg)
/* Size of SHMLOG */ /* Size of SHMLOG */
if (*ap != NULL && **ap != '\0') { if (*ap != NULL && **ap != '\0') {
q = str2bytes(*ap, &s1, 0); q = VNUM_2bytes(*ap, &s1, 0);
if (q != NULL) if (q != NULL)
ARGV_ERR("\t-l[1] ...: %s\n", q); ARGV_ERR("\t-l[1] ...: %s\n", q);
} else { } else {
...@@ -255,7 +256,7 @@ mgt_SHM_Init(const char *l_arg) ...@@ -255,7 +256,7 @@ mgt_SHM_Init(const char *l_arg)
/* Size of space for other stuff */ /* Size of space for other stuff */
if (*ap != NULL && **ap != '\0') { if (*ap != NULL && **ap != '\0') {
q = str2bytes(*ap, &s2, 0); q = VNUM_2bytes(*ap, &s2, 0);
if (q != NULL) if (q != NULL)
ARGV_ERR("\t-l[2] ...: %s\n", q); ARGV_ERR("\t-l[2] ...: %s\n", q);
} else { } else {
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "mgt.h" #include "mgt.h"
#include "stevedore.h" #include "stevedore.h"
#include "vnum.h"
#ifndef O_LARGEFILE #ifndef O_LARGEFILE
#define O_LARGEFILE 0 #define O_LARGEFILE 0
...@@ -197,7 +198,7 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) ...@@ -197,7 +198,7 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx)
l = st.st_size; l = st.st_size;
} else { } else {
AN(size); AN(size);
q = str2bytes(size, &l, fssize); q = VNUM_2bytes(size, &l, fssize);
if (q != NULL) if (q != NULL)
ARGV_ERR("(%s) size \"%s\": %s\n", size, ctx, q); ARGV_ERR("(%s) size \"%s\": %s\n", size, ctx, q);
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "cache.h" #include "cache.h"
#include "stevedore.h" #include "stevedore.h"
#include "vnum.h"
#ifndef MAP_NOCORE #ifndef MAP_NOCORE
#define MAP_NOCORE 0 /* XXX Linux */ #define MAP_NOCORE 0 /* XXX Linux */
...@@ -131,7 +132,7 @@ smf_init(struct stevedore *parent, int ac, char * const *av) ...@@ -131,7 +132,7 @@ smf_init(struct stevedore *parent, int ac, char * const *av)
size = av[1]; size = av[1];
if (ac > 2 && *av[2] != '\0') { if (ac > 2 && *av[2] != '\0') {
r = str2bytes(av[2], &page_size, 0); r = VNUM_2bytes(av[2], &page_size, 0);
if (r != NULL) if (r != NULL)
ARGV_ERR("(-sfile) granularity \"%s\": %s\n", av[2], r); ARGV_ERR("(-sfile) granularity \"%s\": %s\n", av[2], r);
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "cache.h" #include "cache.h"
#include "stevedore.h" #include "stevedore.h"
#include "vnum.h"
struct sma_sc { struct sma_sc {
unsigned magic; unsigned magic;
...@@ -216,7 +217,7 @@ sma_init(struct stevedore *parent, int ac, char * const *av) ...@@ -216,7 +217,7 @@ sma_init(struct stevedore *parent, int ac, char * const *av)
if (ac == 0 || *av[0] == '\0') if (ac == 0 || *av[0] == '\0')
return; return;
e = str2bytes(av[0], &u, 0); e = VNUM_2bytes(av[0], &u, 0);
if (e != NULL) if (e != NULL)
ARGV_ERR("(-smalloc) size \"%s\": %s\n", av[0], e); ARGV_ERR("(-smalloc) size \"%s\": %s\n", av[0], e);
if ((u != (uintmax_t)(size_t)u)) if ((u != (uintmax_t)(size_t)u))
......
...@@ -140,7 +140,7 @@ smu_init(struct stevedore *parent, int ac, char * const *av) ...@@ -140,7 +140,7 @@ smu_init(struct stevedore *parent, int ac, char * const *av)
if (ac == 0 || *av[0] == '\0') if (ac == 0 || *av[0] == '\0')
return; return;
e = str2bytes(av[0], &u, 0); e = VNUM_2bytes(av[0], &u, 0);
if (e != NULL) if (e != NULL)
ARGV_ERR("(-sumem) size \"%s\": %s\n", av[0], e); ARGV_ERR("(-sumem) size \"%s\": %s\n", av[0], e);
if ((u != (uintmax_t)(size_t)u)) if ((u != (uintmax_t)(size_t)u))
......
...@@ -48,6 +48,7 @@ nobase_noinst_HEADERS = \ ...@@ -48,6 +48,7 @@ nobase_noinst_HEADERS = \
vlu.h \ vlu.h \
vmb.h \ vmb.h \
vmod_abi.h \ vmod_abi.h \
vnum.h \
vpf.h \ vpf.h \
vqueue.h \ vqueue.h \
vre.h \ vre.h \
......
...@@ -38,9 +38,6 @@ ...@@ -38,9 +38,6 @@
struct vsb; struct vsb;
/* from libvarnish/num.c */
const char *str2bytes(const char *p, uintmax_t *r, uintmax_t rel);
/* from libvarnish/version.c */ /* from libvarnish/version.c */
void VCS_Message(const char *); void VCS_Message(const char *);
......
...@@ -13,7 +13,7 @@ libvarnish_la_SOURCES = \ ...@@ -13,7 +13,7 @@ libvarnish_la_SOURCES = \
cli_common.c \ cli_common.c \
cli_serve.c \ cli_serve.c \
flopen.c \ flopen.c \
num.c \ vnum.c \
vtim.c \ vtim.c \
vtcp.c \ vtcp.c \
vct.c \ vct.c \
...@@ -33,13 +33,13 @@ libvarnish_la_CFLAGS = -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' ...@@ -33,13 +33,13 @@ libvarnish_la_CFLAGS = -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"'
libvarnish_la_LIBADD = ${RT_LIBS} ${NET_LIBS} ${LIBM} @PCRE_LIBS@ libvarnish_la_LIBADD = ${RT_LIBS} ${NET_LIBS} ${LIBM} @PCRE_LIBS@
if ENABLE_TESTS if ENABLE_TESTS
TESTS = num_c_test TESTS = vnum_c_test
noinst_PROGRAMS = ${TESTS} noinst_PROGRAMS = ${TESTS}
num_c_test_SOURCES = num.c vnum_c_test_SOURCES = vnum.c
num_c_test_CFLAGS = -DNUM_C_TEST -include config.h vnum_c_test_CFLAGS = -DNUM_C_TEST -include config.h
num_c_test_LDADD = ${LIBM} vnum_c_test_LDADD = ${LIBM}
test: ${TESTS} test: ${TESTS}
@for test in ${TESTS} ; do ./$${test} ; done @for test in ${TESTS} ; do ./$${test} ; done
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "libvarnish.h" #include "vnum.h"
static const char err_miss_num[] = "Missing number"; static const char err_miss_num[] = "Missing number";
static const char err_invalid_num[] = "Invalid number"; static const char err_invalid_num[] = "Invalid number";
...@@ -43,7 +43,7 @@ static const char err_abs_req[] = "Absolute number required"; ...@@ -43,7 +43,7 @@ static const char err_abs_req[] = "Absolute number required";
static const char err_invalid_suff[] = "Invalid suffix"; static const char err_invalid_suff[] = "Invalid suffix";
const char * const char *
str2bytes(const char *p, uintmax_t *r, uintmax_t rel) VNUM_2bytes(const char *p, uintmax_t *r, uintmax_t rel)
{ {
double fval; double fval;
char *end; char *end;
...@@ -178,13 +178,13 @@ main(int argc, char *argv[]) ...@@ -178,13 +178,13 @@ main(int argc, char *argv[])
(void)argc; (void)argc;
for (ec = 0, tc = test_cases; tc->str; ++tc) { for (ec = 0, tc = test_cases; tc->str; ++tc) {
e = str2bytes(tc->str, &val, tc->rel); e = VNUM_2bytes(tc->str, &val, tc->rel);
if (e != tc->err) { if (e != tc->err) {
printf("%s: str2bytes(\"%s\", %ju) (%s) != (%s)\n", printf("%s: VNUM_2bytes(\"%s\", %ju) (%s) != (%s)\n",
*argv, tc->str, tc->rel, tc->err, e); *argv, tc->str, tc->rel, tc->err, e);
++ec; ++ec;
} else if (e == NULL && val != tc->val) { } else if (e == NULL && val != tc->val) {
printf("%s: str2bytes(\"%s\", %ju) %ju != %ju (%s)\n", printf("%s: VNUM_2bytes(\"%s\", %ju) %ju != %ju (%s)\n",
*argv, tc->str, tc->rel, val, tc->val, e); *argv, tc->str, tc->rel, val, tc->val, e);
++ec; ++ec;
} }
......
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