From 13772a8a2120017981d280bfe120fdbb74f27860 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 19 May 2020 16:37:23 -0700 Subject: fix: many bug fixes to number parsing --- sys/libn/bufio.c | 2 -- sys/libn/string.c | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'sys/libn') 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; } -- cgit v1.2.1