xref: /Universal-ctags/gnulib/mbsrtowcs-state.c (revision a939078a69878851c19820eb92e6cb95ba429546)
1*a939078aSHiroo HAYASHI /* Convert string to wide string.
2*a939078aSHiroo HAYASHI    Copyright (C) 2008-2021 Free Software Foundation, Inc.
3*a939078aSHiroo HAYASHI    Written by Bruno Haible <bruno@clisp.org>, 2008.
4*a939078aSHiroo HAYASHI 
5*a939078aSHiroo HAYASHI    This file is free software: you can redistribute it and/or modify
6*a939078aSHiroo HAYASHI    it under the terms of the GNU Lesser General Public License as
7*a939078aSHiroo HAYASHI    published by the Free Software Foundation; either version 2.1 of the
8*a939078aSHiroo HAYASHI    License, or (at your option) any later version.
9*a939078aSHiroo HAYASHI 
10*a939078aSHiroo HAYASHI    This file is distributed in the hope that it will be useful,
11*a939078aSHiroo HAYASHI    but WITHOUT ANY WARRANTY; without even the implied warranty of
12*a939078aSHiroo HAYASHI    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*a939078aSHiroo HAYASHI    GNU Lesser General Public License for more details.
14*a939078aSHiroo HAYASHI 
15*a939078aSHiroo HAYASHI    You should have received a copy of the GNU Lesser General Public License
16*a939078aSHiroo HAYASHI    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
17*a939078aSHiroo HAYASHI 
18*a939078aSHiroo HAYASHI #include <config.h>
19*a939078aSHiroo HAYASHI 
20*a939078aSHiroo HAYASHI #include <wchar.h>
21*a939078aSHiroo HAYASHI 
22*a939078aSHiroo HAYASHI /* Internal state used by the functions mbsrtowcs() and mbsnrtowcs().  */
23*a939078aSHiroo HAYASHI mbstate_t _gl_mbsrtowcs_state
24*a939078aSHiroo HAYASHI /* The state must initially be in the "initial state"; so, zero-initialize it.
25*a939078aSHiroo HAYASHI    On most systems, putting it into BSS is sufficient.  Not so on Mac OS X 10.3,
26*a939078aSHiroo HAYASHI    see <https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>.
27*a939078aSHiroo HAYASHI    When it needs an initializer, use 0 or {0} as initializer? 0 only works
28*a939078aSHiroo HAYASHI    when mbstate_t is a scalar type (such as when gnulib defines it, or on
29*a939078aSHiroo HAYASHI    AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct
30*a939078aSHiroo HAYASHI    or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)).  */
31*a939078aSHiroo HAYASHI #if defined __ELF__
32*a939078aSHiroo HAYASHI   /* On ELF systems, variables in BSS behave well.  */
33*a939078aSHiroo HAYASHI #else
34*a939078aSHiroo HAYASHI   /* Use braces, to be on the safe side.  */
35*a939078aSHiroo HAYASHI   = { 0 }
36*a939078aSHiroo HAYASHI #endif
37*a939078aSHiroo HAYASHI   ;
38