Update from gettext 0.14.2.
[gnulib.git] / lib / argp-help.c
index c506b57..4f1fc0e 100644 (file)
@@ -1,5 +1,5 @@
 /* Hierarchial argument parsing help output
-   Copyright (C) 1995-2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1995-2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>.
 
@@ -1669,7 +1669,10 @@ Try `%s --help' or `%s --usage' for more information.\n"),
 void __argp_help (const struct argp *argp, FILE *stream,
                  unsigned flags, char *name)
 {
-  _help (argp, 0, stream, flags, name);
+  struct argp_state state;
+  memset (&state, 0, sizeof state);
+  state.root_argp = argp;
+  _help (argp, &state, stream, flags, name);
 }
 #ifdef weak_alias
 weak_alias (__argp_help, argp_help)
@@ -1745,7 +1748,8 @@ __argp_error (const struct argp_state *state, const char *fmt, ...)
            {
              char *buf;
 
-             __asprintf (&buf, fmt, ap);
+             if (__asprintf (&buf, fmt, ap) < 0)
+               buf = NULL;
 
              __fwprintf (stream, L"%s: %s\n",
                          state ? state->name : __argp_short_program_name (),
@@ -1823,7 +1827,8 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
                {
                  char *buf;
 
-                 __asprintf (&buf, fmt, ap);
+                 if (__asprintf (&buf, fmt, ap) < 0)
+                   buf = NULL;
 
                  __fwprintf (stream, L": %s", buf);
 
@@ -1863,7 +1868,8 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
 #endif
 #if !_LIBC
                  if (! s && ! (s = strerror (errnum)))
-                   s = "Unknown system error"; /* FIXME: translate this */
+                   s = dgettext (state->root_argp->argp_domain,
+                                 "Unknown system error");
 #endif
                  fputs (s, stream);
                }