about summary refs log tree commit diff
path: root/wcsmbs
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-06-01 08:52:38 +0000
committerUlrich Drepper <drepper@redhat.com>2003-06-01 08:52:38 +0000
commit80b5421740a2aeed70072c378762005b671086af (patch)
tree8ec9e742adb052f5f9b2a7c246ca24f3712c093e /wcsmbs
parent31195be25b5cd8e88426ab2496eaeb4d508b0764 (diff)
downloadglibc-80b5421740a2aeed70072c378762005b671086af.tar.gz
glibc-80b5421740a2aeed70072c378762005b671086af.tar.xz
glibc-80b5421740a2aeed70072c378762005b671086af.zip
Update.
2003-06-01  Ulrich Drepper  <drepper@redhat.com>

	* elf/Makefile (CFLAGS-dl-runtime.c): Define.

	* wcsmbs/wcpncpy.c (__wcpncpy): Fix broken implementation to match
	stpncpy.
Diffstat (limited to 'wcsmbs')
-rw-r--r--wcsmbs/wcpncpy.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/wcsmbs/wcpncpy.c b/wcsmbs/wcpncpy.c
index 59b7301ca8..df7efd7fb0 100644
--- a/wcsmbs/wcpncpy.c
+++ b/wcsmbs/wcpncpy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
 
@@ -58,9 +58,7 @@ __wcpncpy (dest, src, n)
 	  if (--n4 == 0)
 	    goto last_chars;
 	}
-      n = n - (dest - s) - 1;
-      if (n == 0)
-	return dest;
+      n -= dest - s;
       goto zero_fill;
     }
 
@@ -69,21 +67,22 @@ __wcpncpy (dest, src, n)
   if (n == 0)
     return dest;
 
-  do
+  for (;;)
     {
       c = *src++;
-      *++dest = c;
-      if (--n == 0)
+      --n;
+      *dest++ = c;
+      if (c == L'\0')
+	break;
+      if (n == 0)
 	return dest;
     }
-  while (c != L'\0');
 
  zero_fill:
-  do
-    *++dest = L'\0';
-  while (--n > 0);
+  while (n-- > 0)
+    dest[n] = L'\0';
 
-  return dest;
+  return dest - 1;
 }
 
 weak_alias (__wcpncpy, wcpncpy)