diff options
author | Roland McGrath <roland@gnu.org> | 1996-07-23 22:18:45 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-07-23 22:18:45 +0000 |
commit | c7fd2f4783d87f29f89709e11dc613b0cb04f0dc (patch) | |
tree | 88088cc31588d432dc66541be24e890f040b1480 /sysdeps/generic | |
parent | b24be05f19d1471526b4643d96c078d32ec1c692 (diff) | |
download | glibc-c7fd2f4783d87f29f89709e11dc613b0cb04f0dc.tar glibc-c7fd2f4783d87f29f89709e11dc613b0cb04f0dc.tar.gz glibc-c7fd2f4783d87f29f89709e11dc613b0cb04f0dc.tar.bz2 glibc-c7fd2f4783d87f29f89709e11dc613b0cb04f0dc.zip |
Tue Jul 23 18:13:37 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>cvs/libc-960725cvs/libc-960724
* sysdeps/mach/hurd/Makefile (rpcuserlibs): New variable.
($(common-objpfx)libc.so): Move deps into that, use it.
[$(subdir) = elf] ($(objpfx)librtld.so): Depend on
$(rpcuserlibs:.so=_pic.a).
* elf/Makefile ($(objpfx)librtld.so): Just depend on libc_pic.a; don't
use $(LDLIBS-c.so).
Thu Jul 18 21:41:25 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/generic/stpncpy.c: Fix semantics to make `stpncpy (d, s,
n)' equivalent to `strncpy (d, s, n), d += strnlen (d, n)'.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/stpncpy.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/sysdeps/generic/stpncpy.c b/sysdeps/generic/stpncpy.c index 5cdd93d19e..427ed4b228 100644 --- a/sysdeps/generic/stpncpy.c +++ b/sysdeps/generic/stpncpy.c @@ -24,15 +24,13 @@ Cambridge, MA 02139, USA. */ /* Copy no more than N characters of SRC to DEST, returning the address of - the last character written into DEST. */ + the terminating '\0' in DEST, if any, or else DEST + N. */ char * DEFUN(__stpncpy, (dest, src, n), char *dest AND CONST char *src AND size_t n) { reg_char c; char *s = dest; - --dest; - if (n >= 4) { size_t n4 = n >> 2; @@ -40,27 +38,27 @@ DEFUN(__stpncpy, (dest, src, n), char *dest AND CONST char *src AND size_t n) for (;;) { c = *src++; - *++dest = c; + *dest++ = c; if (c == '\0') break; c = *src++; - *++dest = c; + *dest++ = c; if (c == '\0') break; c = *src++; - *++dest = c; + *dest++ = c; if (c == '\0') break; c = *src++; - *++dest = c; + *dest++ = c; if (c == '\0') break; if (--n4 == 0) goto last_chars; } - n = n - (dest - s) - 1; + n -= dest - s; if (n == 0) - return dest; + return dest - 1; goto zero_fill; } @@ -69,20 +67,22 @@ DEFUN(__stpncpy, (dest, src, n), char *dest AND CONST char *src AND size_t n) if (n == 0) return dest; - do + for (;;) { c = *src++; - *++dest = c; + *dest++ = c; + if (c == '\0') + break; if (--n == 0) return dest; } - while (c != '\0'); + --n; zero_fill: - while (n-- > 0) + while (--n > 0) dest[n] = '\0'; - return dest; + return dest - 1; } weak_alias (__stpncpy, stpncpy) |