4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-03-02 04:55:35 +08:00

75 lines
1.3 KiB
C
Raw Permalink Normal View History

2000-02-17 19:39:52 +00:00
/*
FUNCTION
<<strcpy>>---copy string
INDEX
strcpy
SYNOPSIS
2000-02-17 19:39:52 +00:00
#include <string.h>
char *strcpy(char *<[dst]>, const char *<[src]>);
DESCRIPTION
<<strcpy>> copies the string pointed to by <[src]>
(including the terminating null character) to the array
pointed to by <[dst]>.
RETURNS
This function returns the initial value of <[dst]>.
PORTABILITY
<<strcpy>> is ANSI C.
<<strcpy>> requires no supporting OS subroutines.
QUICKREF
strcpy ansi pure
*/
#include <string.h>
#include <limits.h>
#include "local.h"
2000-02-17 19:39:52 +00:00
/*SUPPRESS 560*/
/*SUPPRESS 530*/
char*
strcpy (char *dst0,
const char *src0)
2000-02-17 19:39:52 +00:00
{
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
char *s = dst0;
while (*dst0++ = *src0++)
;
return s;
#else
char *dst = dst0;
const char *src = src0;
2000-02-17 19:39:52 +00:00
long *aligned_dst;
const long *aligned_src;
2000-02-17 19:39:52 +00:00
/* If SRC or DEST is unaligned, then copy bytes. */
if (!UNALIGNED_X_Y(src, dst))
2000-02-17 19:39:52 +00:00
{
aligned_dst = (long*)dst;
aligned_src = (long*)src;
/* SRC and DEST are both "long int" aligned, try to do "long int"
sized copies. */
while (!DETECT_NULL(*aligned_src))
2000-02-17 19:39:52 +00:00
{
*aligned_dst++ = *aligned_src++;
}
dst = (char*)aligned_dst;
src = (char*)aligned_src;
}
while ((*dst++ = *src++))
2000-02-17 19:39:52 +00:00
;
return dst0;
#endif /* not PREFER_SIZE_OVER_SPEED */
}