From a7f91846e95ea8ae3d8298063a4cf2972b5f98b2 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 28 Apr 2000 06:14:43 +0000 Subject: Update. * wcsmbs/wcrtomb.c (__wcrtomb): Set end of buffer correctly if s == NULL. Little optimization. * elf/dl-init.c (_dl_init): Correct typo (DT_PREINIT_ARRAY not DT_PREINIT_ARRAYSZ). Reported by Jes Sorensen . --- wcsmbs/wcrtomb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'wcsmbs') diff --git a/wcsmbs/wcrtomb.c b/wcsmbs/wcrtomb.c index 644d26bbc8..7aef505ef3 100644 --- a/wcsmbs/wcrtomb.c +++ b/wcsmbs/wcrtomb.c @@ -43,9 +43,7 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps) size_t result; size_t dummy; - /* Tell where we want the result. */ - data.__outbuf = s; - data.__outbufend = s + MB_CUR_MAX; + /* Set information for this step. */ data.__invocation_counter = 0; data.__internal_use = 1; data.__is_last = 1; @@ -55,12 +53,16 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps) initial state. */ if (s == NULL) { - data.__outbuf = buf; + s = buf; wc = L'\0'; temp_state = *data.__statep; data.__statep = &temp_state; } + /* Tell where we want to have the result. */ + data.__outbuf = s; + data.__outbufend = s + MB_CUR_MAX; + /* Make sure we use the correct function. */ update_conversion_ptrs (); @@ -98,7 +100,7 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps) if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT || status == __GCONV_FULL_OUTPUT) - result = data.__outbuf - (unsigned char *) (s ?: buf); + result = data.__outbuf - (unsigned char *) s; else { result = (size_t) -1; -- cgit 1.4.1