Add missing Wasm shims required by tree-sitter-ruby
This commit is contained in:
parent
d046c97c1f
commit
134a768172
5 changed files with 38 additions and 0 deletions
|
|
@ -1,5 +1,13 @@
|
|||
#include <string.h>
|
||||
|
||||
// Derived from musl (MIT): https://git.musl-libc.org/cgit/musl/tree/src/string/memchr.c
|
||||
void *memchr(const void *src, int c, size_t n) {
|
||||
const unsigned char *s = src;
|
||||
c = (unsigned char)c;
|
||||
for (; n && *s != c; s++, n--);
|
||||
return n ? (void *)s : 0;
|
||||
}
|
||||
|
||||
int memcmp(const void *lhs, const void *rhs, size_t count) {
|
||||
const unsigned char *l = lhs;
|
||||
const unsigned char *r = rhs;
|
||||
|
|
@ -58,3 +66,13 @@ int strncmp(const char *left, const char *right, size_t n) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *strchr(const char *str, int c) {
|
||||
while (*str != (char)c) {
|
||||
if (*str == '\0') {
|
||||
return 0;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
return (char *)str;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue