diff --git a/libc/string/stpcpy.cpp b/libc/string/stpcpy.cpp index 27010e9c..3249c158 100644 --- a/libc/string/stpcpy.cpp +++ b/libc/string/stpcpy.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2014. This file is part of the Sortix C Library. @@ -26,8 +26,9 @@ extern "C" char* stpcpy(char* dest, const char* src) { - while ( *src ) - *dest++ = *src++; - *dest = '\0'; - return dest; + size_t index; + for ( index = 0; src[index]; index++ ) + dest[index] = src[index]; + dest[index] = '\0'; + return dest + index; } diff --git a/libc/wchar/wcpcpy.cpp b/libc/wchar/wcpcpy.cpp index e0e82373..efd81f03 100644 --- a/libc/wchar/wcpcpy.cpp +++ b/libc/wchar/wcpcpy.cpp @@ -26,8 +26,9 @@ extern "C" wchar_t* wcpcpy(wchar_t* restrict dest, const wchar_t* restrict src) { - while ( *src ) - *dest++ = *src++; - *dest = L'\0'; - return dest; + size_t index; + for ( index = 0; src[index]; index++ ) + dest[index] = src[index]; + dest[index] = L'\0'; + return dest + index; }