diff options
| author | he <he@NetBSD.org> | 2007-05-29 17:46:44 +0000 |
|---|---|---|
| committer | he <he@NetBSD.org> | 2007-05-29 17:46:44 +0000 |
| commit | 2f140cf7fe80d28bb0d3fce413387dd6f233449c (patch) | |
| tree | c05ecd21885debbc06b3c006f16f299d75a2ede4 /distrib/utils/libhack | |
| parent | 3d9ab41d78bc8e44b7aa10cfd581e95023955463 (diff) | |
Undo the #if 0 for the multibyte functions we now need to build
ramdisks, and provide untested minimal implementations of mbsrtowcs()
and wcsrtombs().
Verified to fix build problems for at least the amd64 and hp300 ramdisks.
Diffstat (limited to 'distrib/utils/libhack')
| -rw-r--r-- | distrib/utils/libhack/multibyte.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/distrib/utils/libhack/multibyte.c b/distrib/utils/libhack/multibyte.c index 1710fdee63e..7e4e34e4ffd 100644 --- a/distrib/utils/libhack/multibyte.c +++ b/distrib/utils/libhack/multibyte.c @@ -1,4 +1,4 @@ -/* $NetBSD: multibyte.c,v 1.1 2007/04/02 15:53:25 christos Exp $ */ +/* $NetBSD: multibyte.c,v 1.2 2007/05/29 17:46:44 he Exp $ */ /* * Ignore all multibyte sequences, removes all the citrus code. @@ -26,10 +26,6 @@ wctob(wint_t x) return x; } -#if 0 -/* - * We don't need these yet. - */ wint_t btowc(int x) { return x; @@ -55,16 +51,34 @@ size_t mbsrtowcs(wchar_t * __restrict pwcs, const char ** __restrict s, size_t n, mbstate_t * __restrict ps) { - /* XXX: Implement me */ - return 0; + const char *p; + wchar_t *d; + size_t count; + + for (p = *s, d = pwcs, count = 0; + count <= n; + count++, d++, p++) + { + if (mbrtowc(d, p, 1, ps) == 0) + break; + } + return count; } size_t wcsrtombs(char * __restrict s, const wchar_t ** __restrict pwcs, size_t n, mbstate_t * __restrict ps) { - /* XXX: Implement me */ - return 0; -} + char *d; + const wchar_t *p; + size_t count; -#endif + for (p = *pwcs, d = s, count = 0; + count <= n && *p != 0; + count++, d++, p++) + { + wcrtomb(d, *p, ps); + } + *d = 0; + return count; +} |
