Obviously I could have gone the other direction and made xputc() use xferror() like xputs() did, but given that xferror() is only used in vi, and not obviously meaningful there, I'm assuming that xferror() probably won't last...
Also remove an obsolete comment that applied to xflush() but not xferror(). --- lib/xwrap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
From 47ac0fb31a8283f818dcb6e10090dea39bf6e2af Mon Sep 17 00:00:00 2001 From: Elliott Hughes <e...@google.com> Date: Mon, 22 Jan 2024 15:51:39 -0800 Subject: [PATCH] xwrap: implement xputs() like xputc(). Obviously I could have gone the other direction and made xputc() use xferror() like xputs() did, but given that xferror() is only used in vi, and not obviously meaningful there, I'm assuming that xferror() probably won't last... Also remove an obsolete comment that applied to xflush() but not xferror(). --- lib/xwrap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/xwrap.c b/lib/xwrap.c index d2e787e1..494ee2fa 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -142,7 +142,6 @@ char *xmprintf(char *format, ...) return ret; } -// if !flush just check for error on stdout without flushing void xferror(FILE *fp) { if (ferror(fp)) perror_exit("write"); @@ -175,8 +174,7 @@ void xputsn(char *s) // Write string to stdout with newline, flushing and checking for errors void xputs(char *s) { - puts(s); - xferror(stdout); + if (EOF == puts(s)) perror_exit("write"); } void xputc(char c) -- 2.43.0.429.g432eaa2c6b-goog
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net