strtoumax: fix typo in previous commit.
[gnulib.git] / lib / strsignal.c
index a7adaba..12cd881 100644 (file)
@@ -1,29 +1,30 @@
-/* Copyright (C) 1991, 1994-2002, 2005, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994-2002, 2005, 2008-2013 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
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
+   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 3 of the License, or
+   (at your option) any later version.
 
-   The GNU C Library is distributed in the hope that it will be useful,
+   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
-   Lesser General Public License for more details.
+   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 Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 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/>.  */
 
 #ifndef _LIBC
 # include <config.h>
 #endif
 
+/* Specification.  */
+#include <string.h>
+
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #ifdef _LIBC
 # include <libintl.h>
@@ -55,7 +56,9 @@ extern const char *const _sys_siglist_internal[] attribute_hidden;
 #else /* !_LIBC */
 
 /* NetBSD declares sys_siglist in unistd.h. */
-# include <unistd.h>
+# if HAVE_UNISTD_H
+#  include <unistd.h>
+# endif
 
 # define INTUSE(x) (x)
 
@@ -77,7 +80,7 @@ static __libc_key_t key;
 
 /* If nonzero the key allocation failed and we should better use a
    static buffer than fail.  */
-#define BUFFERSIZ      100
+#define BUFFERSIZ       100
 static char local_buf[BUFFERSIZ];
 static char *static_buf;
 
@@ -108,16 +111,16 @@ strsignal (int signum)
       int len;
 #ifdef SIGRTMIN
       if (signum >= SIGRTMIN && signum <= SIGRTMAX)
-       len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"),
-                         signum - SIGRTMIN);
+        len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"),
+                          signum - (int) SIGRTMIN);
       else
 #endif
-       len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"),
-                         signum);
+        len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"),
+                          signum);
       if (len >= BUFFERSIZ)
-       buffer = NULL;
+        buffer = NULL;
       else
-       buffer[len] = '\0';
+        buffer[len] = '\0';
 
       return buffer;
     }
@@ -179,18 +182,18 @@ getbuffer (void)
   else
     {
       /* We don't use the static buffer and so we have a key.  Use it
-        to get the thread-specific buffer.  */
+         to get the thread-specific buffer.  */
       result = __libc_getspecific (key);
       if (result == NULL)
-       {
-         /* No buffer allocated so far.  */
-         result = malloc (BUFFERSIZ);
-         if (result == NULL)
-           /* No more memory available.  We use the static buffer.  */
-           result = local_buf;
-         else
-           __libc_setspecific (key, result);
-       }
+        {
+          /* No buffer allocated so far.  */
+          result = malloc (BUFFERSIZ);
+          if (result == NULL)
+            /* No more memory available.  We use the static buffer.  */
+            result = local_buf;
+          else
+            __libc_setspecific (key, result);
+        }
     }
 
   return result;