diff options
author | tjr <tjr@FreeBSD.org> | 2004-04-06 13:14:03 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-04-06 13:14:03 +0000 |
commit | 4212f9711ffee179c943b9f40b788b759a1ad9e6 (patch) | |
tree | 6779dc19a3df61ca545f851748ebd5f5de3a255e /lib/libc/locale/mbrlen.c | |
parent | fcc4fa555ff7fcd7b9e4327aa717b090a18361b5 (diff) | |
download | FreeBSD-src-4212f9711ffee179c943b9f40b788b759a1ad9e6.zip FreeBSD-src-4212f9711ffee179c943b9f40b788b759a1ad9e6.tar.gz |
Prepare to handle state-dependent encodings. This mainly involves not
taking shortcuts when it comes to storing and passing around conversion
states.
Diffstat (limited to 'lib/libc/locale/mbrlen.c')
-rw-r--r-- | lib/libc/locale/mbrlen.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libc/locale/mbrlen.c b/lib/libc/locale/mbrlen.c index a2ab65b..edad289 100644 --- a/lib/libc/locale/mbrlen.c +++ b/lib/libc/locale/mbrlen.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002 Tim J. Robbins. + * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,8 +30,11 @@ __FBSDID("$FreeBSD$"); #include <wchar.h> size_t -mbrlen(const char * __restrict s, size_t n, mbstate_t * __restrict ps __unused) +mbrlen(const char * __restrict s, size_t n, mbstate_t * __restrict ps) { + static mbstate_t mbs; - return (mbrtowc(NULL, s, n, NULL)); + if (ps == NULL) + ps = &mbs; + return (mbrtowc(NULL, s, n, ps)); } |