about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/include/skalibs/siovec.h1
-rw-r--r--src/libstddjb/buffer_get.c9
-rw-r--r--src/libstddjb/buffer_getv.c5
-rw-r--r--src/libstddjb/slurpn.c2
4 files changed, 10 insertions, 7 deletions
diff --git a/src/include/skalibs/siovec.h b/src/include/skalibs/siovec.h
index 46d9a81..5a64be0 100644
--- a/src/include/skalibs/siovec.h
+++ b/src/include/skalibs/siovec.h
@@ -16,5 +16,6 @@ extern unsigned int siovec_trunc (struct iovec *, unsigned int, size_t) ;
 
 extern size_t siovec_bytechr (struct iovec const *, unsigned int, char) ;
 extern size_t siovec_bytein (struct iovec const *, unsigned int, char const *, size_t) ;
+extern size_t siovec_search (struct iovec const *, unsigned int, char const *, size_t) ;
 
 #endif
diff --git a/src/libstddjb/buffer_get.c b/src/libstddjb/buffer_get.c
index fbc0de3..6fe394d 100644
--- a/src/libstddjb/buffer_get.c
+++ b/src/libstddjb/buffer_get.c
@@ -1,12 +1,13 @@
 /* ISC license. */
 
-#include <errno.h>
+#include <stddef.h>
+
+#include <skalibs/allreadwrite.h>
 #include <skalibs/buffer.h>
 
 ssize_t buffer_get (buffer *b, char *s, size_t len)
 {
   size_t w = 0 ;
-  int r = buffer_getall(b, s, len, &w) ;
-  return r == -1 ? errno == EPIPE ? (errno = 0, w) : -1 :
-         !r ? (errno = EWOULDBLOCK, -1) : w ;
+  ssize_t r = unsanitize_read(buffer_getall(b, s, len, &w)) ;
+  return r < 0 ? r : w ;
 }
diff --git a/src/libstddjb/buffer_getv.c b/src/libstddjb/buffer_getv.c
index 280a3b4..ab637a3 100644
--- a/src/libstddjb/buffer_getv.c
+++ b/src/libstddjb/buffer_getv.c
@@ -1,6 +1,7 @@
 /* ISC license. */
 
-#include <sys/uio.h>
+#include <stddef.h>
+
 #include <skalibs/allreadwrite.h>
 #include <skalibs/buffer.h>
 
@@ -8,5 +9,5 @@ ssize_t buffer_getv (buffer *b, struct iovec const *v, unsigned int n)
 {
   size_t w = 0 ;
   ssize_t r = unsanitize_read(buffer_getvall(b, v, n, &w)) ;
-  return r <= 0 ? r : w ;
+  return r < 0 ? r : w ;
 }
diff --git a/src/libstddjb/slurpn.c b/src/libstddjb/slurpn.c
index c9c5c11..ee5157f 100644
--- a/src/libstddjb/slurpn.c
+++ b/src/libstddjb/slurpn.c
@@ -16,7 +16,7 @@ int slurpn (int fd, stralloc *sa, size_t max)
   for (;;)
   {
     ssize_t r ;
-    size_t n = max && sa->len + N > max ? max - sa->len : N ;
+    size_t n = max && sa->len - sabase + N > max ? max - (sa->len - sabase) : N ;
     if (!n) { errno = ENOBUFS ; goto err ; }
     if (!stralloc_readyplus(sa, n)) break ;
     r = fd_read(fd, sa->s + sa->len, n) ;