commit 3fb8d27d07565d86ee45d4bb4d7a3fa4a94f3176
parent 3bfee62a25825f1dbd87d9420cb833fc2407365f
Author: Rolf Eike Beer <eike@sf-mail.de>
Date: Mon, 15 Jun 2020 20:16:00 +0200
convert some additional substdio functions to return ssize_t
Diffstat:
4 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/getln2.c b/getln2.c
@@ -12,12 +12,12 @@ int sep;
{
register char *x;
register unsigned int i;
- int n;
if (!stralloc_ready(sa,0)) return -1;
sa->len = 0;
for (;;) {
+ ssize_t n;
n = substdio_feed(ss);
if (n < 0) return -1;
if (n == 0) { *clen = 0; return 0; }
diff --git a/substdi.c b/substdi.c
@@ -2,7 +2,7 @@
#include "byte.h"
#include "error.h"
-static int oneread(ssize_t (*op)(), int fd, char *buf, size_t len)
+static ssize_t oneread(ssize_t (*op)(), int fd, char *buf, size_t len)
{
for (;;) {
ssize_t r = op(fd,buf,len);
@@ -27,10 +27,9 @@ register int len;
return r;
}
-int substdio_feed(s)
-register substdio *s;
+ssize_t substdio_feed(substdio *s)
{
- register int r;
+ ssize_t r;
register int q;
if (s->p) return s->p;
@@ -44,12 +43,9 @@ register substdio *s;
return r;
}
-int substdio_get(s,buf,len)
-register substdio *s;
-register char *buf;
-register int len;
+ssize_t substdio_get(substdio *s, char *buf, size_t len)
{
- register int r;
+ ssize_t r;
if (s->p > 0) return getthis(s,buf,len);
if (s->n <= len) return oneread(s->op,s->fd,buf,len);
diff --git a/substdio.h b/substdio.h
@@ -23,8 +23,8 @@ extern int substdio_puts();
extern int substdio_bputs();
extern int substdio_putsflush();
-extern int substdio_get();
-extern int substdio_feed();
+extern ssize_t substdio_get(substdio *s, char *buf, size_t len);
+extern ssize_t substdio_feed(substdio *s);
extern char *substdio_peek();
extern void substdio_seek();
diff --git a/substdio_copy.c b/substdio_copy.c
@@ -4,10 +4,10 @@ int substdio_copy(ssout,ssin)
register substdio *ssout;
register substdio *ssin;
{
- register int n;
register char *x;
for (;;) {
+ ssize_t n;
n = substdio_feed(ssin);
if (n < 0) return -2;
if (!n) return 0;