Use case-insensitive comparison.
[gnulib.git] / lib / error.c
index 34e8365..3177bd5 100644 (file)
@@ -1,24 +1,23 @@
 /* Error handler for noninteractive utilities
-   Copyright (C) 1990-1998, 2000-2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1990-1998, 2000-2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
-   This program is free software; you can redistribute it and/or modify
+   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
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
-   You should have received a copy of the GNU General Public License along
-   with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Written by David MacKenzie <djm@gnu.ai.mit.edu>.  */
 
-#ifdef HAVE_CONFIG_H
+#if !_LIBC
 # include <config.h>
 #endif
 
@@ -31,6 +30,7 @@
 
 #if !_LIBC && ENABLE_NLS
 # include "gettext.h"
+# define _(msgid) gettext (msgid)
 #endif
 
 #ifdef _LIBC
@@ -92,23 +92,19 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
 char *strerror_r ();
 # endif
 
-# ifndef SIZE_MAX
-#  define SIZE_MAX ((size_t) -1)
-# endif
-
 /* The calling program should define program_name and set it to the
    name of the executing program.  */
 extern char *program_name;
 
 # if HAVE_STRERROR_R || defined strerror_r
 #  define __strerror_r strerror_r
-# endif
+# endif        /* HAVE_STRERROR_R || defined strerror_r */
 #endif /* not _LIBC */
 
 static void
 print_errno_message (int errnum)
 {
-  char const *s = NULL;
+  char const *s;
 
 #if defined HAVE_STRERROR_R || _LIBC
   char errbuf[1024];
@@ -117,11 +113,15 @@ print_errno_message (int errnum)
 # else
   if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
     s = errbuf;
+  else
+    s = 0;
 # endif
+#else
+  s = strerror (errnum);
 #endif
 
 #if !_LIBC
-  if (! s && ! (s = strerror (errnum)))
+  if (! s)
     s = _("Unknown system error");
 #endif
 
@@ -310,14 +310,13 @@ error_at_line (int status, int errnum, const char *file_name,
 #endif
     }
 
-  if (file_name != NULL)
-    {
 #if _LIBC
-      __fxprintf (NULL, "%s:%d: ", file_name, line_number);
+  __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
+             file_name, line_number);
 #else
-      fprintf (stderr, "%s:%d: ", file_name, line_number);
+  fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
+          file_name, line_number);
 #endif
-    }
 
   va_start (args, message);
   error_tail (status, errnum, message, args);