7 /* Stringify a token */
9 #define _STRINGIFY(x) #x
10 #define STRINGIFY(x) _STRINGIFY(x)
13 void *memcpy(void *dest
, const void *src
, size_t n
);
14 void *memmove(void *dest
, const void *src
, size_t n
);
15 void *memset(void *s
, int c
, size_t n
);
16 int memcmp(const void *s1
, const void *s2
, size_t n
);
17 void *memchr(const void *s
, int c
, size_t n
);
18 #if !defined(__PRE_RAM__)
19 int snprintf(char * buf
, size_t size
, const char *fmt
, ...);
22 // simple string functions
24 static inline size_t strnlen(const char *src
, size_t max
)
27 while((*src
++) && (i
< max
)) {
33 static inline size_t strlen(const char *src
)
42 static inline char *strchr(const char *s
, int c
)
51 #if !defined(__PRE_RAM__)
52 static inline char *strdup(const char *s
)
54 size_t sz
= strlen(s
) + 1;
60 static inline char *strconcat(const char *s1
, const char *s2
)
62 size_t sz_1
= strlen(s1
);
63 size_t sz_2
= strlen(s2
);
64 char *d
= malloc(sz_1
+ sz_2
+ 1);
66 memcpy(d
+ sz_1
, s2
, sz_2
+ 1);
71 static inline char *strncpy(char *to
, const char *from
, int count
)
73 register char *ret
= to
;
77 if ((*to
++ = *from
++) == '\0')
88 static inline char *strcpy(char *dst
, const char *src
)
99 static inline int strcmp(const char *s1
, const char *s2
)
103 while ((r
= (*s1
- *s2
)) == 0 && *s1
) {
110 static inline int strncmp(const char *s1
, const char *s2
, int maxlen
)
114 for (i
= 0; i
< maxlen
; i
++) {
115 if ((s1
[i
] != s2
[i
]) || (s1
[i
] == '\0'))
116 return s1
[i
] - s2
[i
];
122 static inline int isspace(int c
)
125 case ' ': case '\f': case '\n':
126 case '\r': case '\t': case '\v':
133 static inline int isdigit(int c
)
135 return (c
>= '0' && c
<= '9');
138 static inline int isxdigit(int c
)
140 return ((c
>= '0' && c
<= '9') ||
141 (c
>= 'a' && c
<= 'f') ||
142 (c
>= 'A' && c
<= 'F'));
145 static inline int isupper(int c
)
147 return (c
>= 'A' && c
<= 'Z');
150 static inline int islower(int c
)
152 return (c
>= 'a' && c
<= 'z');
155 static inline int toupper(int c
)
162 static inline int tolower(int c
)
168 #endif /* STRING_H */