xref: /dflybsd-src/contrib/binutils-2.27/libiberty/stpcpy.c (revision e656dc90e3d65d744d534af2f5ea88cf8101ebcf)
1*a9fa9459Szrj /* Implement the stpcpy function.
2*a9fa9459Szrj    Copyright (C) 2003 Free Software Foundation, Inc.
3*a9fa9459Szrj    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
4*a9fa9459Szrj 
5*a9fa9459Szrj This file is part of the libiberty library.
6*a9fa9459Szrj Libiberty is free software; you can redistribute it and/or
7*a9fa9459Szrj modify it under the terms of the GNU Library General Public
8*a9fa9459Szrj License as published by the Free Software Foundation; either
9*a9fa9459Szrj version 2 of the License, or (at your option) any later version.
10*a9fa9459Szrj 
11*a9fa9459Szrj Libiberty is distributed in the hope that it will be useful,
12*a9fa9459Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of
13*a9fa9459Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*a9fa9459Szrj Library General Public License for more details.
15*a9fa9459Szrj 
16*a9fa9459Szrj You should have received a copy of the GNU Library General Public
17*a9fa9459Szrj License along with libiberty; see the file COPYING.LIB.  If
18*a9fa9459Szrj not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19*a9fa9459Szrj Boston, MA 02110-1301, USA.  */
20*a9fa9459Szrj 
21*a9fa9459Szrj /*
22*a9fa9459Szrj 
23*a9fa9459Szrj @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
24*a9fa9459Szrj 
25*a9fa9459Szrj Copies the string @var{src} into @var{dst}.  Returns a pointer to
26*a9fa9459Szrj @var{dst} + strlen(@var{src}).
27*a9fa9459Szrj 
28*a9fa9459Szrj @end deftypefn
29*a9fa9459Szrj 
30*a9fa9459Szrj */
31*a9fa9459Szrj 
32*a9fa9459Szrj #include <ansidecl.h>
33*a9fa9459Szrj #include <stddef.h>
34*a9fa9459Szrj 
35*a9fa9459Szrj extern size_t strlen (const char *);
36*a9fa9459Szrj extern PTR memcpy (PTR, const PTR, size_t);
37*a9fa9459Szrj 
38*a9fa9459Szrj char *
stpcpy(char * dst,const char * src)39*a9fa9459Szrj stpcpy (char *dst, const char *src)
40*a9fa9459Szrj {
41*a9fa9459Szrj   const size_t len = strlen (src);
42*a9fa9459Szrj   return (char *) memcpy (dst, src, len + 1) + len;
43*a9fa9459Szrj }
44