From 74f5199426d5bb6d3a3b91253fcc10dc3e19600f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 19 Jan 2000 06:51:15 +0000 Subject: [PATCH] Compute return value correctly after change in gconv function. --- wcsmbs/mbsrtowcs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wcsmbs/mbsrtowcs.c b/wcsmbs/mbsrtowcs.c index 84b7a3883bb..d32c4ee17e0 100644 --- a/wcsmbs/mbsrtowcs.c +++ b/wcsmbs/mbsrtowcs.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -42,7 +42,7 @@ __mbsrtowcs (dst, src, len, ps) mbstate_t *ps; { struct gconv_step_data data; - size_t result = 0; + size_t result; int status; /* Tell where we want the result. */ @@ -61,6 +61,7 @@ __mbsrtowcs (dst, src, len, ps) const unsigned char *inbuf = (const unsigned char *) *src; const unsigned char *srcend = inbuf + strlen (inbuf) + 1; + result = 0; data.outbufend = (char *) buf + sizeof (buf); do { @@ -69,6 +70,8 @@ __mbsrtowcs (dst, src, len, ps) status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, &data, &inbuf, srcend, &result, 0); + + result += (wchar_t *) data.__outbuf - buf; } while (status == GCONV_FULL_OUTPUT); @@ -99,6 +102,8 @@ __mbsrtowcs (dst, src, len, ps) (const unsigned char **) src, srcend, &result, 0); + result = (wchar_t *) data.__outbuf - dst; + /* We have to determine whether the last character converted is the NUL character. */ if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) -- 2.47.2