From 568b5313544c91ffbf65ec0e2ca38e5b62668026 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 29 Apr 2009 00:46:58 +0200 Subject: [PATCH] Fix a compilation error. --- ChangeLog | 7 +++++++ lib/mbsrtowcs-state.c | 16 +++++++++++++++- lib/wcsrtombs-state.c | 16 +++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6389ebea2..7e08cfcf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-04-28 Bruno Haible + + Fix a compilation error. + * lib/mbsrtowcs-state.c (_gl_mbsrtowcs_state): Fix initializer. + * lib/wcsrtombs-state.c (_gl_wcsrtombs_state): Likewise. + Reported by Jim Meyering. + 2009-04-27 Bruno Haible New module 'libunistring'. diff --git a/lib/mbsrtowcs-state.c b/lib/mbsrtowcs-state.c index 3b4db21e0..89011183f 100644 --- a/lib/mbsrtowcs-state.c +++ b/lib/mbsrtowcs-state.c @@ -20,4 +20,18 @@ #include /* Internal state used by the functions mbsrtowcs() and mbsnrtowcs(). */ -mbstate_t _gl_mbsrtowcs_state = 0; +mbstate_t _gl_mbsrtowcs_state +/* The state must initially be in the "initial state"; so, zero-initialize it. + On most systems, putting it into BSS is sufficient. Not so on MacOS X 10.3, + see . + When it needs an initializer, use 0 or {0} as initializer? 0 only works + when mbstate_t is a scalar type (such as when gnulib defines it, or on + AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct + or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)). */ +#if defined __ELF__ + /* On ELF systems, variables in BSS behave well. */ +#else + /* Use braces, to be on the safe side. */ + = { 0 } +#endif + ; diff --git a/lib/wcsrtombs-state.c b/lib/wcsrtombs-state.c index cbdd250e1..d2b123d47 100644 --- a/lib/wcsrtombs-state.c +++ b/lib/wcsrtombs-state.c @@ -20,4 +20,18 @@ #include /* Internal state used by the functions wcsrtombs() and wcsnrtombs(). */ -mbstate_t _gl_wcsrtombs_state = 0; +mbstate_t _gl_wcsrtombs_state +/* The state must initially be in the "initial state"; so, zero-initialize it. + On most systems, putting it into BSS is sufficient. Not so on MacOS X 10.3, + see . + When it needs an initializer, use 0 or {0} as initializer? 0 only works + when mbstate_t is a scalar type (such as when gnulib defines it, or on + AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct + or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)). */ +#if defined __ELF__ + /* On ELF systems, variables in BSS behave well. */ +#else + /* Use braces, to be on the safe side. */ + = { 0 } +#endif + ; -- 2.11.0