summaryrefslogtreecommitdiff
path: root/print.c
diff options
context:
space:
mode:
authortgoodwin <tgoodwin>1998-10-28 14:15:21 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:12 +0100
commitf034ca39df7f6f513d0d4d4f479194592ac48645 (patch)
tree4ab1c68a27cf65c5213df77c0a2e51f59a66c498 /print.c
parentd535c86b0f886e1c4cf0ae73048bf4bdba6d0813 (diff)
use va_copy() where it exists
Diffstat (limited to 'print.c')
-rw-r--r--print.c110
1 files changed, 6 insertions, 104 deletions
diff --git a/print.c b/print.c
index b1de94b..9ccccc4 100644
--- a/print.c
+++ b/print.c
@@ -289,11 +289,11 @@ extern int fmtprint(Format *format, const char *fmt,...) {
va_list ap, saveargs;
va_start(ap, fmt);
- saveargs = format->args;
- format->args = ap;
+ va_copy(saveargs, format->args);
+ va_copy(format->args, ap);
n += printfmt(format, fmt);
va_end(format->args);
- format->args = saveargs;
+ va_copy(format->args, saveargs);
return n + format->flushed;
}
@@ -320,7 +320,7 @@ extern int fprint(int fd, const char *fmt,...) {
format.u.n = fd;
va_start(ap, fmt);
- format.args = ap;
+ va_copy(format.args, ap);
printfmt(&format, fmt);
va_end(format.args);
@@ -365,7 +365,7 @@ extern char *mprint(const char *fmt,...) {
format.u.n = 1;
va_start(ap, fmt);
- format.args = ap;
+ va_copy(format.args, ap);
result = memprint(&format, fmt, ealloc(PRINT_ALLOCSIZE), PRINT_ALLOCSIZE);
va_end(format.args);
return result;
@@ -378,106 +378,8 @@ extern char *nprint(const char *fmt,...) {
format.u.n = 0;
va_start(ap, fmt);
- format.args = ap;
+ va_copy(format.args, ap);
result = memprint(&format, fmt, nalloc(PRINT_ALLOCSIZE), PRINT_ALLOCSIZE);
va_end(format.args);
return result;
}
-
-
-/* THESE ARE UNUSED IN rc */
-
-#if 0
-
-extern int print(const char *fmt,...) {
- char buf[1024];
- Format format;
-
- format.buf = buf;
- format.bufbegin = buf;
- format.bufend = buf + sizeof buf;
- format.grow = fprint_flush;
- format.flushed = 0;
- format.u.n = 1;
-
- va_start(format.args, fmt);
- printfmt(&format, fmt);
- va_end(format.args);
-
- fprint_flush(&format, 0);
- return format.flushed;
-}
-
-extern int eprint(const char *fmt,...) {
- char buf[1024];
- Format format;
-
- format.buf = buf;
- format.bufbegin = buf;
- format.bufend = buf + sizeof buf;
- format.grow = fprint_flush;
- format.flushed = 0;
- format.u.n = 2;
-
- va_start(format.args, fmt);
- printfmt(&format, fmt);
- va_end(format.args);
-
- fprint_flush(&format, 0);
- return format.flushed;
-}
-
-static void snprint_grow(Format *format, size_t more) {
- longjmp(format->u.p, 1);
-}
-
-extern int snprint(char *buf, int buflen, const char *fmt,...) {
- int n;
- jmp_buf jbuf;
- Format format;
-
- if (setjmp(jbuf)) {
- *format.buf = '\0';
- return format.buf - format.bufbegin;
- }
-
- format.buf = buf;
- format.bufbegin = buf;
- format.bufend = buf + buflen - 1;
- format.grow = snprint_grow;
- format.flushed = 0;
- format.u.p = jbuf;
-
- va_start(format.args, fmt);
- n = printfmt(&format, fmt);
- va_end(format.args);
-
- *format.buf = '\0';
- return n;
-}
-
-extern int sprint(char *buf, const char *fmt,...) {
- int n;
- jmp_buf jbuf;
- Format format;
-
- if (setjmp(jbuf)) {
- *format.buf = '\0';
- return format.buf - format.bufbegin;
- }
-
- format.buf = buf;
- format.bufbegin = buf;
- format.bufend = buf + SPRINT_BUFSIZ - 1;
- format.grow = snprint_grow;
- format.flushed = 0;
- format.u.p = jbuf;
-
- va_start(format.args, fmt);
- n = printfmt(&format, fmt);
- va_end(format.args);
-
- *format.buf = '\0';
- return n;
-}
-#endif