diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-06 09:24:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-06 09:24:23 +0100 |
| commit | 9b4df9e50837cc837e113053ba12ee6967d5e6c2 (patch) | |
| tree | bf989e771579f835bcb49c074637a8e224bcecbc /gl/btowc.c | |
| parent | 94150ae347beb25ac369d5773834ceef7f3736d3 (diff) | |
| parent | 5be04ec2ceb1df77afbca4fcbf9e92a712612d6f (diff) | |
| download | monitoring-plugins-9b4df9e50837cc837e113053ba12ee6967d5e6c2.tar.gz | |
Merge pull request #2037 from RincewindsHat/update/gnulib-1.0
Sync with the latest Gnulib code (d4ec02b3cc) (gnulib v1.0)
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; |
