Add stpcpy(3).
This commit is contained in:
parent
b8f13ad643
commit
ae09b5969d
@ -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
|
||||
|
46
lib/libc/string/stpcpy.c
Normal file
46
lib/libc/string/stpcpy.c
Normal file
@ -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);
|
||||
}
|
@ -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.
|
||||
|
@ -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 ,
|
||||
|
Loading…
Reference in New Issue
Block a user