[libc] Add stpcpy()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2024-05-23 13:18:16 +01:00
parent dc118c5369
commit e965f179e1
3 changed files with 34 additions and 2 deletions

View File

@@ -321,9 +321,9 @@ char * strstr ( const char *haystack, const char *needle ) {
*
* @v dest Destination string
* @v src Source string
* @ret dest Destination string
* @ret dnul Terminating NUL of destination string
*/
char * strcpy ( char *dest, const char *src ) {
char * stpcpy ( char *dest, const char *src ) {
const uint8_t *src_bytes = ( ( const uint8_t * ) src );
uint8_t *dest_bytes = ( ( uint8_t * ) dest );
@@ -333,6 +333,19 @@ char * strcpy ( char *dest, const char *src ) {
if ( ! *dest_bytes )
break;
}
return ( ( char * ) dest_bytes );
}
/**
* Copy string
*
* @v dest Destination string
* @v src Source string
* @ret dest Destination string
*/
char * strcpy ( char *dest, const char *src ) {
stpcpy ( dest, src );
return dest;
}