aboutsummaryrefslogtreecommitdiff
path: root/sys/libn
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-05-19 16:37:23 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-05-19 16:37:23 -0700
commit13772a8a2120017981d280bfe120fdbb74f27860 (patch)
tree0dcd2245580572297fe258f3bc4d681df2756680 /sys/libn
parent02103dfd518faf327f7edc13695435308ddcead8 (diff)
fix: many bug fixes to number parsing
Diffstat (limited to 'sys/libn')
-rw-r--r--sys/libn/bufio.c2
-rw-r--r--sys/libn/string.c9
2 files changed, 6 insertions, 5 deletions
diff --git a/sys/libn/bufio.c b/sys/libn/bufio.c
index cde56b7..9bca46a 100644
--- a/sys/libn/bufio.c
+++ b/sys/libn/bufio.c
@@ -75,7 +75,6 @@ getbyte:
error
bufio·ungetbyte(io·Buffer *buf, byte c)
{
- buf->state &= ~bufio·end;
if (!(buf->state & bufio·rdr)) {
errorf("attempted to unget on non-active reader");
return bufio·err;
@@ -135,7 +134,6 @@ nextbyte:
error
bufio·ungetrune(io·Buffer *buf, rune r)
{
- buf->state ^= bufio·end;
if (buf->state & bufio·rdr) {
errorf("attempted to unget on non-active reader");
return bufio·err;
diff --git a/sys/libn/string.c b/sys/libn/string.c
index 4c8c903..7c152e3 100644
--- a/sys/libn/string.c
+++ b/sys/libn/string.c
@@ -243,19 +243,22 @@ str·make(const byte *s)
string
str·makef(const byte *fmt, ...)
{
+ vlong n;
+ string s;
va_list args;
+
va_start(args, fmt);
- vlong n = vsnprintf(nil, 0, fmt, args);
+ n = vsnprintf(nil, 0, fmt, args);
va_end(args);
- string s = str·makecap(nil, 0, n);
+ s = str·makecap(nil, 0, n);
va_start(args, fmt);
vsnprintf(s, n + 1, fmt, args);
va_end(args);
Hdr* h = (Hdr*)(s - sizeof(Hdr));
- h->len = n;
+ h->len = n;
return s;
}