diff options
Diffstat (limited to 'src/lib/libc/string/strncpy.c')
| -rw-r--r-- | src/lib/libc/string/strncpy.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/lib/libc/string/strncpy.c b/src/lib/libc/string/strncpy.c index 5215311b75..d73008c6db 100644 --- a/src/lib/libc/string/strncpy.c +++ b/src/lib/libc/string/strncpy.c | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | /* $OpenBSD: strncpy.c,v 1.5 2004/11/28 07:16:54 mickey Exp $ */ | ||
| 2 | |||
| 1 | /*- | 3 | /*- |
| 2 | * Copyright (c) 1990 The Regents of the University of California. | 4 | * Copyright (c) 1990 The Regents of the University of California. |
| 3 | * All rights reserved. | 5 | * All rights reserved. |
| @@ -13,11 +15,7 @@ | |||
| 13 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. All advertising materials mentioning features or use of this software | 18 | * 3. Neither the name of the University nor the names of its contributors |
| 17 | * must display the following acknowledgement: | ||
| 18 | * This product includes software developed by the University of | ||
| 19 | * California, Berkeley and its contributors. | ||
| 20 | * 4. Neither the name of the University nor the names of its contributors | ||
| 21 | * may be used to endorse or promote products derived from this software | 19 | * may be used to endorse or promote products derived from this software |
| 22 | * without specific prior written permission. | 20 | * without specific prior written permission. |
| 23 | * | 21 | * |
| @@ -35,25 +33,25 @@ | |||
| 35 | */ | 33 | */ |
| 36 | 34 | ||
| 37 | #if defined(LIBC_SCCS) && !defined(lint) | 35 | #if defined(LIBC_SCCS) && !defined(lint) |
| 38 | /*static char *sccsid = "from: @(#)strncpy.c 5.6 (Berkeley) 1/26/91";*/ | 36 | static char *rcsid = "$OpenBSD: strncpy.c,v 1.5 2004/11/28 07:16:54 mickey Exp $"; |
| 39 | static char *rcsid = "$Id: strncpy.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; | ||
| 40 | #endif /* LIBC_SCCS and not lint */ | 37 | #endif /* LIBC_SCCS and not lint */ |
| 41 | 38 | ||
| 39 | #if !defined(_KERNEL) && !defined(_STANDALONE) | ||
| 42 | #include <string.h> | 40 | #include <string.h> |
| 41 | #else | ||
| 42 | #include <lib/libkern/libkern.h> | ||
| 43 | #endif | ||
| 43 | 44 | ||
| 44 | /* | 45 | /* |
| 45 | * Copy src to dst, truncating or null-padding to always copy n bytes. | 46 | * Copy src to dst, truncating or null-padding to always copy n bytes. |
| 46 | * Return dst. | 47 | * Return dst. |
| 47 | */ | 48 | */ |
| 48 | char * | 49 | char * |
| 49 | strncpy(dst, src, n) | 50 | strncpy(char *dst, const char *src, size_t n) |
| 50 | char *dst; | ||
| 51 | const char *src; | ||
| 52 | register size_t n; | ||
| 53 | { | 51 | { |
| 54 | if (n != 0) { | 52 | if (n != 0) { |
| 55 | register char *d = dst; | 53 | char *d = dst; |
| 56 | register const char *s = src; | 54 | const char *s = src; |
| 57 | 55 | ||
| 58 | do { | 56 | do { |
| 59 | if ((*d++ = *s++) == 0) { | 57 | if ((*d++ = *s++) == 0) { |
