From 879ba026666c5dd256f1e6074d5455d115e6b0a9 Mon Sep 17 00:00:00 2001 From: soda Date: Sat, 25 Sep 2004 23:51:31 +0000 Subject: [PATCH] corrent an error in previous commit: don't corrupt return value on error case, pointed out by yamt --- lib/libc/citrus/citrus_ctype_template.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/libc/citrus/citrus_ctype_template.h b/lib/libc/citrus/citrus_ctype_template.h index bb08285a5f5c..09e6ec755354 100644 --- a/lib/libc/citrus/citrus_ctype_template.h +++ b/lib/libc/citrus/citrus_ctype_template.h @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_ctype_template.h,v 1.26 2004/09/25 22:53:46 soda Exp $ */ +/* $NetBSD: citrus_ctype_template.h,v 1.27 2004/09/25 23:51:31 soda Exp $ */ /*- * Copyright (c)2002 Citrus Project, @@ -603,7 +603,8 @@ _FUNCNAME(ctype_wcrtomb)(void * __restrict cl, char * __restrict s, wchar_t wc, err = _FUNCNAME(wcrtomb_priv)(_CEI_TO_EI(_TO_CEI(cl)), s, sz, wc, psenc, nresult); #if _ENCODING_IS_STATE_DEPENDENT - *nresult += rsz; + if (err == 0) + *nresult += rsz; quit: #endif if (err == E2BIG) @@ -693,7 +694,8 @@ _FUNCNAME(ctype_wctomb)(void * __restrict cl, char * __restrict s, wchar_t wc, #endif err = _FUNCNAME(wcrtomb_priv)(ei, s, sz, wc, psenc, &nr); #if _ENCODING_IS_STATE_DEPENDENT - *nresult = (int)(nr + rsz); + if (err == 0) + *nresult = (int)(nr + rsz); #else *nresult = (int)nr; #endif