Contents of /trunk/netkit-rsh/patches/netkit-rsh-0.17-stdarg.patch
Parent Directory | Revision Log
Revision 153 -
(show annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 952 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 952 byte(s)
-import
1 | --- netkit-rsh-0.10/rcp/rcp.c 1999-04-18 05:16:49-04 1.1 |
2 | +++ netkit-rsh-0.10/rcp/rcp.c 1999-04-18 05:40:52-04 |
3 | @@ -836,19 +836,33 @@ |
4 | error(const char *fmt, ...) |
5 | { |
6 | static FILE *fp; |
7 | - va_list ap; |
8 | - |
9 | - va_start(ap, fmt); |
10 | + char buf[1000]; |
11 | |
12 | ++errs; |
13 | if (!fp && !(fp = fdopen(rem, "w"))) |
14 | return; |
15 | - fprintf(fp, "%c", 0x01); |
16 | - vfprintf(fp, fmt, ap); |
17 | + |
18 | + /* (fmt,...) might need to go to two streams. |
19 | + * |
20 | + * In { va_start ; vfprintf ; vfprintf ; va_end }, second |
21 | + * vfprintf didn't restart (ie: vfprintf affects ap) (glibc) |
22 | + * |
23 | + * Is { va_start ; vfprintf ; va_end} * 2 even allowed? |
24 | + * |
25 | + * => Dump (fmt,...) to buffer. */ |
26 | + |
27 | + { |
28 | + va_list ap; |
29 | + va_start(ap, fmt); |
30 | + vsnprintf(buf, sizeof(buf), fmt, ap); |
31 | + buf[sizeof(buf)-1] = 0; |
32 | + va_end(ap); |
33 | + } |
34 | + |
35 | + fprintf(fp, "%c%s", 0x01, buf); |
36 | fflush(fp); |
37 | - if (!iamremote) vfprintf(stderr, fmt, ap); |
38 | |
39 | - va_end(ap); |
40 | + if (!iamremote) fputs(buf, stderr); |
41 | } |
42 | |
43 | static void |