/tags/sdcc-221-pre1/sdcc/device/lib/z80/string.c
C | 34 lines | 26 code | 5 blank | 3 comment | 7 complexity | 349e55b3cfc0e9b6838871d71b8664ea MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, LGPL-2.1, GPL-3.0
- /* Dumb strings stub.
- Wanted a quick hack for now - will use the libc version later.
- */
- char *strcpy(char *dest, const char *source)
- {
- char *d = dest;
- const char *s = source;
- while (*d++ = *s++);
- return dest;
- }
- void *memcpy(void *dest, const void *source, int count)
- {
- char *d = dest;
- const char *s = source;
- while (count--)
- *d++ = *s++;
- return dest;
- }
- int strcmp(const char *s1, const char *s2)
- {
- char ret = 0;
- while (!(ret = *s1 - *s2) && *s2)
- ++s1, ++s2;
- if (ret < 0)
- return -1;
- else if (ret > 0)
- return 1;
- return 0;
- }