comparison lib/strsignal.c @ 12421:e8d2c6fc33ad

Use spaces for indentation, not tabs.
author Bruno Haible <bruno@clisp.org>
date Thu, 10 Dec 2009 20:28:30 +0100
parents f295924fa612
children b5e42ef33b49
comparison
equal deleted inserted replaced
12420:5850b9a81029 12421:e8d2c6fc33ad
73 73
74 static __libc_key_t key; 74 static __libc_key_t key;
75 75
76 /* If nonzero the key allocation failed and we should better use a 76 /* If nonzero the key allocation failed and we should better use a
77 static buffer than fail. */ 77 static buffer than fail. */
78 #define BUFFERSIZ 100 78 #define BUFFERSIZ 100
79 static char local_buf[BUFFERSIZ]; 79 static char local_buf[BUFFERSIZ];
80 static char *static_buf; 80 static char *static_buf;
81 81
82 /* Destructor for the thread-specific data. */ 82 /* Destructor for the thread-specific data. */
83 static void init (void); 83 static void init (void);
104 { 104 {
105 char *buffer = getbuffer (); 105 char *buffer = getbuffer ();
106 int len; 106 int len;
107 #ifdef SIGRTMIN 107 #ifdef SIGRTMIN
108 if (signum >= SIGRTMIN && signum <= SIGRTMAX) 108 if (signum >= SIGRTMIN && signum <= SIGRTMAX)
109 len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"), 109 len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"),
110 signum - SIGRTMIN); 110 signum - SIGRTMIN);
111 else 111 else
112 #endif 112 #endif
113 len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"), 113 len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"),
114 signum); 114 signum);
115 if (len >= BUFFERSIZ) 115 if (len >= BUFFERSIZ)
116 buffer = NULL; 116 buffer = NULL;
117 else 117 else
118 buffer[len] = '\0'; 118 buffer[len] = '\0';
119 119
120 return buffer; 120 return buffer;
121 } 121 }
122 122
123 return (char *) _(desc); 123 return (char *) _(desc);
175 if (static_buf != NULL) 175 if (static_buf != NULL)
176 result = static_buf; 176 result = static_buf;
177 else 177 else
178 { 178 {
179 /* We don't use the static buffer and so we have a key. Use it 179 /* We don't use the static buffer and so we have a key. Use it
180 to get the thread-specific buffer. */ 180 to get the thread-specific buffer. */
181 result = __libc_getspecific (key); 181 result = __libc_getspecific (key);
182 if (result == NULL) 182 if (result == NULL)
183 { 183 {
184 /* No buffer allocated so far. */ 184 /* No buffer allocated so far. */
185 result = malloc (BUFFERSIZ); 185 result = malloc (BUFFERSIZ);
186 if (result == NULL) 186 if (result == NULL)
187 /* No more memory available. We use the static buffer. */ 187 /* No more memory available. We use the static buffer. */
188 result = local_buf; 188 result = local_buf;
189 else 189 else
190 __libc_setspecific (key, result); 190 __libc_setspecific (key, result);
191 } 191 }
192 } 192 }
193 193
194 return result; 194 return result;
195 } 195 }