mbsrtowcs-state.c 1.6 KB

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