ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/misc.C
(Generate patch)

Comparing rxvt-unicode/src/misc.C (file contents):
Revision 1.59 by sf-exg, Wed Nov 12 12:12:02 2014 UTC vs.
Revision 1.60 by sf-exg, Thu May 13 19:40:19 2021 UTC

29#include <new> 29#include <new>
30 30
31// alas new/delete cannot be specified as inline in C++11 (see 17.6.4.6) 31// alas new/delete cannot be specified as inline in C++11 (see 17.6.4.6)
32void * 32void *
33operator new (size_t s) 33operator new (size_t s)
34#if !ECB_CPP11
35 throw (std::bad_alloc)
36#endif
37{ 34{
38 return rxvt_malloc (s); 35 return rxvt_malloc (s);
39} 36}
40 37
41void 38void
42operator delete (void *p) 39operator delete (void *p) noexcept
43#if ECB_CPP11
44 noexcept
45#else
46 throw ()
47#endif
48{ 40{
49 free (p); 41 free (p);
50} 42}
51 43
52char * 44char *
189 181
190 return r; 182 return r;
191} 183}
192 184
193const char * 185const char *
194rxvt_basename (const char *str) NOTHROW 186rxvt_basename (const char *str) noexcept
195{ 187{
196 const char *base = strrchr (str, '/'); 188 const char *base = strrchr (str, '/');
197 189
198 return base ? base + 1 : str; 190 return base ? base + 1 : str;
199} 191}
200 192
201/* 193/*
202 * Print an error message 194 * Print an error message
203 */ 195 */
204void 196void
205rxvt_vlog (const char *fmt, va_list arg_ptr) NOTHROW 197rxvt_vlog (const char *fmt, va_list arg_ptr) noexcept
206{ 198{
207 char msg[1024]; 199 char msg[1024];
208 200
209 vsnprintf (msg, sizeof msg, fmt, arg_ptr); 201 vsnprintf (msg, sizeof msg, fmt, arg_ptr);
210 202
213 else 205 else
214 write (STDOUT_FILENO, msg, strlen (msg)); 206 write (STDOUT_FILENO, msg, strlen (msg));
215} 207}
216 208
217void 209void
218rxvt_log (const char *fmt,...) NOTHROW 210rxvt_log (const char *fmt,...) noexcept
219{ 211{
220 va_list arg_ptr; 212 va_list arg_ptr;
221 213
222 va_start (arg_ptr, fmt); 214 va_start (arg_ptr, fmt);
223 rxvt_vlog (fmt, arg_ptr); 215 rxvt_vlog (fmt, arg_ptr);
226 218
227/* 219/*
228 * Print an error message 220 * Print an error message
229 */ 221 */
230void 222void
231rxvt_warn (const char *fmt,...) NOTHROW 223rxvt_warn (const char *fmt,...) noexcept
232{ 224{
233 va_list arg_ptr; 225 va_list arg_ptr;
234 226
235 rxvt_log ("%s: ", RESNAME); 227 rxvt_log ("%s: ", RESNAME);
236 228
238 rxvt_vlog (fmt, arg_ptr); 230 rxvt_vlog (fmt, arg_ptr);
239 va_end (arg_ptr); 231 va_end (arg_ptr);
240} 232}
241 233
242void 234void
243rxvt_fatal (const char *fmt,...) THROW ((class rxvt_failure_exception)) 235rxvt_fatal (const char *fmt,...)
244{ 236{
245 va_list arg_ptr; 237 va_list arg_ptr;
246 238
247 rxvt_log ("%s: ", RESNAME); 239 rxvt_log ("%s: ", RESNAME);
248 240
252 244
253 rxvt_exit_failure (); 245 rxvt_exit_failure ();
254} 246}
255 247
256void 248void
257rxvt_exit_failure () THROW ((class rxvt_failure_exception)) 249rxvt_exit_failure ()
258{ 250{
259 static class rxvt_failure_exception rxvt_failure_exception; 251 static class rxvt_failure_exception rxvt_failure_exception;
260 throw (rxvt_failure_exception); 252 throw (rxvt_failure_exception);
261} 253}
262 254
263/* 255/*
264 * remove leading/trailing space in place. 256 * remove leading/trailing space in place.
265 */ 257 */
266char * 258char *
267rxvt_strtrim (char *str) NOTHROW 259rxvt_strtrim (char *str) noexcept
268{ 260{
269 char *r, *s; 261 char *r, *s;
270 262
271 if (!str || !*str) /* shortcut */ 263 if (!str || !*str) /* shortcut */
272 return str; 264 return str;
290/* 282/*
291 * Split a string into an array based on the given delimiter, stripping leading and 283 * Split a string into an array based on the given delimiter, stripping leading and
292 * trailing spaces from each entry. Empty strings are properly returned 284 * trailing spaces from each entry. Empty strings are properly returned
293 */ 285 */
294char ** 286char **
295rxvt_strsplit (char delim, const char *str) NOTHROW 287rxvt_strsplit (char delim, const char *str) noexcept
296{ 288{
297 int l, n; 289 int l, n;
298 char *s, *t; 290 char *s, *t;
299 char **ret; 291 char **ret;
300 292

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines