1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-29 23:10:52 +00:00

Fix broken Luaj jar [#419]

This commit is contained in:
gnosygnu 2019-04-03 00:19:01 -04:00
parent cc8b9810a7
commit 623c7a129e
2 changed files with 26 additions and 25 deletions

View File

@ -17,33 +17,34 @@ package gplx.xowa.xtns.scribunto.libs.patterns; import gplx.*; import gplx.xowa.
import gplx.core.intls.*; import gplx.core.intls.*;
import gplx.langs.regxs.*; import gplx.langs.regxs.*;
import org.luaj.vm2.lib.StringLib; import org.luaj.vm2.lib.StringLib;
import org.luaj.vm2.lib.Str_find_mgr; //import org.luaj.vm2.lib.Str_find_mgr;
import org.luaj.vm2.lib.Str_find_mgr__regx; //import org.luaj.vm2.lib.Str_find_mgr__regx;
class Scrib_pattern_matcher__luaj implements Scrib_pattern_matcher { class Scrib_pattern_matcher__luaj implements Scrib_pattern_matcher {
public Regx_match[] Match(Xoa_url url, Unicode_string text_ucs, Scrib_regx_converter regx_converter, String find_str, int bgn_as_codes) { public Regx_match[] Match(Xoa_url url, Unicode_string text_ucs, Scrib_regx_converter regx_converter, String find_str, int bgn_as_codes) {
// int src_bgn = bgn_as_codes < 0 ? bgn_as_codes : text_ucs.Pos_codes_to_bytes(bgn_as_codes); // int src_bgn = bgn_as_codes < 0 ? bgn_as_codes : text_ucs.Pos_codes_to_bytes(bgn_as_codes);
int src_bgn = bgn_as_codes < 0 ? Int_.Base1 : bgn_as_codes + Int_.Base1; // int src_bgn = bgn_as_codes < 0 ? Int_.Base1 : bgn_as_codes + Int_.Base1;
src_bgn = src_bgn >= text_ucs.Len_codes() ? text_ucs.Len_codes() : text_ucs.Pos_codes_to_bytes(src_bgn); // src_bgn = src_bgn >= text_ucs.Len_codes() ? text_ucs.Len_codes() : text_ucs.Pos_codes_to_bytes(src_bgn);
Str_find_mgr__regx mgr = new Str_find_mgr__regx(text_ucs.Src_string(), find_str, src_bgn, false, true); // Str_find_mgr__regx mgr = new Str_find_mgr__regx(text_ucs.Src_string(), find_str, src_bgn, false, true);
mgr.Process(); // mgr.Process();
//
// convert to Regx_match // // convert to Regx_match
int find_bgn = mgr.Bgn() == -1 ? -1 : text_ucs.Pos_bytes_to_chars(mgr.Bgn()); // int find_bgn = mgr.Bgn() == -1 ? -1 : text_ucs.Pos_bytes_to_chars(mgr.Bgn());
int find_end = mgr.End() == -1 ? -1 : text_ucs.Pos_bytes_to_chars(mgr.End()); // int find_end = mgr.End() == -1 ? -1 : text_ucs.Pos_bytes_to_chars(mgr.End());
boolean found = find_bgn != -1; // boolean found = find_bgn != -1;
if (!found) { // if (!found) {
return Regx_match.Ary_empty; // return Regx_match.Ary_empty;
} // }
int[] captures = mgr.Capture_ints(); // int[] captures = mgr.Capture_ints();
Regx_group[] groups = null; // Regx_group[] groups = null;
if (found && captures != null) { // if (found && captures != null) {
int captures_len = captures.length; // int captures_len = captures.length;
groups = new Regx_group[captures_len / 2]; // groups = new Regx_group[captures_len / 2];
for (int i = 0; i < captures_len; i += 2) { // for (int i = 0; i < captures_len; i += 2) {
groups[i / 2] = new Regx_group(true, captures[i], captures[i + 1], String_.Mid(text_ucs.Src_string(), text_ucs.Pos_bytes_to_chars(captures[i]), text_ucs.Pos_bytes_to_chars(captures[i + 1]))); // groups[i / 2] = new Regx_group(true, captures[i], captures[i + 1], String_.Mid(text_ucs.Src_string(), text_ucs.Pos_bytes_to_chars(captures[i]), text_ucs.Pos_bytes_to_chars(captures[i + 1])));
} // }
} // }
Regx_match rv = new Regx_match(found, find_bgn, find_end, groups); // Regx_match rv = new Regx_match(found, find_bgn, find_end, groups);
return new Regx_match[] {rv}; // return new Regx_match[] {rv};
return null;
} }
} }

Binary file not shown.