xref: /netbsd-src/external/gpl3/gdb/dist/libiberty/stpcpy.c (revision 5173eb0a33e5d83890ba976253e703be4c92557c)
198b9484cSchristos /* Implement the stpcpy function.
2*5173eb0aSchristos    Copyright (C) 2003-2024 Free Software Foundation, Inc.
398b9484cSchristos    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
498b9484cSchristos 
598b9484cSchristos This file is part of the libiberty library.
698b9484cSchristos Libiberty is free software; you can redistribute it and/or
798b9484cSchristos modify it under the terms of the GNU Library General Public
898b9484cSchristos License as published by the Free Software Foundation; either
998b9484cSchristos version 2 of the License, or (at your option) any later version.
1098b9484cSchristos 
1198b9484cSchristos Libiberty is distributed in the hope that it will be useful,
1298b9484cSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of
1398b9484cSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1498b9484cSchristos Library General Public License for more details.
1598b9484cSchristos 
1698b9484cSchristos You should have received a copy of the GNU Library General Public
1798b9484cSchristos License along with libiberty; see the file COPYING.LIB.  If
1898b9484cSchristos not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
1998b9484cSchristos Boston, MA 02110-1301, USA.  */
2098b9484cSchristos 
2198b9484cSchristos /*
2298b9484cSchristos 
2398b9484cSchristos @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
2498b9484cSchristos 
2598b9484cSchristos Copies the string @var{src} into @var{dst}.  Returns a pointer to
2698b9484cSchristos @var{dst} + strlen(@var{src}).
2798b9484cSchristos 
2898b9484cSchristos @end deftypefn
2998b9484cSchristos 
3098b9484cSchristos */
3198b9484cSchristos 
3298b9484cSchristos #include <ansidecl.h>
3398b9484cSchristos #include <stddef.h>
3498b9484cSchristos 
3598b9484cSchristos extern size_t strlen (const char *);
364b169a6bSchristos extern void *memcpy (void *, const void *, size_t);
3798b9484cSchristos 
3898b9484cSchristos char *
3998b9484cSchristos stpcpy (char *dst, const char *src)
4098b9484cSchristos {
4198b9484cSchristos   const size_t len = strlen (src);
4298b9484cSchristos   return (char *) memcpy (dst, src, len + 1) + len;
4398b9484cSchristos }
44