xref: /dflybsd-src/contrib/gdb-7/libiberty/stpcpy.c (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /* Implement the stpcpy function.
286d7f5d3SJohn Marino    Copyright (C) 2003 Free Software Foundation, Inc.
386d7f5d3SJohn Marino    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
486d7f5d3SJohn Marino 
586d7f5d3SJohn Marino This file is part of the libiberty library.
686d7f5d3SJohn Marino Libiberty is free software; you can redistribute it and/or
786d7f5d3SJohn Marino modify it under the terms of the GNU Library General Public
886d7f5d3SJohn Marino License as published by the Free Software Foundation; either
986d7f5d3SJohn Marino version 2 of the License, or (at your option) any later version.
1086d7f5d3SJohn Marino 
1186d7f5d3SJohn Marino Libiberty is distributed in the hope that it will be useful,
1286d7f5d3SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
1386d7f5d3SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1486d7f5d3SJohn Marino Library General Public License for more details.
1586d7f5d3SJohn Marino 
1686d7f5d3SJohn Marino You should have received a copy of the GNU Library General Public
1786d7f5d3SJohn Marino License along with libiberty; see the file COPYING.LIB.  If
1886d7f5d3SJohn Marino not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
1986d7f5d3SJohn Marino Boston, MA 02110-1301, USA.  */
2086d7f5d3SJohn Marino 
2186d7f5d3SJohn Marino /*
2286d7f5d3SJohn Marino 
2386d7f5d3SJohn Marino @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
2486d7f5d3SJohn Marino 
2586d7f5d3SJohn Marino Copies the string @var{src} into @var{dst}.  Returns a pointer to
2686d7f5d3SJohn Marino @var{dst} + strlen(@var{src}).
2786d7f5d3SJohn Marino 
2886d7f5d3SJohn Marino @end deftypefn
2986d7f5d3SJohn Marino 
3086d7f5d3SJohn Marino */
3186d7f5d3SJohn Marino 
3286d7f5d3SJohn Marino #include <ansidecl.h>
3386d7f5d3SJohn Marino #include <stddef.h>
3486d7f5d3SJohn Marino 
3586d7f5d3SJohn Marino extern size_t strlen (const char *);
3686d7f5d3SJohn Marino extern PTR memcpy (PTR, const PTR, size_t);
3786d7f5d3SJohn Marino 
3886d7f5d3SJohn Marino char *
stpcpy(char * dst,const char * src)3986d7f5d3SJohn Marino stpcpy (char *dst, const char *src)
4086d7f5d3SJohn Marino {
4186d7f5d3SJohn Marino   const size_t len = strlen (src);
4286d7f5d3SJohn Marino   return (char *) memcpy (dst, src, len + 1) + len;
4386d7f5d3SJohn Marino }
44