summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/bsd-misc.c')
-rw-r--r--openbsd-compat/bsd-misc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 2a788e47f..18bf62dd8 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -284,3 +284,20 @@ pledge(const char *promises, const char *paths[])
284 return 0; 284 return 0;
285} 285}
286#endif 286#endif
287
288#ifndef HAVE_MBTOWC
289/* a mbtowc that only supports ASCII */
290int
291mbtowc(wchar_t *pwc, const char *s, size_t n)
292{
293 if (s == NULL || *s == '\0')
294 return 0; /* ASCII is not state-dependent */
295 if (*s < 0 || *s > 0x7f || n < 1) {
296 errno = EOPNOTSUPP;
297 return -1;
298 }
299 if (pwc != NULL)
300 *pwc = *s;
301 return 1;
302}
303#endif