Mercurial > hg > octave-jordi > gnulib-hg
annotate lib/strsignal.c @ 12518:b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
The files named by the following are exempted:
grep -v '^#' config/srclist.txt|grep -v '^$' \
| while read src dst; do
test -f "$dst" && { echo "$dst"; continue; }
test -d "$dst" || continue
echo "$dst"/$(basename "$src")
done > exempt
git ls-files tests/unictype >> exempt
In the remaining files, convert to all-interval notation if
- there is already at least one year interval like 2000-2003
- the file is maintained by me
- the file is in lib/uni*/, where that style already prevails
Otherwise, use update-copyright's default.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Mon, 28 Dec 2009 10:50:36 +0100 |
parents | e8d2c6fc33ad |
children | c2cbabec01dd |
rev | line source |
---|---|
12518
b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
1 /* Copyright (C) 1991, 1994-2002, 2005, 2008-2009 Free Software Foundation, |
b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
2 Inc. |
9616 | 3 This file is part of the GNU C Library. |
4 | |
12002
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
8 (at your option) any later version. |
9616 | 9 |
12002
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
9616 | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12002
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
13 GNU General Public License for more details. |
9616 | 14 |
12002
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
f295924fa612
Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents:
10318
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
9616 | 17 |
18 #ifndef _LIBC | |
19 # include <config.h> | |
20 #endif | |
21 | |
22 #include <signal.h> | |
23 #include <stdio.h> | |
24 #include <stdlib.h> | |
25 #include <string.h> | |
26 | |
27 #ifdef _LIBC | |
28 # include <libintl.h> | |
29 #else /* !_LIBC */ | |
30 # include "gettext.h" | |
31 # define _(msgid) gettext (msgid) | |
32 # define N_(msgid) gettext_noop (msgid) | |
33 #endif /* _LIBC */ | |
34 | |
35 #ifdef _LIBC | |
36 # include <bits/libc-lock.h> | |
37 #else /* !_LIBC */ | |
10318
8a3539888308
Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
9893
diff
changeset
|
38 # include "glthread/lock.h" |
8a3539888308
Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
9893
diff
changeset
|
39 # include "glthread/tls.h" |
9616 | 40 # define __libc_once_define(CLASS, NAME) gl_once_define (CLASS, NAME) |
41 # define __libc_once(NAME, INIT) gl_once ((NAME), (INIT)) | |
42 # define __libc_key_t gl_tls_key_t | |
43 # define __libc_getspecific(NAME) gl_tls_get ((NAME)) | |
44 # define __libc_setspecific(NAME, POINTER) gl_tls_set ((NAME), (POINTER)) | |
45 # define __snprintf snprintf | |
46 #endif /* _LIBC */ | |
47 | |
48 #ifdef _LIBC | |
49 | |
50 /* Defined in siglist.c. */ | |
51 extern const char *const _sys_siglist[]; | |
52 extern const char *const _sys_siglist_internal[] attribute_hidden; | |
53 | |
54 #else /* !_LIBC */ | |
55 | |
56 /* NetBSD declares sys_siglist in unistd.h. */ | |
57 # include <unistd.h> | |
58 | |
59 # define INTUSE(x) (x) | |
60 | |
61 # if HAVE_DECL_SYS_SIGLIST | |
62 # undef _sys_siglist | |
63 # define _sys_siglist sys_siglist | |
64 # else /* !HAVE_DECL_SYS_SIGLIST */ | |
65 # ifndef NSIG | |
66 # define NSIG 32 | |
67 # endif /* NSIG */ | |
9893
ec6e90aaf2d7
Fix two compilation errors.
Bruno Haible <bruno@clisp.org>
parents:
9616
diff
changeset
|
68 # if !HAVE_DECL__SYS_SIGLIST |
9616 | 69 static const char *_sys_siglist[NSIG]; |
9893
ec6e90aaf2d7
Fix two compilation errors.
Bruno Haible <bruno@clisp.org>
parents:
9616
diff
changeset
|
70 # endif |
9616 | 71 # endif /* !HAVE_DECL_SYS_SIGLIST */ |
72 | |
73 #endif /* _LIBC */ | |
74 | |
75 static __libc_key_t key; | |
76 | |
77 /* If nonzero the key allocation failed and we should better use a | |
78 static buffer than fail. */ | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
79 #define BUFFERSIZ 100 |
9616 | 80 static char local_buf[BUFFERSIZ]; |
81 static char *static_buf; | |
82 | |
83 /* Destructor for the thread-specific data. */ | |
84 static void init (void); | |
85 static void free_key_mem (void *mem); | |
86 static char *getbuffer (void); | |
87 | |
88 | |
89 /* Return a string describing the meaning of the signal number SIGNUM. */ | |
90 char * | |
91 strsignal (int signum) | |
92 { | |
93 const char *desc; | |
94 __libc_once_define (static, once); | |
95 | |
96 /* If we have not yet initialized the buffer do it now. */ | |
97 __libc_once (once, init); | |
98 | |
99 if ( | |
100 #ifdef SIGRTMIN | |
101 (signum >= SIGRTMIN && signum <= SIGRTMAX) || | |
102 #endif | |
103 signum < 0 || signum >= NSIG | |
104 || (desc = INTUSE(_sys_siglist)[signum]) == NULL) | |
105 { | |
106 char *buffer = getbuffer (); | |
107 int len; | |
108 #ifdef SIGRTMIN | |
109 if (signum >= SIGRTMIN && signum <= SIGRTMAX) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
110 len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
111 signum - SIGRTMIN); |
9616 | 112 else |
113 #endif | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
114 len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
115 signum); |
9616 | 116 if (len >= BUFFERSIZ) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
117 buffer = NULL; |
9616 | 118 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
119 buffer[len] = '\0'; |
9616 | 120 |
121 return buffer; | |
122 } | |
123 | |
124 return (char *) _(desc); | |
125 } | |
126 | |
127 | |
128 /* Initialize buffer. */ | |
129 static void | |
130 init (void) | |
131 { | |
132 #ifdef _LIBC | |
133 if (__libc_key_create (&key, free_key_mem)) | |
134 /* Creating the key failed. This means something really went | |
135 wrong. In any case use a static buffer which is better than | |
136 nothing. */ | |
137 static_buf = local_buf; | |
138 #else /* !_LIBC */ | |
139 gl_tls_key_init (key, free_key_mem); | |
140 | |
141 # if !HAVE_DECL_SYS_SIGLIST | |
142 memset (_sys_siglist, 0, NSIG * sizeof *_sys_siglist); | |
143 | |
144 /* No need to use a do {} while (0) here since init_sig(...) must expand | |
145 to a complete statement. (We cannot use the ISO C99 designated array | |
146 initializer syntax since it is not supported by ANSI C compilers and | |
147 since some signal numbers might exceed NSIG.) */ | |
148 # define init_sig(sig, abbrev, desc) \ | |
149 if (sig >= 0 && sig < NSIG) \ | |
150 _sys_siglist[sig] = desc; | |
151 | |
152 # include "siglist.h" | |
153 | |
154 # undef init_sig | |
155 | |
156 # endif /* !HAVE_DECL_SYS_SIGLIST */ | |
157 #endif /* !_LIBC */ | |
158 } | |
159 | |
160 | |
161 /* Free the thread specific data, this is done if a thread terminates. */ | |
162 static void | |
163 free_key_mem (void *mem) | |
164 { | |
165 free (mem); | |
166 __libc_setspecific (key, NULL); | |
167 } | |
168 | |
169 | |
170 /* Return the buffer to be used. */ | |
171 static char * | |
172 getbuffer (void) | |
173 { | |
174 char *result; | |
175 | |
176 if (static_buf != NULL) | |
177 result = static_buf; | |
178 else | |
179 { | |
180 /* We don't use the static buffer and so we have a key. Use it | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
181 to get the thread-specific buffer. */ |
9616 | 182 result = __libc_getspecific (key); |
183 if (result == NULL) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
184 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
185 /* No buffer allocated so far. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
186 result = malloc (BUFFERSIZ); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
187 if (result == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
188 /* No more memory available. We use the static buffer. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
189 result = local_buf; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
190 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
191 __libc_setspecific (key, result); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12002
diff
changeset
|
192 } |
9616 | 193 } |
194 | |
195 return result; | |
196 } |