[hackers] [sbase] add agetline, separate estrtod to util || Hiltjo Posthuma
commit d12e953f18e9746c83d4bed532fa2c51cc3c5d48
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun Jun 1 13:57:22 2014 +0200
add agetline, separate estrtod to util
Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
diff --git a/Makefile b/Makefile
index ad1e43b..abfceab 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -7,12 +7,14 @@ HDR = crypt.h fs.h text.h md5.h sha1.h sha256.h sha512.h util.h arg.h
LIB = \
util/afgets.o \
util/agetcwd.o \
+ util/agetline.o \
util/apathmax.o \
util/concat.o \
util/cp.o \
util/crypt.o \
util/enmasse.o \
util/eprintf.o \
+ util/estrtod.o \
util/estrtol.o \
util/fnck.o \
util/getlines.o \
diff --git a/seq.c b/seq.c
index 5b3d5f0..9beb568 100644
--- a/seq.c
+++ b/seq.c
_AT_@ -8,7 +8,6 @@
static int digitsleft(const char *);
static int digitsright(const char *);
-static double estrtod(const char *);
static bool validfmt(const char *);
static void
_AT_@ -75,7 +74,7 @@ main(int argc, char *argv[])
left = MAX(digitsleft(starts), digitsleft(ends));
snprintf(ftmp, sizeof ftmp, "%%0%d.%df",
- right+left+(right != 0), right);
+ right + left + (right != 0), right);
} else
snprintf(ftmp, sizeof ftmp, "%%.%df", right);
}
_AT_@ -89,7 +88,7 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-int
+static int
digitsleft(const char *d)
{
char *exp;
_AT_@ -100,10 +99,10 @@ digitsleft(const char *d)
exp = strpbrk(d, "eE");
shift = exp ? estrtol(&exp[1], 10) : 0;
- return MAX(0, strspn(d, "-0123456789")+shift);
+ return MAX(0, strspn(d, "-0123456789") + shift);
}
-int
+static int
digitsright(const char *d)
{
char *exp;
_AT_@ -113,22 +112,10 @@ digitsright(const char *d)
shift = exp ? estrtol(&exp[1], 10) : 0;
after = (d = strchr(d, '.')) ? strspn(&d[1], "0123456789") : 0;
- return MAX(0, after-shift);
+ return MAX(0, after - shift);
}
-double
-estrtod(const char *s)
-{
- char *end;
- double d;
-
- d = strtod(s, &end);
- if(end == s || *end != '
Received on Sun Jun 01 2014 - 19:01:49 CEST
This archive was generated by hypermail 2.3.0
: Sun Jun 01 2014 - 19:12:10 CEST