gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/string.c
1 /** Dumb strings hack.
2 */
3 #include <string.h>
4 #include <gbdk/gbdk-lib.h>
5
6 #if USE_C_STRCPY
7 char *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
17 void *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
31 int 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
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.