summaryrefslogtreecommitdiffstats
path: root/src/bfstd.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-10-27 10:58:47 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-10-27 11:15:07 -0400
commit14ef89a442f7a027f52fd688b438c5fa627b6af7 (patch)
treeb28e2f7114b067a26af6fffea044615d57ef10c8 /src/bfstd.h
parent8ced65189cbea5ff0b06482713d647ca57c91f81 (diff)
downloadbfs-14ef89a442f7a027f52fd688b438c5fa627b6af7.tar.xz
bfstd: Expose xmbrtowc() and use it in eval_status()
Diffstat (limited to 'src/bfstd.h')
-rw-r--r--src/bfstd.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/bfstd.h b/src/bfstd.h
index abde24e..db558c6 100644
--- a/src/bfstd.h
+++ b/src/bfstd.h
@@ -316,7 +316,24 @@ char *xconfstr(int name);
*/
int xstrtofflags(const char **str, unsigned long long *set, unsigned long long *clear);
-// #include <wchar.h>
+#include <wchar.h>
+
+/**
+ * Error-recovering mbrtowc() wrapper.
+ *
+ * @param str
+ * The string to convert.
+ * @param i
+ * The current index.
+ * @param len
+ * The length of the string.
+ * @param mb
+ * The multi-byte decoding state.
+ * @return
+ * The wide character at index *i, or WEOF if decoding fails. In either
+ * case, *i will be advanced to the next multi-byte character.
+ */
+wint_t xmbrtowc(const char *str, size_t *i, size_t len, mbstate_t *mb);
/**
* wcswidth() variant that works on narrow strings.