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