Colin Watson wrote: > The attached updated patches address your concerns and Paul's
Thanks; looks better now. Two points still: - This code will not compile with C89 compilers on platforms without threading, due to the semicolon: strsignal (int signum) { __libc_once_define (static, once); const char *desc; Here I think you need to swap the two lines; then you can also remove the semicolon in your definition of the macro __libc_once_define. - In the init function, definition of init_sig, you don't need a do { ... } while (0); wrapper since it is a no-op. The comment could read: /* No need to use a do {} while (0) here since init_sig(...) must expand to a complete statement. (We cannot use the ISO C99 designated array initializer syntax since it is not supported by ANSI C compilers and since some signal numbers might exceed NSIG.) */ Attached you find a proposed patch. > I'd still like to know if anyone has any suggestions that avoid the > snprintf dependency. The snprintf is needed here. For i18n reasons, the message _("Unknown signal %d") cannot be split; some *printf function is needed to executed the translated format string. Since the given buffer is statically sized, snprintf is the best match. Here the return value of snprintf is not used, but I don't think it's worth creating another snprintf variant module that guarantees only the existence of the snprintf function but not its correct return value. Bruno *** lib/strsignal.c.orig 2008-01-09 10:51:00.000000000 +0100 --- lib/strsignal.c 2008-01-09 10:50:52.000000000 +0100 *************** *** 38,44 **** #else /* !_LIBC */ # include "lock.h" # include "tls.h" ! # define __libc_once_define(CLASS, NAME) gl_once_define (CLASS, NAME); # define __libc_once(NAME, INIT) gl_once ((NAME), (INIT)) # define __libc_key_t gl_tls_key_t # define __libc_getspecific(NAME) gl_tls_get ((NAME)) --- 38,44 ---- #else /* !_LIBC */ # include "lock.h" # include "tls.h" ! # define __libc_once_define(CLASS, NAME) gl_once_define (CLASS, NAME) # define __libc_once(NAME, INIT) gl_once ((NAME), (INIT)) # define __libc_key_t gl_tls_key_t # define __libc_getspecific(NAME) gl_tls_get ((NAME)) *************** *** 89,96 **** char * strsignal (int signum) { - __libc_once_define (static, once); const char *desc; /* If we have not yet initialized the buffer do it now. */ __libc_once (once, init); --- 89,96 ---- char * strsignal (int signum) { const char *desc; + __libc_once_define (static, once); /* If we have not yet initialized the buffer do it now. */ __libc_once (once, init); *************** *** 140,152 **** # if !HAVE_DECL_SYS_SIGLIST memset (_sys_siglist, 0, NSIG * sizeof *_sys_siglist); ! /* The trailing semicolon is because siglist.h is really designed for ! array initializers, but we don't want that here because the signal ! numbers might exceed NSIG. */ ! # define init_sig(sig, abbrev, desc) do { \ if (sig >= 0 && sig < NSIG) \ ! _sys_siglist[sig] = desc; \ ! } while (0); # include "siglist.h" --- 140,152 ---- # if !HAVE_DECL_SYS_SIGLIST memset (_sys_siglist, 0, NSIG * sizeof *_sys_siglist); ! /* No need to use a do {} while (0) here since init_sig(...) must expand ! to a complete statement. (We cannot use the ISO C99 designated array ! initializer syntax since it is not supported by ANSI C compilers and ! since some signal numbers might exceed NSIG.) */ ! # define init_sig(sig, abbrev, desc) \ if (sig >= 0 && sig < NSIG) \ ! _sys_siglist[sig] = desc; # include "siglist.h"