From: Bruno Haible Date: Wed, 12 Jan 2005 13:12:40 +0000 (+0000) Subject: Update 'strerror' module from gnulib, but keep #if !HAVE_STRERROR modification. X-Git-Tag: v0.14.2~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b68b9d038047b6c9051700966f6423d0d9de7a2;p=thirdparty%2Fgettext.git Update 'strerror' module from gnulib, but keep #if !HAVE_STRERROR modification. --- diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index e0d5bab3d..e46f8beb6 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,3 +1,7 @@ +2005-01-06 Bruno Haible + + * strerror.c: Update from gnulib, with HAVE_STRERROR modifications. + 2005-01-06 Bruno Haible * strtol.c: Update from gnulib. diff --git a/gettext-tools/lib/strerror.c b/gettext-tools/lib/strerror.c index 931460fbb..465d00997 100644 --- a/gettext-tools/lib/strerror.c +++ b/gettext-tools/lib/strerror.c @@ -1,6 +1,7 @@ /* strerror.c --- ANSI C compatible system error routine - Copyright (C) 1986, 1988-1989, 1991, 2002-2003 Free Software Foundation, Inc. + Copyright (C) 1986, 1988, 1989, 1991, 2002, 2003 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,21 +23,27 @@ #if !HAVE_STRERROR -#if 0 /* Avoid colliding declaration of sys_errlist. */ -# include -#endif +#include +/* Don't include , since it may or may not declare + sys_errlist and its declarations may collide with ours. Just + declare the stuff that we need directly. Standard hosted C89 + implementations define strerror and they don't need this strerror + function, so take some liberties with the standard to cater to + ancient or limited freestanding implementations. */ +int sprintf (char *, char const *, ...); extern int sys_nerr; extern char *sys_errlist[]; char * strerror (int n) { - static char mesg[30]; + static char const fmt[] = "Unknown error (%d)"; + static char mesg[sizeof fmt + sizeof n * CHAR_BIT / 3]; if (n < 0 || n >= sys_nerr) { - sprintf (mesg, "Unknown error (%d)", n); + sprintf (mesg, fmt, n); return mesg; } else