Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/locale sync with latest Citrus XPG4DL.
details: https://anonhg.NetBSD.org/src/rev/a029043fe9f0
branches: trunk
changeset: 511523:a029043fe9f0
user: yamt <yamt%NetBSD.org@localhost>
date: Thu Jun 21 02:20:24 2001 +0000
description:
sync with latest Citrus XPG4DL.
- mbsrtowcs/wcsrtombs
- when conversion stopped with terminating-null, set *src null-pointer.
- if dst isn't null, ignore len.
- fix how to treat ___mbrtowc
- mbrtowc
- fix problem that terminating null charactor wasn't stored.
- fix problem with stateful encoding.
(when src points to escape sequence + '\0', mbstate wasn't initialized)
- fix return value when restarted.
XXX euctw and big5 are not tested.
- iso2022-jp
- fix mbrtowc with imcomplete sequence.
- etc
- make sure mbstate is initialized. (___rune_initstate is called)
primarily to fix mbsinit for iso2022.
- sync citrus Id
diffstat:
lib/libc/locale/big5.c | 8 +-
lib/libc/locale/euc.c | 8 +-
lib/libc/locale/euctw.c | 10 ++-
lib/libc/locale/iso2022.c | 25 +++++---
lib/libc/locale/iso2022.h | 4 +-
lib/libc/locale/mskanji.c | 8 +-
lib/libc/locale/multibyte.c | 121 ++++++++++++++++++++++++++++---------------
lib/libc/locale/runeglue.c | 6 +-
lib/libc/locale/utf8.c | 10 ++-
9 files changed, 126 insertions(+), 74 deletions(-)
diffs (truncated from 644 to 300 lines):
diff -r 8d2834f590d2 -r a029043fe9f0 lib/libc/locale/big5.c
--- a/lib/libc/locale/big5.c Thu Jun 21 01:17:18 2001 +0000
+++ b/lib/libc/locale/big5.c Thu Jun 21 02:20:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: big5.c,v 1.7 2001/01/27 05:40:18 tsutsui Exp $ */
+/* $NetBSD: big5.c,v 1.8 2001/06/21 02:20:24 yamt Exp $ */
/*-
* Copyright (c) 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)big5.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: big5.c,v 1.7 2001/01/27 05:40:18 tsutsui Exp $");
+__RCSID("$NetBSD: big5.c,v 1.8 2001/06/21 02:20:24 yamt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -142,6 +142,7 @@
_BIG5State *ps;
rune_t rune;
int c;
+ int chlenbak;
/* rl appears to be unused */
/* pwcs may be NULL */
@@ -149,6 +150,7 @@
_DIAGASSERT(state != NULL);
ps = state;
+ chlenbak = ps->chlen;
/* make sure we have the first byte in the buffer */
switch (ps->chlen) {
@@ -197,7 +199,7 @@
if (!rune)
return 0;
else
- return c;
+ return c - chlenbak;
encoding_error:
ps->chlen = 0;
diff -r 8d2834f590d2 -r a029043fe9f0 lib/libc/locale/euc.c
--- a/lib/libc/locale/euc.c Thu Jun 21 01:17:18 2001 +0000
+++ b/lib/libc/locale/euc.c Thu Jun 21 02:20:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: euc.c,v 1.8 2001/03/26 20:06:46 tshiozak Exp $ */
+/* $NetBSD: euc.c,v 1.9 2001/06/21 02:20:24 yamt Exp $ */
/*-
* Copyright (c) 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: euc.c,v 1.8 2001/03/26 20:06:46 tshiozak Exp $");
+__RCSID("$NetBSD: euc.c,v 1.9 2001/06/21 02:20:24 yamt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -183,6 +183,7 @@
_EUCState *ps;
rune_t rune;
int c, set, len;
+ int chlenbak;
_DIAGASSERT(rl != NULL);
/* pwcs may be NULL */
@@ -190,6 +191,7 @@
_DIAGASSERT(state != NULL);
ps = state;
+ chlenbak = ps->chlen;
/* make sure we have the first byte in the buffer */
switch (ps->chlen) {
@@ -243,7 +245,7 @@
if (!rune)
return 0;
else
- return c;
+ return c - chlenbak;
encoding_error:
ps->chlen = 0;
diff -r 8d2834f590d2 -r a029043fe9f0 lib/libc/locale/euctw.c
--- a/lib/libc/locale/euctw.c Thu Jun 21 01:17:18 2001 +0000
+++ b/lib/libc/locale/euctw.c Thu Jun 21 02:20:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: euctw.c,v 1.9 2001/01/27 05:40:18 tsutsui Exp $ */
+/* $NetBSD: euctw.c,v 1.10 2001/06/21 02:20:24 yamt Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@@ -25,12 +25,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * citrus Id: euctw.c,v 1.10 2000/12/30 04:51:34 itojun Exp
+ * $Citrus: xpg4dl/FreeBSD/lib/libc/locale/euctw.c,v 1.13 2001/06/21 01:51:44 yamt Exp $
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: euctw.c,v 1.9 2001/01/27 05:40:18 tsutsui Exp $");
+__RCSID("$NetBSD: euctw.c,v 1.10 2001/06/21 02:20:24 yamt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -141,6 +141,7 @@
_EUCTWState *ps;
rune_t rune;
int c, set;
+ int chlenbak;
/* rl appears to be unused */
/* pwcs may be NULL */
@@ -148,6 +149,7 @@
_DIAGASSERT(state != NULL);
ps = state;
+ chlenbak = ps->chlen;
/* make sure we have the first byte in the buffer */
switch (ps->chlen) {
@@ -208,7 +210,7 @@
if (!rune)
return 0;
else
- return c;
+ return c - chlenbak;
encoding_error:
ps->chlen = 0;
diff -r 8d2834f590d2 -r a029043fe9f0 lib/libc/locale/iso2022.c
--- a/lib/libc/locale/iso2022.c Thu Jun 21 01:17:18 2001 +0000
+++ b/lib/libc/locale/iso2022.c Thu Jun 21 02:20:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iso2022.c,v 1.11 2001/01/25 09:46:44 jdolecek Exp $ */
+/* $NetBSD: iso2022.c,v 1.12 2001/06/21 02:20:24 yamt Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@@ -25,12 +25,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * citrus Id: iso2022.c,v 1.19 2000/12/30 04:51:34 itojun Exp
+ * $Citrus: xpg4dl/FreeBSD/lib/libc/locale/iso2022.c,v 1.23 2001/06/21 01:51:44 yamt Exp $
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: iso2022.c,v 1.11 2001/01/25 09:46:44 jdolecek Exp $");
+__RCSID("$NetBSD: iso2022.c,v 1.12 2001/06/21 02:20:24 yamt Exp $");
#endif /* LIBC_SCCS and not lint */
/*
@@ -996,6 +996,7 @@
rune_t rune;
const char *p, *result;
int c;
+ int chlenbak;
_DIAGASSERT(rl != NULL);
/* pwcs may be NULL */
@@ -1003,6 +1004,8 @@
_DIAGASSERT(state != NULL);
ps = state;
+ c = 0;
+ chlenbak = ps->chlen;
/*
* if we have something in buffer, use that.
@@ -1015,7 +1018,7 @@
if (ps->chlen == 0)
goto nobuf;
p = ps->ch;
- while (ps->chlen && ps->chlen < sizeof(ps->ch) && n >= 0) {
+ while (ps->chlen < sizeof(ps->ch) && n >= 0) {
if (n > 0) {
ps->ch[ps->chlen++] = *s++;
n--;
@@ -1024,7 +1027,7 @@
rune = _ISO2022_sgetrune(rl, p, ps->chlen - (p - ps->ch),
&result, state);
if (rune != _INVALID_RUNE) {
- c = result - p;
+ c += result - p;
if (ps->chlen > c)
memmove(ps->ch, result, ps->chlen - c);
if (ps->chlen < c)
@@ -1034,6 +1037,7 @@
goto output;
}
+ c += result - p;
p = result;
if (n == 0)
@@ -1046,21 +1050,24 @@
nobuf:
rune = _ISO2022_sgetrune(rl, s, n, &result, state);
if (rune != _INVALID_RUNE) {
- c = result - s;
+ c += result - s;
ps->chlen = 0;
goto output;
}
if (result > s && n > result - s) {
+ c += (result - s);
n -= (result - s);
s = result;
goto nobuf;
}
- if (result == s && n < sizeof(ps->ch)) {
- memcpy(ps->ch, s, n);
+ n += c;
+ if (n < sizeof(ps->ch)) {
+ memcpy(ps->ch, s - c, n);
ps->chlen = n;
return (size_t)-2;
}
+
/* escape sequence too long? */
encoding_error:
@@ -1073,7 +1080,7 @@
if (!rune)
return 0;
else
- return c;
+ return c - chlenbak;
}
/* s is non-null */
diff -r 8d2834f590d2 -r a029043fe9f0 lib/libc/locale/iso2022.h
--- a/lib/libc/locale/iso2022.h Thu Jun 21 01:17:18 2001 +0000
+++ b/lib/libc/locale/iso2022.h Thu Jun 21 02:20:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iso2022.h,v 1.4 2000/12/28 05:27:35 itojun Exp $ */
+/* $NetBSD: iso2022.h,v 1.5 2001/06/21 02:20:24 yamt Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * citrus Id: iso2022.h,v 1.3 2000/12/26 11:08:04 itojun Exp
+ * $Citrus: xpg4dl/FreeBSD/lib/libc/locale/iso2022.h,v 1.4 2001/06/21 01:51:44 yamt Exp $
*/
typedef struct {
diff -r 8d2834f590d2 -r a029043fe9f0 lib/libc/locale/mskanji.c
--- a/lib/libc/locale/mskanji.c Thu Jun 21 01:17:18 2001 +0000
+++ b/lib/libc/locale/mskanji.c Thu Jun 21 02:20:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mskanji.c,v 1.7 2001/01/27 05:40:18 tsutsui Exp $ */
+/* $NetBSD: mskanji.c,v 1.8 2001/06/21 02:20:24 yamt Exp $ */
/*
* ja_JP.SJIS locale table for BSD4.4/rune
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95";
#else
-__RCSID("$NetBSD: mskanji.c,v 1.7 2001/01/27 05:40:18 tsutsui Exp $");
+__RCSID("$NetBSD: mskanji.c,v 1.8 2001/06/21 02:20:24 yamt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -138,6 +138,7 @@
_MSKanjiState *ps;
rune_t rune;
int len;
+ int chlenbak;
/* rl appears to be unused */
/* pwcs may be NULL */
@@ -145,6 +146,7 @@
_DIAGASSERT(state != NULL);
ps = state;
+ chlenbak = ps->chlen;
/* make sure we have the first byte in the buffer */
switch (ps->chlen) {
@@ -191,7 +193,7 @@
if (!rune)
return 0;
else
- return len;
+ return len - chlenbak;
encoding_error:
ps->chlen = 0;
Home |
Main Index |
Thread Index |
Old Index