# HG changeset patch # User unc0rr # Date 1392234384 -14400 # Node ID 81d733899e06326cc3ef0f5fa326130f33f34d4e # Parent d73412fbf3b468b33238873d9d5bfe7f7b5f913e Use strchr instead of strstr with specially constructed string255 struct (not tested) diff -r d73412fbf3b4 -r 81d733899e06 project_files/hwc/rtl/system.c --- a/project_files/hwc/rtl/system.c Wed Feb 12 23:40:35 2014 +0400 +++ b/project_files/hwc/rtl/system.c Wed Feb 12 23:46:24 2014 +0400 @@ -143,11 +143,22 @@ } Integer __attribute__((overloadable)) fpcrtl_pos(Char c, string255 str) { - string255 t; - t.len = 1; - t.str[0] = c; - t.str[1] = 0; - return fpcrtl_pos(t, str); + + unsigned char* p; + + if (str.len == 0) { + return 0; + } + + FIX_STRING(str); + + p = strchr(str.str, c); + + if (p == NULL) { + return 0; + } + + return p - (unsigned char*)&str.s; } Integer __attribute__((overloadable)) fpcrtl_pos(string255 substr, string255 str) { @@ -175,11 +186,20 @@ } Integer __attribute__((overloadable)) fpcrtl_pos(Char c, astring str) { - string255 t; - t.len = 1; - t.str[0] = c; - t.str[1] = 0; - return fpcrtl_pos(t, str); + unsigned char* p; + + if (str.len == 0) { + return 0; + } + + p = strchr(str.s + 1, c); + + if (p == NULL) { + return 0; + } + + return p - (unsigned char*)&str.s; + } Integer __attribute__((overloadable)) fpcrtl_pos(string255 substr, astring str) {