summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-17 04:49:12 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-17 04:49:12 +0000
commit51028f34ceeb7c4c91abc2ac2b818afeaa671b91 (patch)
tree165d143b47736e6438b31cfb98d80fdc11cdcbb5
parentd79e55530924e8fc9b33991ab4df33653480ec0a (diff)
downloadglibc-51028f34ceeb7c4c91abc2ac2b818afeaa671b91.tar.gz
Update.
* libio/tst-ungetwc2.c (main): Define str const. * include/wchar.h: Add prototypes for __fwprintf and __vfwprintf. * libio/fwprintf.c: Also define __fwprintf. * stdio-common/vfprintf.c [COMPILE_WPRINTF]: Also define __vfwprintf. * argp/argp-fmtstream.c: Handle wide oriented stderr stream. * assert/assert-perr.c: Likewise. * assert/assert.c: Likewise. * gmon/gmon.c: Likewise. * inet/rcmd.c: Likewise. * malloc/obstack.c: Likewise. * misc/err.c: Likewise. * misc/error.c: Likewise. * misc/getpass.c: Likewise. * posix/getopt.c: Likewise. * resolv/res_hconf.c: Likewise. * stdio-common/perror.c: Likewise. * stdio-common/psignal.c: Likewise. * stdlib/fmtmsg.c: Likewise. * sunrpc/auth_unix.c: Likewise. * sunrpc/clnt_perr.c: Likewise. * sunrpc/clnt_tcp.c: Likewise. * sunrpc/clnt_udp.c: Likewise. * sunrpc/clnt_unix.c: Likewise. * sunrpc/svc_simple.c: Likewise. * sunrpc/svc_tcp.c: Likewise. * sunrpc/svc_udp.c: Likewise. * sunrpc/svc_unix.c: Likewise. * sunrpc/xdr.c: Likewise. * sunrpc/xdr_array.c: Likewise. * sunrpc/xdr_rec.c: Likewise. * sunrpc/xdr_ref.c: Likewise. * sysdeps/generic/wordexp.c: Likewise. * misc/err.c: Handle wide oriented stderr stream.
-rw-r--r--ChangeLog36
-rw-r--r--argp/argp-fmtstream.c60
-rw-r--r--assert/assert-perr.c27
-rw-r--r--assert/assert.c27
-rw-r--r--gmon/gmon.c10
-rw-r--r--include/wchar.h7
-rw-r--r--inet/rcmd.c131
-rw-r--r--libio/fwprintf.c5
-rw-r--r--libio/tst-ungetwc2.c2
-rw-r--r--malloc/obstack.c11
-rw-r--r--misc/err.c8
-rw-r--r--misc/error.c10
-rw-r--r--misc/getpass.c18
-rw-r--r--posix/getopt.c259
-rw-r--r--resolv/res_hconf.c135
-rw-r--r--stdio-common/perror.c2
-rw-r--r--stdio-common/psignal.c30
-rw-r--r--stdio-common/vfprintf.c3
-rw-r--r--stdlib/fmtmsg.c55
-rw-r--r--sunrpc/auth_unix.c27
-rw-r--r--sunrpc/clnt_perr.c22
-rw-r--r--sunrpc/clnt_tcp.c27
-rw-r--r--sunrpc/clnt_udp.c23
-rw-r--r--sunrpc/clnt_unix.c24
-rw-r--r--sunrpc/svc_simple.c52
-rw-r--r--sunrpc/svc_tcp.c37
-rw-r--r--sunrpc/svc_udp.c45
-rw-r--r--sunrpc/svc_unix.c40
-rw-r--r--sunrpc/xdr.c20
-rw-r--r--sunrpc/xdr_array.c14
-rw-r--r--sunrpc/xdr_rec.c18
-rw-r--r--sunrpc/xdr_ref.c9
-rw-r--r--sysdeps/generic/wordexp.c43
33 files changed, 958 insertions, 279 deletions
diff --git a/ChangeLog b/ChangeLog
index aac8d4ccf6..6f2f4e9cac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,42 @@
2001-08-16 Ulrich Drepper <drepper@redhat.com>
+ * libio/tst-ungetwc2.c (main): Define str const.
+
+ * include/wchar.h: Add prototypes for __fwprintf and __vfwprintf.
+ * libio/fwprintf.c: Also define __fwprintf.
+ * stdio-common/vfprintf.c [COMPILE_WPRINTF]: Also define __vfwprintf.
+ * argp/argp-fmtstream.c: Handle wide oriented stderr stream.
+ * assert/assert-perr.c: Likewise.
+ * assert/assert.c: Likewise.
+ * gmon/gmon.c: Likewise.
+ * inet/rcmd.c: Likewise.
+ * malloc/obstack.c: Likewise.
+ * misc/err.c: Likewise.
+ * misc/error.c: Likewise.
+ * misc/getpass.c: Likewise.
+ * posix/getopt.c: Likewise.
+ * resolv/res_hconf.c: Likewise.
+ * stdio-common/perror.c: Likewise.
+ * stdio-common/psignal.c: Likewise.
+ * stdlib/fmtmsg.c: Likewise.
+ * sunrpc/auth_unix.c: Likewise.
+ * sunrpc/clnt_perr.c: Likewise.
+ * sunrpc/clnt_tcp.c: Likewise.
+ * sunrpc/clnt_udp.c: Likewise.
+ * sunrpc/clnt_unix.c: Likewise.
+ * sunrpc/svc_simple.c: Likewise.
+ * sunrpc/svc_tcp.c: Likewise.
+ * sunrpc/svc_udp.c: Likewise.
+ * sunrpc/svc_unix.c: Likewise.
+ * sunrpc/xdr.c: Likewise.
+ * sunrpc/xdr_array.c: Likewise.
+ * sunrpc/xdr_rec.c: Likewise.
+ * sunrpc/xdr_ref.c: Likewise.
+ * sysdeps/generic/wordexp.c: Likewise.
+
* po/it.po: Update from translation team.
- * misc/err.c: Handle wide oriented stderr.
+ * misc/err.c: Handle wide oriented stderr stream.
2001-08-14 Tom Rix <trix@redhat.com>
diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 9c029c265a..fca89a382d 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -1,5 +1,5 @@
/* Word-wrapping and line-truncating streams
- Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -41,6 +41,7 @@
#endif
#if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
# include <libio/libioP.h>
# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
#endif
@@ -58,8 +59,10 @@ argp_fmtstream_t
__argp_make_fmtstream (FILE *stream,
size_t lmargin, size_t rmargin, ssize_t wmargin)
{
- argp_fmtstream_t fs = malloc (sizeof (struct argp_fmtstream));
- if (fs)
+ argp_fmtstream_t fs;
+
+ fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
+ if (fs != NULL)
{
fs->stream = stream;
@@ -69,7 +72,7 @@ __argp_make_fmtstream (FILE *stream,
fs->point_col = 0;
fs->point_offs = 0;
- fs->buf = malloc (INIT_BUF_SIZE);
+ fs->buf = (char *) malloc (INIT_BUF_SIZE);
if (! fs->buf)
{
free (fs);
@@ -94,7 +97,14 @@ __argp_fmtstream_free (argp_fmtstream_t fs)
{
__argp_fmtstream_update (fs);
if (fs->p > fs->buf)
- fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+ {
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (fs->stream, 0) > 0)
+ fwprintf (fs->stream, L"%.*s", (int) (fs->p - fs->buf), fs->buf);
+ else
+#endif
+ fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+ }
free (fs->buf);
free (fs);
}
@@ -134,7 +144,14 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
/* No buffer space for spaces. Must flush. */
size_t i;
for (i = 0; i < pad; i++)
- putc_unlocked (' ', fs->stream);
+ {
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (fs->stream, 0) > 0)
+ putwc_unlocked (L' ', fs->stream);
+ else
+#endif
+ putc_unlocked (' ', fs->stream);
+ }
}
fs->point_col = pad;
}
@@ -267,9 +284,17 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
else
/* Output the first line so we can use the space. */
{
- if (nl > fs->buf)
- fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
- putc_unlocked ('\n', fs->stream);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (fs->stream, 0) > 0)
+ fwprintf (fs->stream, L"%.*s\n",
+ (int) (nl - fs->buf), fs->buf);
+ else
+#endif
+ {
+ if (nl > fs->buf)
+ fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
+ putc_unlocked ('\n', fs->stream);
+ }
len += buf - fs->buf;
nl = buf = fs->buf;
}
@@ -286,7 +311,12 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
*nl++ = ' ';
else
for (i = 0; i < fs->wmargin; ++i)
- putc_unlocked (' ', fs->stream);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (fs->stream, 0) > 0)
+ putwc_unlocked (L' ', fs->stream);
+ else
+#endif
+ putc_unlocked (' ', fs->stream);
/* Copy the tail of the original buffer into the current buffer
position. */
@@ -323,7 +353,15 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
/* Flush FS's buffer. */
__argp_fmtstream_update (fs);
- wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (fs->stream, 0) > 0)
+ {
+ __fwprintf (fs->stream, L"%.*s", (int) (fs->p - fs->buf), fs->buf);
+ wrote = fs->p - fs->buf;
+ }
+ else
+#endif
+ wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
if (wrote == fs->p - fs->buf)
{
fs->p = fs->buf;
diff --git a/assert/assert-perr.c b/assert/assert-perr.c
index 436a9ce8c3..597ac5efb4 100644
--- a/assert/assert-perr.c
+++ b/assert/assert-perr.c
@@ -17,16 +17,17 @@
02111-1307 USA. */
#include <assert.h>
+#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysdep.h>
-#include <libintl.h>
extern const char *__progname;
#ifdef USE_IN_LIBIO
+# include <wchar.h>
# include <libio/iolibio.h>
# define fflush(s) _IO_fflush (s)
#endif
@@ -46,17 +47,31 @@ __assert_perror_fail (int errnum,
const char *function)
{
char errbuf[1024];
+ char *buf;
+
#ifdef FATAL_PREPARE
FATAL_PREPARE;
#endif
+ (void) __asprintf (&buf, _("%s%s%s:%u: %s%sUnexpected error: %s.\n"),
+ __progname, __progname[0] ? ": " : "",
+ file, line,
+ function ? function : "", function ? ": " : "",
+ __strerror_r (errnum, errbuf, sizeof errbuf));
+
/* Print the message. */
- (void) fprintf (stderr, _("%s%s%s:%u: %s%sUnexpected error: %s.\n"),
- __progname, __progname[0] ? ": " : "",
- file, line,
- function ? function : "", function ? ": " : "",
- __strerror_r (errnum, errbuf, sizeof errbuf));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ (void) fputs (buf, stderr);
+
(void) fflush (stderr);
+ /* We have to free the buffer since the appplication might catch the
+ SIGABRT. */
+ free (buf);
+
abort ();
}
diff --git a/assert/assert.c b/assert/assert.c
index 81ad080413..df382456e3 100644
--- a/assert/assert.c
+++ b/assert/assert.c
@@ -17,15 +17,16 @@
02111-1307 USA. */
#include <assert.h>
+#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysdep.h>
-#include <libintl.h>
extern const char *__progname;
#ifdef USE_IN_LIBIO
+# include <wchar.h>
# include <libio/iolibio.h>
# define fflush(s) _IO_fflush (s)
#endif
@@ -44,17 +45,31 @@ void
__assert_fail (const char *assertion, const char *file, unsigned int line,
const char *function)
{
+ char *buf;
+
#ifdef FATAL_PREPARE
FATAL_PREPARE;
#endif
+ (void) __asprintf (&buf, _("%s%s%s:%u: %s%sAssertion `%s' failed.\n"),
+ __progname, __progname[0] ? ": " : "",
+ file, line,
+ function ? function : "", function ? ": " : "",
+ assertion);
+
/* Print the message. */
- (void) fprintf (stderr, _("%s%s%s:%u: %s%sAssertion `%s' failed.\n"),
- __progname, __progname[0] ? ": " : "",
- file, line,
- function ? function : "", function ? ": " : "",
- assertion);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ (void) fputs (buf, stderr);
+
(void) fflush (stderr);
+ /* We have to free the buffer since the appplication might catch the
+ SIGABRT. */
+ free (buf);
+
abort ();
}
diff --git a/gmon/gmon.c b/gmon/gmon.c
index 8c8906eca4..c8923ab9da 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -331,8 +331,14 @@ write_gmon (void)
{
char buf[300];
int errnum = errno;
- fprintf (stderr, "_mcleanup: gmon.out: %s\n",
- __strerror_r (errnum, buf, sizeof buf));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"_mcleanup: gmon.out: %s\n",
+ __strerror_r (errnum, buf, sizeof buf));
+ else
+#endif
+ fprintf (stderr, "_mcleanup: gmon.out: %s\n",
+ __strerror_r (errnum, buf, sizeof buf));
return;
}
}
diff --git a/include/wchar.h b/include/wchar.h
index 818afff3ea..0b5556ed51 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -53,6 +53,13 @@ extern int __vswprintf (wchar_t *__restrict __s, size_t __n,
__const wchar_t *__restrict __format,
__gnuc_va_list __arg)
/* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
+extern int __fwprintf (__FILE *__restrict __s,
+ __const wchar_t *__restrict __format, ...)
+ /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
+extern int __vfwprintf (__FILE *__restrict __s,
+ __const wchar_t *__restrict __format,
+ __gnuc_va_list __arg)
+ /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
# endif
#endif
diff --git a/inet/rcmd.c b/inet/rcmd.c
index de00bfaf13..7d974f3e0c 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -80,6 +80,9 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#include <string.h>
#include <libintl.h>
#include <stdlib.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
int __ivaliduser (FILE *, u_int32_t, const char *, const char *);
@@ -133,8 +136,14 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
(void)__snprintf(num, sizeof(num), "%d", ntohs(rport));
error = getaddrinfo(*ahost, num, &hints, &res);
if (error) {
- fprintf(stderr, "rcmd: getaddrinfo: %s\n",
- gai_strerror(error));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf(stderr, L"rcmd: getaddrinfo: %s\n",
+ gai_strerror(error));
+ else
+#endif
+ fprintf(stderr, "rcmd: getaddrinfo: %s\n",
+ gai_strerror(error));
return (-1);
}
@@ -152,13 +161,28 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
refused = 0;
oldmask = __sigblock(sigmask(SIGURG));
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
+ char errbuf[200];
+
s = rresvport_af(&lport, ai->ai_family);
if (s < 0) {
- if (errno == EAGAIN)
- fprintf(stderr,
- _("rcmd: socket: All ports in use\n"));
- else
- fprintf(stderr, "rcmd: socket: %m\n");
+ if (errno == EAGAIN) {
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf(stderr, L"%s",
+ _("rcmd: socket: All ports in use\n"));
+ else
+#endif
+ fputs(_("rcmd: socket: All ports in use\n"),
+ stderr);
+ } else {
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf(stderr,
+ L"rcmd: socket: %m\n");
+ else
+#endif
+ fprintf(stderr, "rcmd: socket: %m\n");
+ }
__sigsetmask(oldmask);
freeaddrinfo(res);
return -1;
@@ -175,12 +199,20 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
refused = 1;
if (ai->ai_next != NULL) {
int oerrno = errno;
+ char *buf = NULL;
getnameinfo(ai->ai_addr, ai->ai_addrlen,
paddr, sizeof(paddr),
NULL, 0,
NI_NUMERICHOST);
- fprintf(stderr, "connect to address %s: ", paddr);
+
+ asprintf (&buf, _("connect to address %s: "), paddr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf(stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
__set_errno (oerrno);
perror(0);
ai = ai->ai_next;
@@ -188,7 +220,14 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
paddr, sizeof(paddr),
NULL, 0,
NI_NUMERICHOST);
- fprintf(stderr, "Trying %s...\n", paddr);
+ asprintf (&buf, _("Trying %s...\n"), paddr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+ free (buf);
continue;
}
if (refused && timo <= 16) {
@@ -199,7 +238,16 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
continue;
}
freeaddrinfo(res);
- (void)fprintf(stderr, "%s: %s\n", *ahost, strerror(errno));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void)__fwprintf(stderr, L"%s: %s\n", *ahost,
+ __strerror_r(errno,
+ errbuf, sizeof (errbuf)));
+ else
+#endif
+ (void)fprintf(stderr, "%s: %s\n", *ahost,
+ __strerror_r(errno,
+ errbuf, sizeof (errbuf)));
__sigsetmask(oldmask);
return -1;
}
@@ -217,8 +265,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
listen(s2, 1);
(void)__snprintf(num, sizeof(num), "%d", lport);
if (__write(s, num, strlen(num)+1) != (ssize_t)strlen(num)+1) {
- (void)fprintf(stderr,
- _("rcmd: write (setting up stderr): %m\n"));
+ char *buf = NULL;
+
+ asprintf (&buf,
+ _("rcmd: write (setting up stderr): %m\n"));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf(stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+ free (buf);
(void)__close(s2);
goto bad;
}
@@ -226,12 +283,21 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
pfd[1].fd = s2;
__set_errno (0);
if (__poll (pfd, 2, -1) < 1 || (pfd[1].revents & POLLIN) == 0){
+ char *buf = NULL;
+
if (errno != 0)
- (void)fprintf(stderr,
+ asprintf(&buf,
_("rcmd: poll (setting up stderr): %m\n"));
else
- (void)fprintf(stderr,
+ asprintf(&buf,
_("poll: protocol failure in circuit setup\n"));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+ free (buf);
(void)__close(s2);
goto bad;
}
@@ -249,16 +315,31 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
}
(void)__close(s2);
if (s3 < 0) {
- (void)fprintf(stderr,
- "rcmd: accept: %m\n");
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void)__fwprintf(stderr,
+ L"rcmd: accept: %m\n");
+ else
+#endif
+ (void)fprintf(stderr,
+ "rcmd: accept: %m\n");
lport = 0;
goto bad;
}
*fd2p = s3;
if (rport >= IPPORT_RESERVED || rport < IPPORT_RESERVED / 2){
- (void)fprintf(stderr,
- _("socket: protocol failure in circuit setup\n"));
+ char *buf = NULL;
+
+ asprintf(&buf,
+ _("socket: protocol failure in circuit setup\n"));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+ free (buf);
goto bad2;
}
}
@@ -267,11 +348,19 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
(void)__write(s, cmd, strlen(cmd)+1);
n = __read(s, &c, 1);
if (n != 1) {
+ char *buf = NULL;
+
if (n == 0)
- (void)fprintf(stderr, _("rcmd: %s: short read"),
- *ahost);
+ asprintf(&buf, _("rcmd: %s: short read"), *ahost);
+ else
+ asprintf(&buf, "rcmd: %s: %m\n", *ahost);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
else
- (void)fprintf(stderr, "rcmd: %s: %m\n", *ahost);
+#endif
+ fputs (buf, stderr);
+ free (buf);
goto bad2;
}
if (c != 0) {
diff --git a/libio/fwprintf.c b/libio/fwprintf.c
index ece710dfde..6f30bc1f55 100644
--- a/libio/fwprintf.c
+++ b/libio/fwprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,7 +24,7 @@
/* Write formatted output to STREAM from the format string FORMAT. */
/* VARARGS2 */
int
-fwprintf (FILE *stream, const wchar_t *format, ...)
+__fwprintf (FILE *stream, const wchar_t *format, ...)
{
va_list arg;
int done;
@@ -35,3 +35,4 @@ fwprintf (FILE *stream, const wchar_t *format, ...)
return done;
}
+weak_alias (__fwprintf, fwprintf)
diff --git a/libio/tst-ungetwc2.c b/libio/tst-ungetwc2.c
index 64efa9d619..d15e287c05 100644
--- a/libio/tst-ungetwc2.c
+++ b/libio/tst-ungetwc2.c
@@ -11,7 +11,7 @@ int
main (void)
{
FILE *fp;
- char *str = "abcdef";
+ const char *str = "abcdef";
wint_t ret, wc;
char fname[] = "/tmp/tst-ungetwc2.out.XXXXXX";
int fd;
diff --git a/malloc/obstack.c b/malloc/obstack.c
index dcc5cce386..2e50397150 100644
--- a/malloc/obstack.c
+++ b/malloc/obstack.c
@@ -481,8 +481,15 @@ static void
__attribute__ ((noreturn))
print_and_abort ()
{
- fputs (_("memory exhausted"), stderr);
- fputc ('\n', stderr);
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s\n", _("memory exhausted"));
+ else
+#endif
+ {
+ fputs (_("memory exhausted"), stderr);
+ fputc ('\n', stderr);
+ }
exit (obstack_exit_failure);
}
diff --git a/misc/err.c b/misc/err.c
index dc7025c670..24b615b750 100644
--- a/misc/err.c
+++ b/misc/err.c
@@ -83,7 +83,7 @@ convert_and_print (const char *format, __gnuc_va_list ap)
/* The string cannot be converted. */
wformat = (wchar_t *) L"???";
- vfwprintf (stderr, wformat, ap);
+ __vfwprintf (stderr, wformat, ap);
}
#endif
@@ -94,7 +94,7 @@ vwarnx (const char *format, __gnuc_va_list ap)
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
{
- fwprintf (stderr, L"%s: ", __progname);
+ __fwprintf (stderr, L"%s: ", __progname);
convert_and_print (format, ap);
putwc_unlocked (L'\n', stderr);
}
@@ -118,14 +118,14 @@ vwarn (const char *format, __gnuc_va_list ap)
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
{
- fwprintf (stderr, L"%s: ", __progname);
+ __fwprintf (stderr, L"%s: ", __progname);
if (format)
{
convert_and_print (format, ap);
fputws_unlocked (L": ", stderr);
}
__set_errno (error);
- fwprintf (stderr, L"%m\n");
+ __fwprintf (stderr, L"%m\n");
}
else
#endif
diff --git a/misc/error.c b/misc/error.c
index 40b949879c..86d49a52a6 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -164,7 +164,7 @@ error_tail (int status, int errnum, const char *message, va_list args)
/* The string cannot be converted. */
wmessage = (wchar_t *) L"???";
- vfwprintf (stderr, wmessage, args);
+ __vfwprintf (stderr, wmessage, args);
}
else
# endif
@@ -182,7 +182,7 @@ error_tail (int status, int errnum, const char *message, va_list args)
char *s = __strerror_r (errnum, errbuf, sizeof errbuf);
# ifdef _LIBC
if (_IO_fwide (stderr, 0) > 0)
- fwprintf (stderr, L": %s", s);
+ __fwprintf (stderr, L": %s", s);
else
# endif
fprintf (stderr, ": %s", s);
@@ -233,7 +233,7 @@ error (status, errnum, message, va_alist)
{
#ifdef _LIBC
if (_IO_fwide (stderr, 0) > 0)
- fwprintf (stderr, L"%s: ", program_name);
+ __fwprintf (stderr, L"%s: ", program_name);
else
#endif
fprintf (stderr, "%s: ", program_name);
@@ -305,7 +305,7 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
{
#ifdef _LIBC
if (_IO_fwide (stderr, 0) > 0)
- fwprintf (stderr, L"%s: ", program_name);
+ __fwprintf (stderr, L"%s: ", program_name);
else
#endif
fprintf (stderr, "%s:", program_name);
@@ -315,7 +315,7 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
{
#ifdef _LIBC
if (_IO_fwide (stderr, 0) > 0)
- fwprintf (stderr, L"%s:%d: ", file_name, line_number);
+ __fwprintf (stderr, L"%s:%d: ", file_name, line_number);
else
#endif
fprintf (stderr, "%s:%d: ", file_name, line_number);
diff --git a/misc/getpass.c b/misc/getpass.c
index 04ac12a76d..c392221f67 100644
--- a/misc/getpass.c
+++ b/misc/getpass.c
@@ -79,7 +79,12 @@ getpass (prompt)
tty_changed = 0;
/* Write the prompt. */
- fputs_unlocked (prompt, out);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (out, 0) > 0)
+ __fwprintf (out, L"%s", prompt);
+ else
+#endif
+ fputs_unlocked (prompt, out);
fflush_unlocked (out);
/* Read the password. */
@@ -93,8 +98,15 @@ getpass (prompt)
/* Remove the newline. */
buf[nread - 1] = '\0';
if (tty_changed)
- /* Write the newline that was not echoed. */
- putc_unlocked ('\n', out);
+ {
+ /* Write the newline that was not echoed. */
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (out, 0) > 0)
+ putwc_unlocked (L'\n', out);
+ else
+#endif
+ putc_unlocked ('\n', out);
+ }
}
}
diff --git a/posix/getopt.c b/posix/getopt.c
index 9bafa453c6..df7127e478 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -86,6 +86,9 @@
# else
# define _(msgid) (msgid)
# endif
+# if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
+# endif
#endif
/* This version of `getopt' appears to the caller like standard Unix `getopt'
@@ -678,8 +681,24 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (ambig && !exact)
{
if (print_errors)
- fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
- argv[0], argv[optind]);
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ __asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[optind]);
+
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#else
+ fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[optind]);
+#endif
+ }
nextchar += strlen (nextchar);
optind++;
optopt = 0;
@@ -700,16 +719,46 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (print_errors)
{
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+#endif
+
if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- _("%s: option `--%s' doesn't allow an argument\n"),
- argv[0], pfound->name);
+ {
+ /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ __asprintf (&buf, _("\
+%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#else
+ fprintf (stderr, _("\
+%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#endif
+ }
else
- /* +option or -option */
- fprintf (stderr,
- _("%s: option `%c%s' doesn't allow an argument\n"),
- argv[0], argv[optind - 1][0], pfound->name);
+ {
+ /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ __asprintf (&buf, _("\
+%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[optind - 1][0],
+ pfound->name);
+#else
+ fprintf (stderr, _("\
+%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[optind - 1][0], pfound->name);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#endif
}
nextchar += strlen (nextchar);
@@ -725,9 +774,26 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (print_errors)
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ __asprintf (&buf,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#else
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+#endif
+ }
nextchar += strlen (nextchar);
optopt = pfound->val;
return optstring[0] == ':' ? ':' : '?';
@@ -753,14 +819,41 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (print_errors)
{
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+#endif
+
if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
- argv[0], nextchar);
+ {
+ /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
+ argv[0], nextchar);
+#else
+ fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+ argv[0], nextchar);
+#endif
+ }
+ else
+ {
+ /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[optind][0], nextchar);
+#else
+ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[optind][0], nextchar);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
else
- /* +option or -option */
- fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
- argv[0], argv[optind][0], nextchar);
+ fputs (buf, stderr);
+
+ free (buf);
+#endif
}
nextchar = (char *) "";
optind++;
@@ -783,13 +876,38 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (print_errors)
{
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+#endif
+
if (posixly_correct)
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, _("%s: illegal option -- %c\n"),
- argv[0], c);
+ {
+ /* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ __asprintf (&buf, _("%s: illegal option -- %c\n"),
+ argv[0], c);
+#else
+ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
+#endif
+ }
else
- fprintf (stderr, _("%s: invalid option -- %c\n"),
- argv[0], c);
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ __asprintf (&buf, _("%s: invalid option -- %c\n"),
+ argv[0], c);
+#else
+ fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#endif
}
optopt = c;
return '?';
@@ -818,8 +936,22 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (print_errors)
{
/* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ __asprintf (&buf, _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#else
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
argv[0], c);
+#endif
}
optopt = c;
if (optstring[0] == ':')
@@ -865,8 +997,24 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (ambig && !exact)
{
if (print_errors)
- fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
- argv[0], argv[optind]);
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ __asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[optind]);
+
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#else
+ fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[optind]);
+#endif
+ }
nextchar += strlen (nextchar);
optind++;
return '?';
@@ -883,9 +1031,26 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (print_errors)
- fprintf (stderr, _("\
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ __asprintf (&buf, _("\
%s: option `-W %s' doesn't allow an argument\n"),
- argv[0], pfound->name);
+ argv[0], pfound->name);
+
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#else
+ fprintf (stderr, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#endif
+ }
nextchar += strlen (nextchar);
return '?';
@@ -898,9 +1063,26 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (print_errors)
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ __asprintf (&buf, _("\
+%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#else
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+#endif
+ }
nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : '?';
}
@@ -947,9 +1129,24 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (print_errors)
{
/* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ __asprintf (&buf,
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+ fputs (buf, stderr);
+
+ free (buf);
+#else
fprintf (stderr,
_("%s: option requires an argument -- %c\n"),
argv[0], c);
+#endif
}
optopt = c;
if (optstring[0] == ':')
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
index ab97e39554..eb8cffad7a 100644
--- a/resolv/res_hconf.c
+++ b/resolv/res_hconf.c
@@ -31,6 +31,7 @@
#include <errno.h>
#include <ctype.h>
+#include <libintl.h>
#include <memory.h>
#include <stdio.h>
#include <stdio_ext.h>
@@ -43,6 +44,9 @@
#include <bits/libc-lock.h>
#include "ifreq.h"
#include "res_hconf.h"
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
#define _PATH_HOSTCONF "/etc/host.conf"
@@ -138,14 +142,37 @@ arg_service_list (const char *fname, int line_num, const char *args,
}
if (service == SERVICE_NONE)
{
- fprintf (stderr, "%s: line %d: expected service, found `%s'\n",
- fname, line_num, start);
+ char *buf;
+
+ __asprintf (&buf, _("%s: line %d: expected service, found `%s'\n"),
+ fname, line_num, start);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+
+ free (buf);
return 0;
}
if (_res_hconf.num_services >= SERVICE_MAX)
{
- fprintf (stderr, "%s: line %d: cannot specify more than %d services",
- fname, line_num, SERVICE_MAX);
+ char *buf;
+
+ __asprintf (&buf,
+ _("%s: line %d: cannot specify more than %d services"),
+ fname, line_num, SERVICE_MAX);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+
+ free (buf);
return 0;
}
_res_hconf.service[_res_hconf.num_services++] = service;
@@ -159,9 +186,20 @@ arg_service_list (const char *fname, int line_num, const char *args,
args = skip_ws (++args);
if (!*args || *args == '#')
{
- fprintf (stderr,
- "%s: line %d: list delimiter not followed by keyword",
- fname, line_num);
+ char *buf;
+
+ __asprintf (&buf, _("\
+%s: line %d: list delimiter not followed by keyword"),
+ fname, line_num);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+
+ free (buf);
return 0;
}
default:
@@ -188,9 +226,20 @@ arg_trimdomain_list (const char *fname, int line_num, const char *args,
if (_res_hconf.num_trimdomains >= TRIMDOMAINS_MAX)
{
- fprintf (stderr,
- "%s: line %d: cannot specify more than %d trim domains",
- fname, line_num, TRIMDOMAINS_MAX);
+ char *buf;
+
+ __asprintf (&buf, _("\
+%s: line %d: cannot specify more than %d trim domains"),
+ fname, line_num, TRIMDOMAINS_MAX);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+
+ free (buf);
return 0;
}
_res_hconf.trimdomain[_res_hconf.num_trimdomains++] =
@@ -202,9 +251,20 @@ arg_trimdomain_list (const char *fname, int line_num, const char *args,
args = skip_ws (++args);
if (!*args || *args == '#')
{
- fprintf (stderr,
- "%s: line %d: list delimiter not followed by domain",
- fname, line_num);
+ char *buf;
+
+ __asprintf (&buf, _("\
+%s: line %d: list delimiter not followed by domain"),
+ fname, line_num);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+
+ free (buf);
return 0;
}
default:
@@ -253,8 +313,20 @@ arg_bool (const char *fname, int line_num, const char *args, unsigned flag)
}
else
{
- fprintf (stderr, "%s: line %d: expected `on' or `off', found `%s'\n",
- fname, line_num, args);
+ char *buf;
+
+ __asprintf (&buf,
+ _("%s: line %d: expected `on' or `off', found `%s'\n"),
+ fname, line_num, args);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+
+ free (buf);
return 0;
}
return args;
@@ -289,8 +361,19 @@ parse_line (const char *fname, int line_num, const char *str)
}
if (c == NULL)
{
- fprintf (stderr, "%s: line %d: bad command `%s'\n",
- fname, line_num, start);
+ char *buf;
+
+ __asprintf (&buf, _("%s: line %d: bad command `%s'\n"),
+ fname, line_num, start);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+
+ free (buf);
return;
}
@@ -305,8 +388,22 @@ parse_line (const char *fname, int line_num, const char *str)
{
if (!isspace (*str)) {
if (*str != '#')
- fprintf (stderr, "%s: line %d: ignoring trailing garbage `%s'\n",
- fname, line_num, str);
+ {
+ char *buf;
+
+ __asprintf (&buf,
+ _("%s: line %d: ignoring trailing garbage `%s'\n"),
+ fname, line_num, str);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+
+ free (buf);
+ }
break;
}
++str;
diff --git a/stdio-common/perror.c b/stdio-common/perror.c
index dfdd69a344..a2865dc25c 100644
--- a/stdio-common/perror.c
+++ b/stdio-common/perror.c
@@ -42,7 +42,7 @@ perror_internal (FILE *fp, const char *s)
#ifdef USE_IN_LIBIO
if (_IO_fwide (fp, 0) > 0)
- (void) fwprintf (fp, L"%s%s%s\n", s, colon, errstring);
+ (void) __fwprintf (fp, L"%s%s%s\n", s, colon, errstring);
else
#endif
(void) fprintf (fp, "%s%s%s\n", s, colon, errstring);
diff --git a/stdio-common/psignal.c b/stdio-common/psignal.c
index 019e15d471..c524bf31b0 100644
--- a/stdio-common/psignal.c
+++ b/stdio-common/psignal.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1995,1996,1997,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,7 +18,11 @@
#include <stdio.h>
#include <signal.h>
+#include <stdlib.h>
#include <libintl.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
#ifndef HAVE_GNU_LD
@@ -43,7 +47,27 @@ psignal (int sig, const char *s)
colon = ": ";
if (sig >= 0 && sig < NSIG && (desc = _sys_siglist[sig]) != NULL)
- (void) fprintf (stderr, "%s%s%s\n", s, colon, _(desc));
+ {
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s%s%s\n", s, colon, _(desc));
+ else
+#endif
+ (void) fprintf (stderr, "%s%s%s\n", s, colon, _(desc));
+ }
else
- (void) fprintf (stderr, _("%s%sUnknown signal %d\n"), s, colon, sig);
+ {
+ char *buf;
+
+ (void) __asprintf (&buf, _("%s%sUnknown signal %d\n"), s, colon, sig);
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ (void) fputs (buf, stderr);
+
+ free (buf);
+ }
}
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 9973e5e5d0..68631fe903 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -2182,7 +2182,8 @@ __wprintf_pad (FILE *s, wchar_t pad, size_t count)
# ifdef strong_alias
/* This is for glibc. */
# ifdef COMPILE_WPRINTF
-strong_alias (_IO_vfwprintf, vfwprintf);
+strong_alias (_IO_vfwprintf, __vfwprintf);
+weak_alias (_IO_vfwprintf, vfwprintf);
# else
strong_alias (_IO_vfprintf, vfprintf);
# endif
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 2bafbc3fc1..bb8502f00b 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -23,6 +23,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/syslog.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
/* We have global data, protect the modification. */
@@ -143,20 +146,42 @@ fmtmsg (long int classification, const char *label, int severity,
int do_action = (print & action_mask) && action != MM_NULLACT;
int do_tag = (print & tag_mask) && tag != MM_NULLTAG;
- if (fprintf (stderr, "%s%s%s%s%s%s%s%s%s%s\n",
- do_label ? label : "",
- do_label && (do_severity | do_text | do_action | do_tag)
- ? ": " : "",
- do_severity ? severity_rec->string : "",
- do_severity && (do_text | do_action | do_tag) ? ": " : "",
- do_text ? text : "",
- do_text && (do_action | do_tag) ? "\n" : "",
- do_action ? "TO FIX: " : "",
- do_action ? action : "",
- do_action && do_tag ? " " : "",
- do_tag ? tag : "") == EOF)
- /* Oh, oh. An error occurred during the output. */
- result = MM_NOMSG;
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ {
+ if (__fwprintf (stderr, L"%s%s%s%s%s%s%s%s%s%s\n",
+ do_label ? label : "",
+ do_label
+ && (do_severity | do_text | do_action | do_tag)
+ ? ": " : "",
+ do_severity ? severity_rec->string : "",
+ do_severity && (do_text | do_action | do_tag)
+ ? ": " : "",
+ do_text ? text : "",
+ do_text && (do_action | do_tag) ? "\n" : "",
+ do_action ? "TO FIX: " : "",
+ do_action ? action : "",
+ do_action && do_tag ? " " : "",
+ do_tag ? tag : "") == WEOF)
+ /* Oh, oh. An error occurred during the output. */
+ result = MM_NOMSG;
+ }
+ else
+#endif
+ if (fprintf (stderr, "%s%s%s%s%s%s%s%s%s%s\n",
+ do_label ? label : "",
+ do_label && (do_severity | do_text | do_action | do_tag)
+ ? ": " : "",
+ do_severity ? severity_rec->string : "",
+ do_severity && (do_text | do_action | do_tag) ? ": " : "",
+ do_text ? text : "",
+ do_text && (do_action | do_tag) ? "\n" : "",
+ do_action ? "TO FIX: " : "",
+ do_action ? action : "",
+ do_action && do_tag ? " " : "",
+ do_tag ? tag : "") == EOF)
+ /* Oh, oh. An error occurred during the output. */
+ result = MM_NOMSG;
}
if (classification & MM_CONSOLE)
diff --git a/sunrpc/auth_unix.c b/sunrpc/auth_unix.c
index a03ce0219a..50f955146c 100644
--- a/sunrpc/auth_unix.c
+++ b/sunrpc/auth_unix.c
@@ -50,6 +50,10 @@
#include <rpc/auth.h>
#include <rpc/auth_unix.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
+
/*
* Unix authenticator operations vector
*/
@@ -101,15 +105,16 @@ authunix_create (char *machname, uid_t uid, gid_t gid, int len,
* Allocate and set up auth handle
*/
auth = (AUTH *) mem_alloc (sizeof (*auth));
- if (auth == NULL)
- {
- (void) fprintf (stderr, _("authunix_create: out of memory\n"));
- return NULL;
- }
au = (struct audata *) mem_alloc (sizeof (*au));
- if (au == NULL)
+ if (auth == NULL || au == NULL)
{
- (void) fprintf (stderr, _("authunix_create: out of memory\n"));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("authunix_create: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("authunix_create: out of memory\n"), stderr);
return NULL;
}
auth->ah_ops = &auth_unix_ops;
@@ -139,7 +144,13 @@ authunix_create (char *machname, uid_t uid, gid_t gid, int len,
au->au_origcred.oa_base = mem_alloc ((u_int) len);
if (au->au_origcred.oa_base == NULL)
{
- (void) fputs (_("authunix_create: out of memory\n"), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("authunix_create: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("authunix_create: out of memory\n"), stderr);
return NULL;
}
memcpy(au->au_origcred.oa_base, mymem, (u_int) len);
diff --git a/sunrpc/clnt_perr.c b/sunrpc/clnt_perr.c
index 55d38153b9..4164539dd2 100644
--- a/sunrpc/clnt_perr.c
+++ b/sunrpc/clnt_perr.c
@@ -43,6 +43,7 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
#include <rpc/rpc.h>
#ifdef USE_IN_LIBIO
+# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
#endif
@@ -154,7 +155,12 @@ clnt_sperror (CLIENT * rpch, const char *msg)
void
clnt_perror (CLIENT * rpch, const char *msg)
{
- (void) fputs (clnt_sperror (rpch, msg), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", clnt_sperror (rpch, msg));
+ else
+#endif
+ (void) fputs (clnt_sperror (rpch, msg), stderr);
}
@@ -281,7 +287,12 @@ clnt_sperrno (enum clnt_stat stat)
void
clnt_perrno (enum clnt_stat num)
{
- (void) fputs (clnt_sperrno (num), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", clnt_sperrno (num));
+ else
+#endif
+ (void) fputs (clnt_sperrno (num), stderr);
}
@@ -323,7 +334,12 @@ clnt_spcreateerror (const char *msg)
void
clnt_pcreateerror (const char *msg)
{
- (void) fputs (clnt_spcreateerror (msg), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", clnt_spcreateerror (msg));
+ else
+#endif
+ (void) fputs (clnt_spcreateerror (msg), stderr);
}
struct auth_errtab
diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c
index e3076524a7..6267dc70f6 100644
--- a/sunrpc/clnt_tcp.c
+++ b/sunrpc/clnt_tcp.c
@@ -59,6 +59,9 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
#include <sys/poll.h>
#include <sys/socket.h>
#include <rpc/pmap_clnt.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
extern u_long _create_xid (void);
@@ -117,25 +120,23 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
int *sockp, u_int sendsz, u_int recvsz)
{
CLIENT *h;
- struct ct_data *ct = (struct ct_data *) mem_alloc (sizeof (*ct));
+ struct ct_data *ct;
struct rpc_msg call_msg;
h = (CLIENT *) mem_alloc (sizeof (*h));
- if (h == NULL)
+ ct = (struct ct_data *) mem_alloc (sizeof (*ct));
+ if (h == NULL || ct == NULL)
{
struct rpc_createerr *ce = &get_rpc_createerr ();
- (void) fprintf (stderr, _("clnttcp_create: out of memory\n"));
- ce->cf_stat = RPC_SYSTEMERROR;
- ce->cf_error.re_errno = errno;
- goto fooy;
- }
- /* ct = (struct ct_data *) mem_alloc (sizeof (*ct)); */
- if (ct == NULL)
- {
- struct rpc_createerr *ce = &get_rpc_createerr ();
- (void) fprintf (stderr, _("clnttcp_create: out of memory\n"));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("clnttcp_create: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("clnttcp_create: out of memory\n"), stderr);
ce->cf_stat = RPC_SYSTEMERROR;
- ce->cf_error.re_errno = errno;
+ ce->cf_error.re_errno = ENOMEM;
goto fooy;
}
diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c
index bf98553b8d..94b672174f 100644
--- a/sunrpc/clnt_udp.c
+++ b/sunrpc/clnt_udp.c
@@ -50,6 +50,9 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
#include <errno.h>
#include <rpc/pmap_clnt.h>
#include <net/if.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
#ifdef IP_RECVERR
#include <errqueue.h>
@@ -126,23 +129,21 @@ clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
struct rpc_msg call_msg;
cl = (CLIENT *) mem_alloc (sizeof (CLIENT));
- if (cl == NULL)
- {
- struct rpc_createerr *ce = &get_rpc_createerr ();
- (void) fprintf (stderr, _("clntudp_create: out of memory\n"));
- ce->cf_stat = RPC_SYSTEMERROR;
- ce->cf_error.re_errno = errno;
- goto fooy;
- }
sendsz = ((sendsz + 3) / 4) * 4;
recvsz = ((recvsz + 3) / 4) * 4;
cu = (struct cu_data *) mem_alloc (sizeof (*cu) + sendsz + recvsz);
- if (cu == NULL)
+ if (cl == NULL || cu == NULL)
{
struct rpc_createerr *ce = &get_rpc_createerr ();
- (void) fprintf (stderr, _("clntudp_create: out of memory\n"));
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("clntudp_create: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("clntudp_create: out of memory\n"), stderr);
ce->cf_stat = RPC_SYSTEMERROR;
- ce->cf_error.re_errno = errno;
+ ce->cf_error.re_errno = ENOMEM;
goto fooy;
}
cu->cu_outbuf = &cu->cu_inbuf[recvsz];
diff --git a/sunrpc/clnt_unix.c b/sunrpc/clnt_unix.c
index 19356ad032..64a97a1b68 100644
--- a/sunrpc/clnt_unix.c
+++ b/sunrpc/clnt_unix.c
@@ -56,6 +56,9 @@
#include <sys/poll.h>
#include <sys/socket.h>
#include <rpc/pmap_clnt.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
extern u_long _create_xid (void);
@@ -119,21 +122,18 @@ clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers,
int len;
h = (CLIENT *) mem_alloc (sizeof (*h));
- if (h == NULL)
- {
- struct rpc_createerr *ce = &get_rpc_createerr ();
- (void) fputs (_("clntunix_create: out of memory\n"), stderr);
- ce->cf_stat = RPC_SYSTEMERROR;
- ce->cf_error.re_errno = errno;
- goto fooy;
- }
- /* ct = (struct ct_data *) mem_alloc (sizeof (*ct)); */
- if (ct == NULL)
+ if (h == NULL || ct == NULL)
{
struct rpc_createerr *ce = &get_rpc_createerr ();
- (void) fputs (_("clntunix_create: out of memory\n"), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("clntunix_create: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("clntunix_create: out of memory\n"), stderr);
ce->cf_stat = RPC_SYSTEMERROR;
- ce->cf_error.re_errno = errno;
+ ce->cf_error.re_errno = ENOMEM;
goto fooy;
}
diff --git a/sunrpc/svc_simple.c b/sunrpc/svc_simple.c
index 979b5b69df..db77743360 100644
--- a/sunrpc/svc_simple.c
+++ b/sunrpc/svc_simple.c
@@ -41,12 +41,14 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
#include <stdio.h>
#include <string.h>
#include <libintl.h>
+#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#include <sys/socket.h>
#include <netdb.h>
#ifdef USE_IN_LIBIO
+# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
#endif
@@ -78,35 +80,37 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc)
{
struct proglst_ *pl;
+ char *buf;
if (procnum == NULLPROC)
{
- (void) fprintf (stderr,
- _("can't reassign procedure number %ld\n"), NULLPROC);
- return -1;
+
+ (void) __asprintf (&buf, _("can't reassign procedure number %ld\n"),
+ NULLPROC);
+ goto err_out;
}
if (transp == 0)
{
transp = svcudp_create (RPC_ANYSOCK);
if (transp == NULL)
{
- (void) fputs (_("couldn't create an rpc server\n"), stderr);
- return -1;
+ buf = strdup (_("couldn't create an rpc server\n"));
+ goto err_out;
}
}
(void) pmap_unset ((u_long) prognum, (u_long) versnum);
if (!svc_register (transp, (u_long) prognum, (u_long) versnum,
universal, IPPROTO_UDP))
{
- (void) fprintf (stderr, _("couldn't register prog %ld vers %ld\n"),
- prognum, versnum);
- return -1;
+ (void) __asprintf (&buf, _("couldn't register prog %ld vers %ld\n"),
+ prognum, versnum);
+ goto err_out;
}
pl = (struct proglst_ *) malloc (sizeof (struct proglst_));
if (pl == NULL)
{
- (void) fprintf (stderr, _("registerrpc: out of memory\n"));
- return -1;
+ buf = strdup (_("registerrpc: out of memory\n"));
+ goto err_out;
}
pl->p_progname = progname;
pl->p_prognum = prognum;
@@ -116,6 +120,16 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
pl->p_nxt = proglst;
proglst = pl;
return 0;
+
+ err_out:
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ (void) fputs (buf, stderr);
+ free (buf);
+ return -1;
}
static void
@@ -125,6 +139,7 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l)
char *outdata;
char xdrbuf[UDPMSGSIZE];
struct proglst_ *pl;
+ char *buf = NULL;
/*
* enforce "procnum 0 is echo" convention
@@ -133,7 +148,7 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l)
{
if (svc_sendreply (transp_l, (xdrproc_t)xdr_void, (char *) NULL) == FALSE)
{
- (void) fprintf (stderr, "xxx\n");
+ write (STDERR_FILENO, "xxx\n", 4);
exit (1);
}
return;
@@ -156,15 +171,22 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l)
return;
if (!svc_sendreply (transp_l, pl->p_outproc, outdata))
{
- (void) fprintf (stderr,
- _ ("trouble replying to prog %d\n"),
- pl->p_prognum);
+ (void) __asprintf (&buf,
+ _("trouble replying to prog %d\n"),
+ pl->p_prognum);
exit (1);
}
/* free the decoded arguments */
(void) svc_freeargs (transp_l, pl->p_inproc, xdrbuf);
return;
}
- (void) fprintf (stderr, _ ("never registered prog %d\n"), prog);
+ (void) __asprintf (&buf, _("never registered prog %d\n"), prog);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", buf);
+ else
+#endif
+ fputs (buf, stderr);
+ free (buf);
exit (1);
}
diff --git a/sunrpc/svc_tcp.c b/sunrpc/svc_tcp.c
index 06c05a640d..2fffdf5b5c 100644
--- a/sunrpc/svc_tcp.c
+++ b/sunrpc/svc_tcp.c
@@ -52,6 +52,7 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
#include <stdlib.h>
#ifdef USE_IN_LIBIO
+# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
#endif
@@ -173,19 +174,19 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize)
return (SVCXPRT *) NULL;
}
r = (struct tcp_rendezvous *) mem_alloc (sizeof (*r));
- if (r == NULL)
+ xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
+ if (r == NULL || xprt == NULL)
{
- (void) fputs (_("svctcp_create: out of memory\n"), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", _("svctcp_create: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("svctcp_create: out of memory\n"), stderr);
return NULL;
}
r->sendsize = sendsize;
r->recvsize = recvsize;
- xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
- if (xprt == NULL)
- {
- (void) fputs (_("svctcp_create: out of memory\n"), stderr);
- return NULL;
- }
xprt->xp_p2 = NULL;
xprt->xp_p1 = (caddr_t) r;
xprt->xp_verf = _null_auth;
@@ -214,18 +215,17 @@ makefd_xprt (int fd, u_int sendsize, u_int recvsize)
struct tcp_conn *cd;
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
- if (xprt == (SVCXPRT *) NULL)
- {
- (void) fputs (_("svc_tcp: makefd_xprt: out of memory\n"), stderr);
- goto done;
- }
cd = (struct tcp_conn *) mem_alloc (sizeof (struct tcp_conn));
- if (cd == (struct tcp_conn *) NULL)
+ if (xprt == (SVCXPRT *) NULL || cd == NULL)
{
- (void) fputs (_("svc_tcp: makefd_xprt: out of memory\n"), stderr);
- mem_free ((char *) xprt, sizeof (SVCXPRT));
- xprt = (SVCXPRT *) NULL;
- goto done;
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("svc_tcp: makefd_xprt: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("svc_tcp: makefd_xprt: out of memory\n"), stderr);
+ return NULL;
}
cd->strm_stat = XPRT_IDLE;
xdrrec_create (&(cd->xdrs), sendsize, recvsize,
@@ -238,7 +238,6 @@ makefd_xprt (int fd, u_int sendsize, u_int recvsize)
xprt->xp_port = 0; /* this is a connection, not a rendezvouser */
xprt->xp_sock = fd;
xprt_register (xprt);
-done:
return xprt;
}
diff --git a/sunrpc/svc_udp.c b/sunrpc/svc_udp.c
index f912260ef5..f8ea76c0b8 100644
--- a/sunrpc/svc_udp.c
+++ b/sunrpc/svc_udp.c
@@ -52,6 +52,7 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
#endif
#ifdef USE_IN_LIBIO
+# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
#endif
@@ -118,7 +119,8 @@ svcudp_bufcreate (sock, sendsz, recvsz)
struct svcudp_data *su;
struct sockaddr_in addr;
socklen_t len = sizeof (struct sockaddr_in);
- int pad;
+ int pad;
+ void *buf;
if (sock == RPC_ANYSOCK)
{
@@ -144,23 +146,20 @@ svcudp_bufcreate (sock, sendsz, recvsz)
return (SVCXPRT *) NULL;
}
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
- if (xprt == NULL)
- {
- (void) fputs (_("svcudp_create: out of memory\n"), stderr);
- return NULL;
- }
su = (struct svcudp_data *) mem_alloc (sizeof (*su));
- if (su == NULL)
+ buf = mem_alloc (((MAX (sendsz, recvsz) + 3) / 4) * 4);
+ if (xprt == NULL || su == NULL || buf == NULL)
{
- (void) fputs (_("svcudp_create: out of memory\n"), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", _("svcudp_create: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("svcudp_create: out of memory\n"), stderr);
return NULL;
}
su->su_iosz = ((MAX (sendsz, recvsz) + 3) / 4) * 4;
- if ((rpc_buffer (xprt) = mem_alloc (su->su_iosz)) == NULL)
- {
- (void) fputs (_("svcudp_create: out of memory\n"), stderr);
- return NULL;
- }
+ rpc_buffer (xprt) = buf;
xdrmem_create (&(su->su_xdrs), rpc_buffer (xprt), su->su_iosz, XDR_DECODE);
su->su_cache = NULL;
xprt->xp_p2 = (caddr_t) su;
@@ -174,8 +173,14 @@ svcudp_bufcreate (sock, sendsz, recvsz)
+ sizeof(struct cmsghdr) + sizeof (struct in_pktinfo))
> sizeof (xprt->xp_pad))
{
- (void) fputs (_("svcudp_create: xp_pad is too small for IP_PKTINFO\n"),
- stderr);
+# ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("svcudp_create: xp_pad is too small for IP_PKTINFO\n"));
+ else
+# endif
+ (void) fputs (_("svcudp_create: xp_pad is too small for IP_PKTINFO\n"),
+ stderr);
return NULL;
}
pad = 1;
@@ -380,8 +385,16 @@ svcudp_destroy (xprt)
#define SPARSENESS 4 /* 75% sparse */
-#define CACHE_PERROR(msg) \
+#ifdef USE_IN_LIBIO
+# define CACHE_PERROR(msg) \
+ if (_IO_fwide (stderr, 0) > 0) \
+ (void) __fwprintf(stderr, L"%s\n", msg); \
+ else \
+ (void) fprintf(stderr, "%s\n", msg)
+#else
+# define CACHE_PERROR(msg) \
(void) fprintf(stderr,"%s\n", msg)
+#endif
#define ALLOC(type, size) \
(type *) mem_alloc((unsigned) (sizeof(type) * (size)))
diff --git a/sunrpc/svc_unix.c b/sunrpc/svc_unix.c
index 20bc0aaf38..99e5a2a781 100644
--- a/sunrpc/svc_unix.c
+++ b/sunrpc/svc_unix.c
@@ -49,6 +49,10 @@
#include <stdlib.h>
#include <libintl.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
+
/*
* Ops vector for AF_UNIX based rpc service handle
*/
@@ -166,19 +170,19 @@ svcunix_create (int sock, u_int sendsize, u_int recvsize, char *path)
}
r = (struct unix_rendezvous *) mem_alloc (sizeof (*r));
- if (r == NULL)
+ xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
+ if (r == NULL || xprt == NULL)
{
- fputs (_("svcunix_create: out of memory\n"), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s", _("svcunix_create: out of memory\n"));
+ else
+#endif
+ fputs (_("svcunix_create: out of memory\n"), stderr);
return NULL;
}
r->sendsize = sendsize;
r->recvsize = recvsize;
- xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
- if (xprt == NULL)
- {
- fputs (_("svcunix_create: out of memory\n"), stderr);
- return NULL;
- }
xprt->xp_p2 = NULL;
xprt->xp_p1 = (caddr_t) r;
xprt->xp_verf = _null_auth;
@@ -207,18 +211,17 @@ makefd_xprt (int fd, u_int sendsize, u_int recvsize)
struct unix_conn *cd;
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
- if (xprt == (SVCXPRT *) NULL)
- {
- (void) fputs (_("svc_unix: makefd_xprt: out of memory\n"), stderr);
- goto done;
- }
cd = (struct unix_conn *) mem_alloc (sizeof (struct unix_conn));
- if (cd == (struct unix_conn *) NULL)
+ if (xprt == (SVCXPRT *) NULL || cd == (struct unix_conn *) NULL)
{
- (void) fputs (_("svc_unix: makefd_xprt: out of memory\n"), stderr);
- mem_free ((char *) xprt, sizeof (SVCXPRT));
- xprt = (SVCXPRT *) NULL;
- goto done;
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("svc_unix: makefd_xprt: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("svc_unix: makefd_xprt: out of memory\n"), stderr);
+ return NULL;
}
cd->strm_stat = XPRT_IDLE;
xdrrec_create (&(cd->xdrs), sendsize, recvsize,
@@ -231,7 +234,6 @@ makefd_xprt (int fd, u_int sendsize, u_int recvsize)
xprt->xp_port = 0; /* this is a connection, not a rendezvouser */
xprt->xp_sock = fd;
xprt_register (xprt);
-done:
return xprt;
}
diff --git a/sunrpc/xdr.c b/sunrpc/xdr.c
index 46dfe3b6b4..cc1aa2c2b9 100644
--- a/sunrpc/xdr.c
+++ b/sunrpc/xdr.c
@@ -44,10 +44,15 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
#include <stdio.h>
#include <limits.h>
#include <string.h>
+#include <libintl.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
+
/*
* constants specific to the xdr "protocol"
*/
@@ -548,7 +553,12 @@ xdr_bytes (xdrs, cpp, sizep, maxsize)
}
if (sp == NULL)
{
- (void) fprintf (stderr, "xdr_bytes: out of memory\n");
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", _("xdr_bytes: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("xdr_bytes: out of memory\n"), stderr);
return FALSE;
}
/* fall into ... */
@@ -694,7 +704,13 @@ xdr_string (xdrs, cpp, maxsize)
*cpp = sp = (char *) mem_alloc (nodesize);
if (sp == NULL)
{
- (void) fprintf (stderr, "xdr_string: out of memory\n");
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("xdr_string: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("xdr_string: out of memory\n"), stderr);
return FALSE;
}
sp[size] = 0;
diff --git a/sunrpc/xdr_array.c b/sunrpc/xdr_array.c
index a049b2d27d..2dbf8c1e8c 100644
--- a/sunrpc/xdr_array.c
+++ b/sunrpc/xdr_array.c
@@ -44,6 +44,11 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
#include <string.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+#include <libintl.h>
+
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
#define LASTUNSIGNED ((u_int)0-1)
@@ -95,8 +100,13 @@ xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc)
*addrp = target = mem_alloc (nodesize);
if (target == NULL)
{
- (void) fprintf (stderr,
- "xdr_array: out of memory\n");
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("xdr_array: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("xdr_array: out of memory\n"), stderr);
return FALSE;
}
__bzero (target, nodesize);
diff --git a/sunrpc/xdr_rec.c b/sunrpc/xdr_rec.c
index 3544edc2e8..17c9b35575 100644
--- a/sunrpc/xdr_rec.c
+++ b/sunrpc/xdr_rec.c
@@ -51,6 +51,7 @@
#include <libintl.h>
#ifdef USE_IN_LIBIO
+# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
#endif
@@ -145,10 +146,16 @@ xdrrec_create (XDR *xdrs, u_int sendsize,
{
RECSTREAM *rstrm = (RECSTREAM *) mem_alloc (sizeof (RECSTREAM));
caddr_t tmp;
+ char *buf = mem_alloc (sendsize + recvsize + BYTES_PER_XDR_UNIT);
- if (rstrm == NULL)
+ if (rstrm == NULL || buf == NULL)
{
- (void) fputs (_("xdrrec_create: out of memory\n"), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s", _("xdrrec_create: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("xdrrec_create: out of memory\n"), stderr);
/*
* This is bad. Should rework xdrrec_create to
* return a handle, and in this case return NULL
@@ -160,12 +167,7 @@ xdrrec_create (XDR *xdrs, u_int sendsize,
*/
rstrm->sendsize = sendsize = fix_buf_size (sendsize);
rstrm->recvsize = recvsize = fix_buf_size (recvsize);
- rstrm->the_buffer = mem_alloc (sendsize + recvsize + BYTES_PER_XDR_UNIT);
- if (rstrm->the_buffer == NULL)
- {
- (void) fputs (_("xdrrec_create: out of memory\n"), stderr);
- return;
- }
+ rstrm->the_buffer = buf;
tmp = rstrm->the_buffer;
if ((size_t)tmp % BYTES_PER_XDR_UNIT)
tmp += BYTES_PER_XDR_UNIT - (size_t)tmp % BYTES_PER_XDR_UNIT;
diff --git a/sunrpc/xdr_ref.c b/sunrpc/xdr_ref.c
index 2a9ffb1696..e49329f20e 100644
--- a/sunrpc/xdr_ref.c
+++ b/sunrpc/xdr_ref.c
@@ -47,6 +47,7 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
#include <libintl.h>
#ifdef USE_IN_LIBIO
+# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
#endif
@@ -82,7 +83,13 @@ xdr_reference (xdrs, pp, size, proc)
*pp = loc = (caddr_t) mem_alloc (size);
if (loc == NULL)
{
- (void) fputs (_("xdr_reference: out of memory\n"), stderr);
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s",
+ _("xdr_reference: out of memory\n"));
+ else
+#endif
+ (void) fputs (_("xdr_reference: out of memory\n"), stderr);
return FALSE;
}
__bzero (loc, (int) size);
diff --git a/sysdeps/generic/wordexp.c b/sysdeps/generic/wordexp.c
index 5a9209cd58..1804d2c292 100644
--- a/sysdeps/generic/wordexp.c
+++ b/sysdeps/generic/wordexp.c
@@ -18,25 +18,29 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <wordexp.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <fnmatch.h>
+#include <glob.h>
+#include <libintl.h>
+#include <paths.h>
+#include <pwd.h>
#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <pwd.h>
-#include <sys/types.h>
#include <string.h>
-#include <glob.h>
-#include <ctype.h>
+#include <sys/param.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <paths.h>
-#include <errno.h>
-#include <sys/param.h>
-#include <stdio.h>
-#include <fnmatch.h>
+#ifdef USE_IN_LIBIO
+# include <wchar.h>
+#endif
+#include <wordexp.h>
#include <stdio-common/_itoa.h>
@@ -1789,12 +1793,19 @@ envsubst:
if (!colon_seen && value)
/* Substitute NULL */
;
- else if (*pattern)
- fprintf (stderr, "%s: %s\n", env, pattern);
else
{
- fprintf (stderr, "%s: parameter null or not set\n", env);
- error = WRDE_BADVAL;
+ const char *str = pattern;
+
+ if (str[0] == '\0')
+ str = gettext ("parameter null or not set");
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf (stderr, L"%s: %s\n", env, str);
+ else
+#endif
+ fprintf (stderr, "%s: %s\n", env, str);
}
if (free_value)