diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/generic/stpncpy.c | 28 | ||||
-rw-r--r-- | sysdeps/mach/hurd/Makefile | 12 |
2 files changed, 24 insertions, 16 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) diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile index 8b70092f5f..26446951cc 100644 --- a/sysdeps/mach/hurd/Makefile +++ b/sysdeps/mach/hurd/Makefile @@ -104,11 +104,19 @@ endif # For the shared library, we don't need to do the linker script machination. # Instead, we specify the required libraries when building the shared object. -$(common-objpfx)libc.so: $(firstword $(objdir) $(..)mach)/libmachuser.so \ - $(firstword $(objdir) $(..)hurd)/libhurduser.so +rpcuserlibs := $(firstword $(objdir) $(..)mach)/libmachuser.so \ + $(firstword $(objdir) $(..)hurd)/libhurduser.so +$(common-objpfx)libc.so: $(rpcuserlibs) ifndef objpfx rpath-link += $(..)mach:$(..)hurd endif + +# The RPC stubs from these libraries are needed in building the dynamic +# linker, too. It must be self-contained, so we link the needed PIC +# objects directly into the shared object. +ifeq (elf,$(subdir)) +$(objpfx)librtld.so: $(rpcuserlibs:.so=_pic.a) +endif endif # in-Makerules |