xref: /openbsd-src/gnu/lib/libiberty/src/stpcpy.c (revision 20fce977aadac3358da45d5027d7d19cdc03b0fe)
132d62142Sespie /* Implement the stpcpy function.
232d62142Sespie    Copyright (C) 2003 Free Software Foundation, Inc.
332d62142Sespie    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
432d62142Sespie 
532d62142Sespie This file is part of the libiberty library.
632d62142Sespie Libiberty is free software; you can redistribute it and/or
732d62142Sespie modify it under the terms of the GNU Library General Public
832d62142Sespie License as published by the Free Software Foundation; either
932d62142Sespie version 2 of the License, or (at your option) any later version.
1032d62142Sespie 
1132d62142Sespie Libiberty is distributed in the hope that it will be useful,
1232d62142Sespie but WITHOUT ANY WARRANTY; without even the implied warranty of
1332d62142Sespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1432d62142Sespie Library General Public License for more details.
1532d62142Sespie 
1632d62142Sespie You should have received a copy of the GNU Library General Public
1732d62142Sespie License along with libiberty; see the file COPYING.LIB.  If
18*20fce977Smiod not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19*20fce977Smiod Boston, MA 02110-1301, USA.  */
2032d62142Sespie 
2132d62142Sespie /*
2232d62142Sespie 
2332d62142Sespie @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
2432d62142Sespie 
2532d62142Sespie Copies the string @var{src} into @var{dst}.  Returns a pointer to
2632d62142Sespie @var{dst} + strlen(@var{src}).
2732d62142Sespie 
2832d62142Sespie @end deftypefn
2932d62142Sespie 
3032d62142Sespie */
3132d62142Sespie 
3232d62142Sespie #include <ansidecl.h>
3332d62142Sespie #include <stddef.h>
3432d62142Sespie 
35*20fce977Smiod extern size_t strlen (const char *);
36*20fce977Smiod extern PTR memcpy (PTR, const PTR, size_t);
3732d62142Sespie 
3832d62142Sespie char *
stpcpy(char * dst,const char * src)39*20fce977Smiod stpcpy (char *dst, const char *src)
4032d62142Sespie {
4132d62142Sespie   const size_t len = strlen (src);
4232d62142Sespie   return (char *) memcpy (dst, src, len + 1) + len;
4332d62142Sespie }
44