diff options
author | obrien <obrien@FreeBSD.org> | 2002-10-03 19:39:20 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-10-03 19:39:20 +0000 |
commit | ae09b5969d9b0b71b7ea2ca9782aaffa85ad1935 (patch) | |
tree | dd6f27de20a59c8b3a0f1272e9928138faa9ce0f /lib/libc/string | |
parent | b8f13ad64366f383744def751f79e415c51f7513 (diff) | |
download | FreeBSD-src-ae09b5969d9b0b71b7ea2ca9782aaffa85ad1935.zip FreeBSD-src-ae09b5969d9b0b71b7ea2ca9782aaffa85ad1935.tar.gz |
Add stpcpy(3).
Diffstat (limited to 'lib/libc/string')
-rw-r--r-- | lib/libc/string/Makefile.inc | 5 | ||||
-rw-r--r-- | lib/libc/string/stpcpy.c | 46 | ||||
-rw-r--r-- | lib/libc/string/strcpy.3 | 20 | ||||
-rw-r--r-- | lib/libc/string/string.3 | 4 |
4 files changed, 73 insertions, 2 deletions
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc index c612a94..ce73ee1 100644 --- a/lib/libc/string/Makefile.inc +++ b/lib/libc/string/Makefile.inc @@ -7,8 +7,8 @@ CFLAGS+= -I${.CURDIR}/../libc/locale # machine-independent string sources MISRCS+=bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \ - memcpy.c memmove.c memset.c rindex.c strcasecmp.c strcat.c strchr.c \ - strcmp.c strcoll.c strcpy.c strcspn.c strdup.c strerror.c \ + memcpy.c memmove.c memset.c rindex.c stpcpy.c strcasecmp.c strcat.c \ + strchr.c strcmp.c strcoll.c strcpy.c strcspn.c strdup.c strerror.c \ strlcat.c strlcpy.c strlen.c strmode.c strncat.c strncmp.c strncpy.c \ strcasestr.c strnstr.c \ strpbrk.c strrchr.c strsep.c strsignal.c strspn.c strstr.c strtok.c \ @@ -34,6 +34,7 @@ MAN+= bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \ MLINKS+=strcasecmp.3 strncasecmp.3 MLINKS+=strcat.3 strncat.3 MLINKS+=strcmp.3 strncmp.3 +MLINKS+=strcpy.3 stpcpy.3 MLINKS+=strcpy.3 strncpy.3 MLINKS+=strerror.3 perror.3 strerror.3 sys_errlist.3 strerror.3 sys_nerr.3 MLINKS+=strerror.3 strerror_r.3 diff --git a/lib/libc/string/stpcpy.c b/lib/libc/string/stpcpy.c new file mode 100644 index 0000000..0bee746 --- /dev/null +++ b/lib/libc/string/stpcpy.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1999 + * David E. O'Brien + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <string.h> + +char * +stpcpy(char * to, const char * from) +{ + + for (; (*to = *from); ++from, ++to); + return(to); +} diff --git a/lib/libc/string/strcpy.3 b/lib/libc/string/strcpy.3 index 9f4410d..5343cdf 100644 --- a/lib/libc/string/strcpy.3 +++ b/lib/libc/string/strcpy.3 @@ -47,11 +47,14 @@ .Sh SYNOPSIS .In string.h .Ft char * +.Fn stpcpy "char *dst" "const char *src" +.Ft char * .Fn strcpy "char * restrict dst" "const char * restrict src" .Ft char * .Fn strncpy "char * restrict dst" "const char * restrict src" "size_t len" .Sh DESCRIPTION The +.Fn stpcpy , .Fn strcpy function copies the string @@ -89,6 +92,12 @@ and functions return .Fa dst . +The +.Fn stpcpy +function returns a pointer to the terminating +.Ql \e0 +character of +.Fa dst . .Sh EXAMPLES The following sets .Va chararray @@ -178,3 +187,14 @@ and functions conform to .St -isoC . +The +.Fn stpcpy +function is an MS-DOS and GNUism. +.Fn stpcpy +conforms to no standard. +.Sh HISTORY +The +.Fn stpcpy +function first appeared in +.Fx 4.4 , +comming from 1998-ventage Linux. diff --git a/lib/libc/string/string.3 b/lib/libc/string/string.3 index fb0d7db..dac9096 100644 --- a/lib/libc/string/string.3 +++ b/lib/libc/string/string.3 @@ -38,6 +38,7 @@ .Dt STRING 3 .Os .Sh NAME +.Nm stpcpy , .Nm strcat , .Nm strncat , .Nm strchr , @@ -64,6 +65,8 @@ .Sh SYNOPSIS .In string.h .Ft char * +.Fn stpcpy "char *dst" "const char *src" +.Ft char * .Fn strcat "char *s" "const char * append" .Ft char * .Fn strncat "char *s" "const char *append" "size_t count" @@ -120,6 +123,7 @@ for size limitations. .Xr bstring 3 , .Xr index 3 , .Xr rindex 3 , +.Xr stpcpy 3 , .Xr strcasecmp 3 , .Xr strcat 3 , .Xr strchr 3 , |