From 8acf4cd1193b990fe70432b14224d4c1cfa356de Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Sat, 13 Apr 2024 15:19:04 +0200 Subject: [PATCH] Berry fix for Ubuntu (#21166) --- lib/libesp32/berry/src/be_strlib.c | 18 +++++++++--------- .../berry_mapping/src/be_class_wrapper.c | 3 +++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/libesp32/berry/src/be_strlib.c b/lib/libesp32/berry/src/be_strlib.c index 2da719da9330..6743c21e2e15 100644 --- a/lib/libesp32/berry/src/be_strlib.c +++ b/lib/libesp32/berry/src/be_strlib.c @@ -23,17 +23,17 @@ static int str_strncasecmp(const char *s1, const char *s2, size_t n) { - if (n == 0) return 0; + if (n == 0) return 0; - while (n-- != 0 && tolower(*s1) == tolower(*s2)) { - if (n == 0 || *s1 == '\0' || *s2 == '\0') - break; - s1++; - s2++; - } + while (n-- != 0 && tolower(*s1) == tolower(*s2)) { + if (n == 0 || *s1 == '\0' || *s2 == '\0') + break; + s1++; + s2++; + } - return tolower(*(const unsigned char *)s1) - - tolower(*(const unsigned char *)s2); + return tolower(*(const unsigned char *)s1) + - tolower(*(const unsigned char *)s2); } typedef bint (*str_opfunc)(const char*, const char*, bint, bint); diff --git a/lib/libesp32/berry_mapping/src/be_class_wrapper.c b/lib/libesp32/berry_mapping/src/be_class_wrapper.c index 5e3a02240874..1c567306be65 100644 --- a/lib/libesp32/berry_mapping/src/be_class_wrapper.c +++ b/lib/libesp32/berry_mapping/src/be_class_wrapper.c @@ -14,6 +14,9 @@ #include #include +/* Ubuntu 22.04 LTS seems to have an invalid or missing signature for strtok_r, forcing a correct one */ +extern char *strtok_r(char *str, const char *delim, char **saveptr); + typedef intptr_t (*fn_any_callable)(intptr_t p0, intptr_t p1, intptr_t p2, intptr_t p3, intptr_t p4, intptr_t p5, intptr_t p6, intptr_t p7);