stpcpy.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* stpcpy.c -- copy a string and return pointer to end of new string
  2. Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2020 Free Software
  3. Foundation, Inc.
  4. NOTE: The canonical source of this file is maintained with the GNU C Library.
  5. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
  6. This program is free software: you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation; either version 3 of the License, or any
  9. later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  16. #include <config.h>
  17. #include <string.h>
  18. #undef __stpcpy
  19. #ifdef _LIBC
  20. # undef stpcpy
  21. #endif
  22. #ifndef weak_alias
  23. # define __stpcpy stpcpy
  24. #endif
  25. /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
  26. char *
  27. __stpcpy (char *dest, const char *src)
  28. {
  29. register char *d = dest;
  30. register const char *s = src;
  31. do
  32. *d++ = *s;
  33. while (*s++ != '\0');
  34. return d - 1;
  35. }
  36. #ifdef weak_alias
  37. weak_alias (__stpcpy, stpcpy)
  38. #endif