PulkoMandy | 612e2cf | 2021-09-20 23:00:40 +0200 | [diff] [blame] | 1 | int strncmp(const char *_l, const char *_r, int n) |
| 2 | { |
| 3 | const unsigned char *l=(void *)_l, *r=(void *)_r; |
| 4 | if (!n--) return 0; |
| 5 | for (; *l && *r && n && *l == *r ; l++, r++, n--); |
| 6 | return *l - *r; |
| 7 | } |
| 8 | |
| 9 | int strlen(const char *s) |
| 10 | { |
| 11 | const char *a = s; |
| 12 | |
| 13 | for (; *s; s++); |
| 14 | return s-a; |
| 15 | } |
| 16 | |
| 17 | char *strcpy(char * d, const char * s) |
| 18 | { |
| 19 | for (; (*d=*s); s++, d++); |
| 20 | |
| 21 | return d; |
| 22 | } |
| 23 | |
| 24 | void *memset(void *dest, int c, int n) |
| 25 | { |
| 26 | unsigned char *s = dest; |
| 27 | for (; n; n--, s++) *s = c; |
| 28 | return dest; |
| 29 | } |
| 30 | |
| 31 | int isprint(int c) |
| 32 | { |
| 33 | return c > 32 && c < 256; |
| 34 | } |