Blame gnulib/lib/stpcpy.c

Packit 06dd63
/* stpcpy.c -- copy a string and return pointer to end of new string
Packit 06dd63
   Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2019 Free Software
Packit 06dd63
   Foundation, Inc.
Packit 06dd63
Packit 06dd63
   NOTE: The canonical source of this file is maintained with the GNU C Library.
Packit 06dd63
   Bugs can be reported to bug-glibc@prep.ai.mit.edu.
Packit 06dd63
Packit 06dd63
   This program is free software: you can redistribute it and/or modify it
Packit 06dd63
   under the terms of the GNU Lesser General Public License as published by the
Packit 06dd63
   Free Software Foundation; either version 2.1 of the License, or any
Packit 06dd63
   later version.
Packit 06dd63
Packit 06dd63
   This program is distributed in the hope that it will be useful,
Packit 06dd63
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 06dd63
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 06dd63
   GNU Lesser General Public License for more details.
Packit 06dd63
Packit 06dd63
   You should have received a copy of the GNU Lesser General Public License
Packit 06dd63
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit 06dd63
Packit 06dd63
#include <config.h>
Packit 06dd63
Packit 06dd63
#include <string.h>
Packit 06dd63
Packit 06dd63
#undef __stpcpy
Packit 06dd63
#ifdef _LIBC
Packit 06dd63
# undef stpcpy
Packit 06dd63
#endif
Packit 06dd63
Packit 06dd63
#ifndef weak_alias
Packit 06dd63
# define __stpcpy stpcpy
Packit 06dd63
#endif
Packit 06dd63
Packit 06dd63
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST.  */
Packit 06dd63
char *
Packit 06dd63
__stpcpy (char *dest, const char *src)
Packit 06dd63
{
Packit 06dd63
  register char *d = dest;
Packit 06dd63
  register const char *s = src;
Packit 06dd63
Packit 06dd63
  do
Packit 06dd63
    *d++ = *s;
Packit 06dd63
  while (*s++ != '\0');
Packit 06dd63
Packit 06dd63
  return d - 1;
Packit 06dd63
}
Packit 06dd63
#ifdef weak_alias
Packit 06dd63
weak_alias (__stpcpy, stpcpy)
Packit 06dd63
#endif