diff options
Diffstat (limited to 'gl/mbsinit.c')
-rw-r--r-- | gl/mbsinit.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/gl/mbsinit.c b/gl/mbsinit.c index 26fbb7fa..9621defc 100644 --- a/gl/mbsinit.c +++ b/gl/mbsinit.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* Test for initial conversion state. | 1 | /* Test for initial conversion state. |
2 | Copyright (C) 2008-2013 Free Software Foundation, Inc. | 2 | Copyright (C) 2008-2022 Free Software Foundation, Inc. |
3 | Written by Bruno Haible <bruno@clisp.org>, 2008. | 3 | Written by Bruno Haible <bruno@clisp.org>, 2008. |
4 | 4 | ||
5 | This program is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU Lesser General Public License as |
7 | the Free Software Foundation; either version 3 of the License, or | 7 | published by the Free Software Foundation; either version 2.1 of the |
8 | (at your option) any later version. | 8 | License, or (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This file is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU Lesser General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Lesser General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 16 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
17 | 17 | ||
18 | #include <config.h> | 18 | #include <config.h> |
19 | 19 | ||
@@ -22,17 +22,7 @@ | |||
22 | 22 | ||
23 | #include "verify.h" | 23 | #include "verify.h" |
24 | 24 | ||
25 | #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ | 25 | #if GNULIB_defined_mbstate_t |
26 | |||
27 | /* On native Windows, 'mbstate_t' is defined as 'int'. */ | ||
28 | |||
29 | int | ||
30 | mbsinit (const mbstate_t *ps) | ||
31 | { | ||
32 | return ps == NULL || *ps == 0; | ||
33 | } | ||
34 | |||
35 | #else | ||
36 | 26 | ||
37 | /* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs() | 27 | /* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs() |
38 | and wcrtomb(), wcsrtombs(). | 28 | and wcrtomb(), wcsrtombs(). |
@@ -45,6 +35,7 @@ mbsinit (const mbstate_t *ps) | |||
45 | We define the meaning of mbstate_t as follows: | 35 | We define the meaning of mbstate_t as follows: |
46 | - In mb -> wc direction, mbstate_t's first byte contains the number of | 36 | - In mb -> wc direction, mbstate_t's first byte contains the number of |
47 | buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. | 37 | buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. |
38 | See mbrtowc.c. | ||
48 | - In wc -> mb direction, mbstate_t contains no information. In other | 39 | - In wc -> mb direction, mbstate_t contains no information. In other |
49 | words, it is always in the initial state. */ | 40 | words, it is always in the initial state. */ |
50 | 41 | ||
@@ -58,4 +49,22 @@ mbsinit (const mbstate_t *ps) | |||
58 | return pstate == NULL || pstate[0] == 0; | 49 | return pstate == NULL || pstate[0] == 0; |
59 | } | 50 | } |
60 | 51 | ||
52 | #else | ||
53 | |||
54 | int | ||
55 | mbsinit (const mbstate_t *ps) | ||
56 | { | ||
57 | # if defined _WIN32 && !defined __CYGWIN__ | ||
58 | /* Native Windows. */ | ||
59 | /* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4 bytes matter. | ||
60 | On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined as | ||
61 | an 8-byte struct, of which the first 4 bytes matter. */ | ||
62 | return ps == NULL || *(const unsigned int *)ps == 0; | ||
63 | # else | ||
64 | /* Minix, HP-UX 11.00, Solaris 2.6, Interix, ... */ | ||
65 | /* Maybe this definition works, maybe not... */ | ||
66 | return ps == NULL || *(const char *)ps == 0; | ||
67 | # endif | ||
68 | } | ||
69 | |||
61 | #endif | 70 | #endif |