diff options
-rw-r--r-- | lib/LuaRegex.cc | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/LuaRegex.cc b/lib/LuaRegex.cc index 00c44ee..e785195 100644 --- a/lib/LuaRegex.cc +++ b/lib/LuaRegex.cc @@ -88,8 +88,8 @@ void LuaRegex::pushstatics(Lua * L) throw (GeneralException) { #define MAX_MATCHES 64 -int sLua_Regex::Regex_proceed(Lua * L, int n, Regex * r, int caller) { - int r = 0, i, n; +int sLua_Regex::Regex_proceed(Lua * L, int n, Regex * reg, int caller) { + int i, num; bool m; String s; regmatch_t pmatches[MAX_MATCHES]; @@ -97,29 +97,28 @@ int sLua_Regex::Regex_proceed(Lua * L, int n, Regex * r, int caller) { switch (caller) { case REGEX_MATCH: s = L->tostring(2); - L->push(m = r->Match(s, MAX_MATCHES, pmatches)); + L->push(m = reg->Match(s, MAX_MATCHES, pmatches)); if (!m) return 1; L->newtable(); - n = 1; + num = 1; for (i = 0; i < MAX_MATCHES; i++) { if (pmatches[i].rm_so == -1) continue; - L->push((lua_Number) n++); + L->push((lua_Number) num++); L->newtable(); L->push("start"); - L->push((lua_Number) patches.rm_so + 1); + L->push((lua_Number) pmatches[i].rm_so + 1); L->settable(); L->push("size"); - L->push((lua_Number) patches.rm_eo - patches.rm_so); + L->push((lua_Number) pmatches[i].rm_eo - pmatches[i].rm_so); L->settable(); L->settable(); } - r = 2; - break; + return 2; } - return r; + return 0; } int sLua_Regex::Regex_proceed_statics(Lua * L, int n, int caller) { |