From: fennecdjay Date: Thu, 5 Nov 2020 22:54:05 +0000 (+0100) Subject: :art: Use strstr family X-Git-Tag: nightly~1201 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=e2709cd73f34fd6b4edc5c823e91c76fd8b418c4;p=gwion.git :art: Use strstr family --- diff --git a/src/lib/string.c b/src/lib/string.c index bcb6029b..7893c838 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -1,6 +1,5 @@ #include #include -#include #include #include "gwion_util.h" #include "gwion_ast.h" @@ -264,7 +263,7 @@ static MFUN(string_replaceN) { static MFUN(string_find) { const m_str base = STRING(o); char c = *(m_int*)MEM(SZ_INT); - char *str = index(base, c); + char *str = strchr(base, c); *(m_uint*)RETURN = str ? str - base : -1; } @@ -274,7 +273,7 @@ static MFUN(string_findStart) { const char pos = *(m_int*)MEM(SZ_INT *2); if(pos >= 0 && (size_t)pos < sz) { const char arg = *(m_int*)MEM(SZ_INT); - char *str = index(base + pos, arg); + char *str = strchr(base + pos, arg); *(m_uint*)RETURN = str ? str - pos - base : -1; } else *(m_uint*)RETURN = -1; @@ -310,7 +309,7 @@ static MFUN(string_findStrStart) { static MFUN(string_rfind) { const m_str base = STRING(o); char c = *(m_int*)MEM(SZ_INT); - char *str = rindex(base, c); + char *str = strrchr(base, c); *(m_uint*)RETURN = str ? str - base : -1; } @@ -320,7 +319,7 @@ static MFUN(string_rfindStart) { const char pos = *(m_int*)MEM(SZ_INT); if(pos >= 0 && (size_t)pos < sz) { const char arg = *(m_int*)MEM(SZ_INT * 2); - char *str = rindex(base + pos, arg); + char *str = strrchr(base + pos, arg); *(m_uint*)RETURN = str ? str - pos - base : -1; } else *(m_uint*)RETURN = -1;