summaryrefslogtreecommitdiffstats
path: root/gl/btowc.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2024-10-31 15:27:12 (GMT)
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2024-10-31 15:27:12 (GMT)
commit5be04ec2ceb1df77afbca4fcbf9e92a712612d6f (patch)
tree2b2e1c71dffae827c8e45cd4cccc375093d03486 /gl/btowc.c
parent6d1d1dac32841d5ca6ee51bb09b30a6c604b17e2 (diff)
downloadmonitoring-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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gl/btowc.c b/gl/btowc.c
index caadbd7..8bf21aa 100644
--- a/gl/btowc.c
+++ b/gl/btowc.c
@@ -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
26wint_t 27wint_t
27btowc (int c) 28btowc (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;