From 5084feadff6503852bf11019baa3e943bbcd4305 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 18 Jun 2007 00:14:03 -0400 Subject: Add xputs() to detect EOF on writes. --- lib/lib.c | 5 +++++ lib/lib.h | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/lib.c b/lib/lib.c index 4e0ef73f..aca70c40 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -155,6 +155,11 @@ void xprintf(char *format, ...) if (ferror(stdout)) perror_exit("write"); } +void xputs(char *s) +{ + if (EOF == puts(s)) perror_exit("write"); +} + void xputc(char c) { if (EOF == fputc(c, stdout)) perror_exit("write"); diff --git a/lib/lib.h b/lib/lib.h index f0d92419..baa52681 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -48,6 +48,7 @@ void *xstrndup(char *s, size_t n); void *xstrdup(char *s); char *xmsprintf(char *format, ...); void xprintf(char *format, ...); +void xputs(char *s); void xputc(char c); void xflush(void); void xexec(char **argv); -- cgit v1.2.3