2001-12-06  Ulrich Drepper  <drepper@redhat.com>

	* libio/vasprintf.c (_IO_vasprintf): Free buffer on failure.
	* assert/assert.c: Check result of __asprintf call and don't use
	string if it failed.
	* assert/assert-perr.c: Likewise.
	* inet/rcmd.c: Likewise.
	* locale/programs/localedef.c (main): Check result of
	construct_output_path and exit if it failed.
	(construct_output_path): Check result of asprintf and mkdir calls and
	fail if they failed.
	* posix/getopt.c: Check result of __asprintf calls and fail if
	they failed.
	Patch by Dmitry V. Levin <ldv@alt-linux.org>.
This commit is contained in:
Ulrich Drepper 2001-12-06 08:49:08 +00:00
parent 1e06620a7b
commit 383bd1c503
7 changed files with 234 additions and 162 deletions

View File

@ -1,3 +1,18 @@
2001-12-06 Ulrich Drepper <drepper@redhat.com>
* libio/vasprintf.c (_IO_vasprintf): Free buffer on failure.
* assert/assert.c: Check result of __asprintf call and don't use
string if it failed.
* assert/assert-perr.c: Likewise.
* inet/rcmd.c: Likewise.
* locale/programs/localedef.c (main): Check result of
construct_output_path and exit if it failed.
(construct_output_path): Check result of asprintf and mkdir calls and
fail if they failed.
* posix/getopt.c: Check result of __asprintf calls and fail if
they failed.
Patch by Dmitry V. Levin <ldv@alt-linux.org>.
2001-12-05 Ulrich Drepper <drepper@redhat.com> 2001-12-05 Ulrich Drepper <drepper@redhat.com>
* sysdeps/generic/strcasecmp.c (__strcasecmp): Little performance * sysdeps/generic/strcasecmp.c (__strcasecmp): Little performance

View File

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sysdep.h> #include <sysdep.h>
#include <unistd.h>
extern const char *__progname; extern const char *__progname;
@ -53,25 +54,30 @@ __assert_perror_fail (int errnum,
FATAL_PREPARE; FATAL_PREPARE;
#endif #endif
(void) __asprintf (&buf, _("%s%s%s:%u: %s%sUnexpected error: %s.\n"), if (__asprintf (&buf, _("%s%s%s:%u: %s%sUnexpected error: %s.\n"),
__progname, __progname[0] ? ": " : "", __progname, __progname[0] ? ": " : "",
file, line, file, line,
function ? function : "", function ? ": " : "", function ? function : "", function ? ": " : "",
__strerror_r (errnum, errbuf, sizeof errbuf)); __strerror_r (errnum, errbuf, sizeof errbuf)) >= 0)
{
/* Print the message. */ /* Print the message. */
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
(void) __fwprintf (stderr, L"%s", buf); (void) __fwprintf (stderr, L"%s", buf);
else else
#endif #endif
(void) fputs (buf, stderr); (void) fputs (buf, stderr);
(void) fflush (stderr); (void) fflush (stderr);
/* We have to free the buffer since the appplication might catch the /* We have to free the buffer since the appplication might catch the
SIGABRT. */ SIGABRT. */
free (buf); free (buf);
}
else
/* At least print a minimal message. */
#define STR_N_LEN(str) str, sizeof (str) - 1
__libc_write (STDERR_FILENO, STR_N_LEN ("Unexpected error.\n"));
abort (); abort ();
} }

View File

@ -21,6 +21,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sysdep.h> #include <sysdep.h>
#include <unistd.h>
extern const char *__progname; extern const char *__progname;
@ -51,25 +52,30 @@ __assert_fail (const char *assertion, const char *file, unsigned int line,
FATAL_PREPARE; FATAL_PREPARE;
#endif #endif
(void) __asprintf (&buf, _("%s%s%s:%u: %s%sAssertion `%s' failed.\n"), if (__asprintf (&buf, _("%s%s%s:%u: %s%sAssertion `%s' failed.\n"),
__progname, __progname[0] ? ": " : "", __progname, __progname[0] ? ": " : "",
file, line, file, line,
function ? function : "", function ? ": " : "", function ? function : "", function ? ": " : "",
assertion); assertion) >= 0)
{
/* Print the message. */ /* Print the message. */
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
(void) __fwprintf (stderr, L"%s", buf); (void) __fwprintf (stderr, L"%s", buf);
else else
#endif #endif
(void) fputs (buf, stderr); (void) fputs (buf, stderr);
(void) fflush (stderr); (void) fflush (stderr);
/* We have to free the buffer since the appplication might catch the /* We have to free the buffer since the appplication might catch the
SIGABRT. */ SIGABRT. */
free (buf); free (buf);
}
else
/* At least print a minimal message. */
#define STR_N_LEN(str) str, sizeof (str) - 1
__libc_write (STDERR_FILENO, STR_N_LEN ("Unexpected error.\n"));
abort (); abort ();
} }

