Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/lib/libc/citrus Pull up revision 1.6 (requested by yamt...
details: https://anonhg.NetBSD.org/src/rev/8abd7800a7b0
branches: netbsd-1-6
changeset: 530241:8abd7800a7b0
user: tron <tron%NetBSD.org@localhost>
date: Mon Jun 02 14:59:32 2003 +0000
description:
Pull up revision 1.6 (requested by yamt in ticket #1202):
mbsrtowcs_priv template:
n == 0 is not an error. it's a valid input.
_citrus_NONE_ctype_mbsrtowcs:
fix a typo that causes SEGV.
while i'm here, make them similar each other.
fix PR 19620.
diffstat:
lib/libc/citrus/citrus_none.c | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
diffs (69 lines):
diff -r c29045f1fc82 -r 8abd7800a7b0 lib/libc/citrus/citrus_none.c
--- a/lib/libc/citrus/citrus_none.c Mon Jun 02 14:56:46 2003 +0000
+++ b/lib/libc/citrus/citrus_none.c Mon Jun 02 14:59:32 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_none.c,v 1.4.2.1 2002/05/24 21:55:23 perry Exp $ */
+/* $NetBSD: citrus_none.c,v 1.4.2.2 2003/06/02 14:59:32 tron Exp $ */
/*-
* Copyright (c)2002 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_none.c,v 1.4.2.1 2002/05/24 21:55:23 perry Exp $");
+__RCSID("$NetBSD: citrus_none.c,v 1.4.2.2 2003/06/02 14:59:32 tron Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
@@ -144,31 +144,39 @@
static int
/*ARGSUSED*/
-_citrus_NONE_ctype_mbsrtowcs(void * __restrict cl, wchar_t * __restrict wcs,
+_citrus_NONE_ctype_mbsrtowcs(void * __restrict cl, wchar_t * __restrict pwcs,
const char ** __restrict s, size_t n,
void * __restrict pspriv,
size_t * __restrict nresult)
{
- size_t count;
+ int cnt;
const char *s0;
- count = 0;
- s0 = *s;
- while (n>0) {
- if (wcs != NULL)
- *wcs++ = (wchar_t)(unsigned char)*s0;
+ /* if pwcs is NULL, ignore n */
+ if (pwcs == NULL)
+ n = 1; /* arbitrary >0 value */
+
+ cnt = 0;
+ s0 = *s; /* to keep *s unchanged for now, use copy instead. */
+ while (n > 0) {
+ if (pwcs != NULL) {
+ *pwcs = (wchar_t)(unsigned char)*s0;
+ }
if (*s0 == '\0') {
s0 = NULL;
break;
}
- count++;
- n--;
s0++;
+ if (pwcs != NULL) {
+ pwcs++;
+ n--;
+ }
+ cnt++;
}
- if (*wcs)
+ if (pwcs)
*s = s0;
- *nresult = count;
+ *nresult = (size_t)cnt;
return (0);
}
Home |
Main Index |
Thread Index |
Old Index