about summary refs log tree commit diff
path: root/wcsmbs
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-04-28 06:14:43 +0000
committerUlrich Drepper <drepper@redhat.com>2000-04-28 06:14:43 +0000
commita7f91846e95ea8ae3d8298063a4cf2972b5f98b2 (patch)
tree1fca02f50d006172c8249272649004361ba46a2d /wcsmbs
parent8651d8a218babc9e9ccc865a68017f12c588ca23 (diff)
downloadglibc-a7f91846e95ea8ae3d8298063a4cf2972b5f98b2.tar.gz
glibc-a7f91846e95ea8ae3d8298063a4cf2972b5f98b2.tar.xz
glibc-a7f91846e95ea8ae3d8298063a4cf2972b5f98b2.zip
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 <Jes.Sorensen@cern.ch>.
Diffstat (limited to 'wcsmbs')
-rw-r--r--wcsmbs/wcrtomb.c12
1 files changed, 7 insertions, 5 deletions
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;