View File

@ -206,13 +206,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
NULL, 0, NULL, 0,
NI_NUMERICHOST); NI_NUMERICHOST);
__asprintf (&buf, _("connect to address %s: "), paddr); if (__asprintf (&buf, _("connect to address %s: "),
paddr) >= 0)
{
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
__fwprintf(stderr, L"%s", buf); __fwprintf(stderr, L"%s", buf);
else else
#endif #endif
fputs (buf, stderr); fputs (buf, stderr);
free (buf);
}
__set_errno (oerrno); __set_errno (oerrno);
perror(0); perror(0);
ai = ai->ai_next; ai = ai->ai_next;
@ -220,14 +224,16 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
paddr, sizeof(paddr), paddr, sizeof(paddr),
NULL, 0, NULL, 0,
NI_NUMERICHOST); NI_NUMERICHOST);
__asprintf (&buf, _("Trying %s...\n"), paddr); if (__asprintf (&buf, _("Trying %s...\n"), paddr) >= 0)
{
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf); __fwprintf (stderr, L"%s", buf);
else else
#endif #endif
fputs (buf, stderr); fputs (buf, stderr);
free (buf); free (buf);
}
continue; continue;
} }
if (refused && timo <= 16) { if (refused && timo <= 16) {
@ -267,15 +273,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
if (__write(s, num, strlen(num)+1) != (ssize_t)strlen(num)+1) { if (__write(s, num, strlen(num)+1) != (ssize_t)strlen(num)+1) {
char *buf = NULL; char *buf = NULL;
__asprintf (&buf, _("\ if (__asprintf (&buf, _("\
rcmd: write (setting up stderr): %m\n")); rcmd: write (setting up stderr): %m\n")) >= 0)
{
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
__fwprintf(stderr, L"%s", buf); __fwprintf(stderr, L"%s", buf);
else else
#endif #endif
fputs (buf, stderr); fputs (buf, stderr);
free (buf); free (buf);
}
(void)__close(s2); (void)__close(s2);
goto bad; goto bad;
} }
@ -285,19 +293,21 @@ rcmd: write (setting up stderr): %m\n"));
if (__poll (pfd, 2, -1) < 1 || (pfd[1].revents & POLLIN) == 0){ if (__poll (pfd, 2, -1) < 1 || (pfd[1].revents & POLLIN) == 0){
char *buf = NULL; char *buf = NULL;
if (errno != 0) if ((errno != 0
__asprintf(&buf, && __asprintf(&buf, _("\
_("rcmd: poll (setting up stderr): %m\n")); rcmd: poll (setting up stderr): %m\n")) >= 0)
else || (errno == 0
__asprintf(&buf, && __asprintf(&buf, _("\
_("poll: protocol failure in circuit setup\n")); poll: protocol failure in circuit setup\n")) >= 0))
{
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf); __fwprintf (stderr, L"%s", buf);
else else
#endif #endif
fputs (buf, stderr); fputs (buf, stderr);
free (buf); free (buf);
}
(void)__close(s2); (void)__close(s2);
goto bad; goto bad;
} }
@ -331,15 +341,17 @@ rcmd: write (setting up stderr): %m\n"));
if (rport >= IPPORT_RESERVED || rport < IPPORT_RESERVED / 2){ if (rport >= IPPORT_RESERVED || rport < IPPORT_RESERVED / 2){
char *buf = NULL; char *buf = NULL;
__asprintf(&buf, if (__asprintf(&buf, _("\
_("socket: protocol failure in circuit setup\n")); socket: protocol failure in circuit setup\n")) >= 0)
{
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf); __fwprintf (stderr, L"%s", buf);
else else
#endif #endif
fputs (buf, stderr); fputs (buf, stderr);
free (buf); free (buf);
}
goto bad2; goto bad2;
} }
} }
@ -350,17 +362,20 @@ rcmd: write (setting up stderr): %m\n"));
if (n != 1) { if (n != 1) {
char *buf = NULL; char *buf = NULL;
if (n == 0) if ((n == 0
__asprintf(&buf, _("rcmd: %s: short read"), *ahost); && __asprintf(&buf, _("rcmd: %s: short read"),
else *ahost) >= 0)
__asprintf(&buf, "rcmd: %s: %m\n", *ahost); || (n != 0
&& __asprintf(&buf, "rcmd: %s: %m\n", *ahost) >= 0))
{
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf); __fwprintf (stderr, L"%s", buf);
else else
#endif #endif
fputs (buf, stderr); fputs (buf, stderr);
free (buf); free (buf);
}
goto bad2; goto bad2;
} }
if (c != 0) { if (c != 0) {

View File

@ -60,7 +60,10 @@ _IO_vasprintf (result_ptr, format, args)
sf._s._free_buffer = (_IO_free_type) free; sf._s._free_buffer = (_IO_free_type) free;
ret = _IO_vfprintf (&sf._sbf._f, format, args); ret = _IO_vfprintf (&sf._sbf._f, format, args);
if (ret < 0) if (ret < 0)
return ret; {
free (sf._sbf._f._IO_buf_base);
return ret;
}
/* Only use realloc if the size we need is of the same order of /* Only use realloc if the size we need is of the same order of
magnitude then the memory we allocated. */ magnitude then the memory we allocated. */
needed = sf._sbf._f._IO_write_ptr - sf._sbf._f._IO_write_base + 1; needed = sf._sbf._f._IO_write_ptr - sf._sbf._f._IO_write_base + 1;

View File

@ -177,6 +177,8 @@ main (int argc, char *argv[])
/* The parameter describes the output path of the constructed files. /* The parameter describes the output path of the constructed files.
If the described files cannot be written return a NULL pointer. */ If the described files cannot be written return a NULL pointer. */
output_path = construct_output_path (argv[remaining]); output_path = construct_output_path (argv[remaining]);
if (output_path == NULL)
error (4, errno, _("cannot create directory for output files"));
cannot_write_why = errno; cannot_write_why = errno;
/* Now that the parameters are processed we have to reset the local /* Now that the parameters are processed we have to reset the local
@ -374,6 +376,9 @@ construct_output_path (char *path)
output_prefix ?: "", LOCALEDIR, output_prefix ?: "", LOCALEDIR,
(int) (startp - path), path, normal, endp, '\0'); (int) (startp - path), path, normal, endp, '\0');
if (n < 0)
return NULL;
endp = result + n - 1; endp = result + n - 1;
} }
else else
@ -392,7 +397,8 @@ construct_output_path (char *path)
if (errno == ENOENT) if (errno == ENOENT)
{ {
errno = 0; errno = 0;
mkdir (result, 0777); if (mkdir (result, 0777) < 0)
return NULL;
} }
*endp++ = '/'; *endp++ = '/';

View File

@ -685,15 +685,17 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
__asprintf (&buf, _("%s: option `%s' is ambiguous\n"), if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
argv[0], argv[optind]); argv[0], argv[optind]) >= 0)
{
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf); __fwprintf (stderr, L"%s", buf);
else else
fputs (buf, stderr); fputs (buf, stderr);
free (buf); free (buf);
}
#else #else
fprintf (stderr, _("%s: option `%s' is ambiguous\n"), fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
argv[0], argv[optind]); argv[0], argv[optind]);
@ -721,15 +723,16 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{ {
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
int n;
#endif #endif
if (argv[optind - 1][1] == '-') if (argv[optind - 1][1] == '-')
{ {
/* --option */ /* --option */
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
__asprintf (&buf, _("\ n = __asprintf (&buf, _("\
%s: option `--%s' doesn't allow an argument\n"), %s: option `--%s' doesn't allow an argument\n"),
argv[0], pfound->name); argv[0], pfound->name);
#else #else
fprintf (stderr, _("\ fprintf (stderr, _("\
%s: option `--%s' doesn't allow an argument\n"), %s: option `--%s' doesn't allow an argument\n"),
@ -740,10 +743,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{ {
/* +option or -option */ /* +option or -option */
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
__asprintf (&buf, _("\ n = __asprintf (&buf, _("\
%s: option `%c%s' doesn't allow an argument\n"), %s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], argv[0], argv[optind - 1][0],
pfound->name); pfound->name);
#else #else
fprintf (stderr, _("\ fprintf (stderr, _("\
%s: option `%c%s' doesn't allow an argument\n"), %s: option `%c%s' doesn't allow an argument\n"),
@ -752,12 +755,15 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
} }
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (n >= 0)
__fwprintf (stderr, L"%s", buf); {
else if (_IO_fwide (stderr, 0) > 0)
fputs (buf, stderr); __fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
free (buf); free (buf);
}
#endif #endif
} }
@ -778,16 +784,17 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
__asprintf (&buf, if (__asprintf (&buf, _("\
_("%s: option `%s' requires an argument\n"), %s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]); argv[0], argv[optind - 1]) >= 0)
{
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
if (_IO_fwide (stderr, 0) > 0) free (buf);
__fwprintf (stderr, L"%s", buf); }
else
fputs (buf, stderr);
free (buf);
#else #else
fprintf (stderr, fprintf (stderr,
_("%s: option `%s' requires an argument\n"), _("%s: option `%s' requires an argument\n"),
@ -821,14 +828,15 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{ {
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
int n;
#endif #endif
if (argv[optind][1] == '-') if (argv[optind][1] == '-')
{ {
/* --option */ /* --option */
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
__asprintf (&buf, _("%s: unrecognized option `--%s'\n"), n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
argv[0], nextchar); argv[0], nextchar);
#else #else
fprintf (stderr, _("%s: unrecognized option `--%s'\n"), fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
argv[0], nextchar); argv[0], nextchar);
@ -838,8 +846,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{ {
/* +option or -option */ /* +option or -option */
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
__asprintf (&buf, _("%s: unrecognized option `%c%s'\n"), n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
argv[0], argv[optind][0], nextchar); argv[0], argv[optind][0], nextchar);
#else #else
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
argv[0], argv[optind][0], nextchar); argv[0], argv[optind][0], nextchar);
@ -847,12 +855,15 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
} }
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (n >= 0)
__fwprintf (stderr, L"%s", buf); {
else if (_IO_fwide (stderr, 0) > 0)
fputs (buf, stderr); __fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
free (buf); free (buf);
}
#endif #endif
} }
nextchar = (char *) ""; nextchar = (char *) "";
@ -878,14 +889,15 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{ {
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
int n;
#endif #endif
if (posixly_correct) if (posixly_correct)
{ {
/* 1003.2 specifies the format of this message. */ /* 1003.2 specifies the format of this message. */
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
__asprintf (&buf, _("%s: illegal option -- %c\n"), n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
argv[0], c); argv[0], c);
#else #else
fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
#endif #endif
@ -893,20 +905,23 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else else
{ {
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
__asprintf (&buf, _("%s: invalid option -- %c\n"), n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
argv[0], c); argv[0], c);
#else #else
fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
#endif #endif
} }
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (n >= 0)
__fwprintf (stderr, L"%s", buf); {
else if (_IO_fwide (stderr, 0) > 0)
fputs (buf, stderr); __fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
free (buf); free (buf);
}
#endif #endif
} }
optopt = c; optopt = c;
@ -939,15 +954,17 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
__asprintf (&buf, _("%s: option requires an argument -- %c\n"), if (__asprintf (&buf,
argv[0], c); _("%s: option requires an argument -- %c\n"),
argv[0], c) >= 0)
{
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
if (_IO_fwide (stderr, 0) > 0) free (buf);
__fwprintf (stderr, L"%s", buf); }
else
fputs (buf, stderr);
free (buf);
#else #else
fprintf (stderr, _("%s: option requires an argument -- %c\n"), fprintf (stderr, _("%s: option requires an argument -- %c\n"),
argv[0], c); argv[0], c);
@ -1001,15 +1018,16 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
argv[0], argv[optind]); argv[0], argv[optind]) >= 0)
{
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
if (_IO_fwide (stderr, 0) > 0) free (buf);
__fwprintf (stderr, L"%s", buf); }
else
fputs (buf, stderr);
free (buf);
#else #else
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
argv[0], argv[optind]); argv[0], argv[optind]);
@ -1035,16 +1053,17 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
__asprintf (&buf, _("\ if (__asprintf (&buf, _("\
%s: option `-W %s' doesn't allow an argument\n"), %s: option `-W %s' doesn't allow an argument\n"),
argv[0], pfound->name); argv[0], pfound->name) >= 0)
{
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
if (_IO_fwide (stderr, 0) > 0) free (buf);
__fwprintf (stderr, L"%s", buf); }
else
fputs (buf, stderr);
free (buf);
#else #else
fprintf (stderr, _("\ fprintf (stderr, _("\
%s: option `-W %s' doesn't allow an argument\n"), %s: option `-W %s' doesn't allow an argument\n"),
@ -1067,16 +1086,17 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
__asprintf (&buf, _("\ if (__asprintf (&buf, _("\
%s: option `%s' requires an argument\n"), %s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]); argv[0], argv[optind - 1]) >= 0)
{
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
if (_IO_fwide (stderr, 0) > 0) free (buf);
__fwprintf (stderr, L"%s", buf); }
else
fputs (buf, stderr);
free (buf);
#else #else
fprintf (stderr, fprintf (stderr,
_("%s: option `%s' requires an argument\n"), _("%s: option `%s' requires an argument\n"),
@ -1132,16 +1152,17 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
#if defined _LIBC && defined USE_IN_LIBIO #if defined _LIBC && defined USE_IN_LIBIO
char *buf; char *buf;
__asprintf (&buf, if (__asprintf (&buf, _("\
_("%s: option requires an argument -- %c\n"), %s: option requires an argument -- %c\n"),
argv[0], c); argv[0], c) >= 0)
{
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
fputs (buf, stderr);
if (_IO_fwide (stderr, 0) > 0) free (buf);
__fwprintf (stderr, L"%s", buf); }
else
fputs (buf, stderr);
free (buf);
#else #else
fprintf (stderr, fprintf (stderr,
_("%s: option requires an argument -- %c\n"), _("%s: option requires an argument -- %c\n"),