From e2709cd73f34fd6b4edc5c823e91c76fd8b418c4 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 5 Nov 2020 23:54:05 +0100 Subject: [PATCH] :art: Use strstr family --- src/lib/string.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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; -- 2.43.0