string.c (675B)
1/** Dumb strings hack. 2*/ 3#include <string.h> 4#include <gbdk/gbdk-lib.h> 5 6#if USE_C_STRCPY 7char *strcpy(char *dest, const char *source) NONBANKED 8{ 9 char *d = dest; 10 const char *s = source; 11 while (*d = *s) d++, s++; 12 return dest; 13} 14#endif 15 16#if USE_C_MEMCPY 17void *memcpy(void *dest, const void *source, size_t count) NONBANKED 18{ 19 char *d = dest; 20 const char *s = source; 21 while (count--) { 22 *d = *s; 23 d++; 24 s++; 25 } 26 return dest; 27} 28#endif 29 30#if USE_C_STRCMP 31int strcmp(const char *s1, const char *s2) { 32 char ret = 0; 33 while (!(ret = *s1 - *s2) && *s2) ++s1, ++s2; 34 return (ret < 0) ? -1 : ((ret > 0) ? 1 : 0); 35} 36#endif