Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/locale - mblen and mbtowc shouldn't return -2.
details: https://anonhg.NetBSD.org/src/rev/40bd0d8b5c47
branches: trunk
changeset: 515935:40bd0d8b5c47
user: yamt <yamt%NetBSD.org@localhost>
date: Tue Oct 09 10:21:48 2001 +0000
description:
- mblen and mbtowc shouldn't return -2.
- non-restartable functions shouldn't be restartable.
diffstat:
lib/libc/locale/multibyte.c | 37 ++++++++++++++++++++++++++++---------
1 files changed, 28 insertions(+), 9 deletions(-)
diffs (92 lines):
diff -r 39009913de23 -r 40bd0d8b5c47 lib/libc/locale/multibyte.c
--- a/lib/libc/locale/multibyte.c Tue Oct 09 05:28:42 2001 +0000
+++ b/lib/libc/locale/multibyte.c Tue Oct 09 10:21:48 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: multibyte.c,v 1.12 2001/06/22 00:01:47 yamt Exp $ */
+/* $NetBSD: multibyte.c,v 1.13 2001/10/09 10:21:48 yamt Exp $ */
/*-
* Copyright (c) 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)ansi.c 8.1 (Berkeley) 6/27/93";
#else
-__RCSID("$NetBSD: multibyte.c,v 1.12 2001/06/22 00:01:47 yamt Exp $");
+__RCSID("$NetBSD: multibyte.c,v 1.13 2001/10/09 10:21:48 yamt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -233,11 +233,19 @@
size_t n;
{
static mbstate_t ls;
+ size_t r;
/* XXX: s may be NULL ? */
- _mbstate_init_locale(&ls, NULL);
- return mbrlen(s, n, &ls);
+ if (___rune_initstate(_CurrentRuneLocale))
+ ___rune_initstate(_CurrentRuneLocale)(_CurrentRuneLocale, &ls);
+ r = mbrlen(s, n, &ls);
+ if (r == (size_t)-2) {
+ errno = EILSEQ;
+ return -1;
+ }
+
+ return (int)r;
}
size_t
@@ -294,12 +302,20 @@
size_t n;
{
static mbstate_t ls;
+ size_t r;
/* pwc may be NULL */
/* s may be NULL */
- _mbstate_init_locale(&ls, NULL);
- return mbrtowc(pwc, s, n, &ls);
+ if (___rune_initstate(_CurrentRuneLocale))
+ ___rune_initstate(_CurrentRuneLocale)(_CurrentRuneLocale, &ls);
+ r = mbrtowc(pwc, s, n, &ls);
+ if (r == (size_t)-2) {
+ errno = EILSEQ;
+ return -1;
+ }
+
+ return (int)r;
}
size_t
@@ -352,7 +368,8 @@
/* s may be NULL */
- _mbstate_init_locale(&ls, NULL);
+ if (___rune_initstate(_CurrentRuneLocale))
+ ___rune_initstate(_CurrentRuneLocale)(_CurrentRuneLocale, &ls);
return wcrtomb(s, wchar, &ls);
}
@@ -444,7 +461,8 @@
/* pwcs may be NULL */
/* s may be NULL */
- _mbstate_init_locale(&ls, NULL);
+ if (___rune_initstate(_CurrentRuneLocale))
+ ___rune_initstate(_CurrentRuneLocale)(_CurrentRuneLocale, &ls);
return mbsrtowcs(pwcs, &s, n, &ls);
}
@@ -529,6 +547,7 @@
/* s may be NULL */
/* pwcs may be NULL */
- _mbstate_init_locale(&ls, NULL);
+ if (___rune_initstate(_CurrentRuneLocale))
+ ___rune_initstate(_CurrentRuneLocale)(_CurrentRuneLocale, &ls);
return wcsrtombs(s, &pwcs, n, &ls);
}
Home |
Main Index |
Thread Index |
Old Index