aboutsummaryrefslogtreecommitdiff
path: root/sys/libn
diff options
context:
space:
mode:
Diffstat (limited to 'sys/libn')
-rw-r--r--sys/libn/bufio.c4
-rw-r--r--sys/libn/string.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/sys/libn/bufio.c b/sys/libn/bufio.c
index 05b6068..cde56b7 100644
--- a/sys/libn/bufio.c
+++ b/sys/libn/bufio.c
@@ -75,8 +75,8 @@ getbyte:
error
bufio·ungetbyte(io·Buffer *buf, byte c)
{
- buf->state ^= bufio·end;
- if (buf->state & bufio·rdr) {
+ 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 fb92a04..4c8c903 100644
--- a/sys/libn/string.c
+++ b/sys/libn/string.c
@@ -355,11 +355,11 @@ str·appendlen(string *s, vlong n, const byte* b)
str·grow(s, n);
if (*s == nil) return;
- Hdr* h = (Hdr*)(s - sizeof(Hdr));
+ Hdr* h = (Hdr*)(*s - sizeof(Hdr));
memcpy(*s + str·len(*s), b, n);
h->len += n;
- *s[h->len] = '\0';
+ (*s)[h->len] = '\0';
}
// Append will append the given null terminated C string to the string data
@@ -379,11 +379,11 @@ str·appendbyte(string *s, const byte b)
str·grow(s, 1);
if (*s == nil) return;
- Hdr* h = (Hdr*)(s - sizeof(Hdr));
+ Hdr* h = (Hdr*)(*s - sizeof(Hdr));
*(*s + str·len(*s)) = b;
h->len++;
- *s[h->len] = '\0'; // NOTE: I don't think an explicit zero is required..?
+ (*s)[h->len] = '\0'; // NOTE: I don't think an explicit zero is required..?
}
/*