diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-31 15:27:12 (GMT) |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-31 15:27:12 (GMT) |
commit | 5be04ec2ceb1df77afbca4fcbf9e92a712612d6f (patch) | |
tree | 2b2e1c71dffae827c8e45cd4cccc375093d03486 /gl/btowc.c | |
parent | 6d1d1dac32841d5ca6ee51bb09b30a6c604b17e2 (diff) | |
download | monitoring-plugins-5be04ec2ceb1df77afbca4fcbf9e92a712612d6f.tar.gz |
Sync with the latest Gnulib code (d4ec02b3cc)refs/pull/2037/head
Diffstat (limited to 'gl/btowc.c')
-rw-r--r-- | gl/btowc.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* Convert unibyte character to wide character. | 1 | /* Convert unibyte character to wide character. |
2 | Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. | 2 | Copyright (C) 2008, 2010-2024 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 file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <stdio.h> | 23 | #include <stdio.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include <string.h> | ||
25 | 26 | ||
26 | wint_t | 27 | wint_t |
27 | btowc (int c) | 28 | btowc (int c) |
@@ -32,7 +33,14 @@ btowc (int c) | |||
32 | wchar_t wc; | 33 | wchar_t wc; |
33 | 34 | ||
34 | buf[0] = c; | 35 | buf[0] = c; |
36 | #if HAVE_MBRTOWC | ||
37 | mbstate_t state; | ||
38 | mbszero (&state); | ||
39 | size_t ret = mbrtowc (&wc, buf, 1, &state); | ||
40 | if (!(ret == (size_t)(-1) || ret == (size_t)(-2))) | ||
41 | #else | ||
35 | if (mbtowc (&wc, buf, 1) >= 0) | 42 | if (mbtowc (&wc, buf, 1) >= 0) |
43 | #endif | ||
36 | return wc; | 44 | return wc; |
37 | } | 45 | } |
38 | return WEOF; | 46 | return WEOF; |