mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Fix broken Luaj jar [#419]
This commit is contained in:
parent
cc8b9810a7
commit
623c7a129e
@ -17,33 +17,34 @@ package gplx.xowa.xtns.scribunto.libs.patterns; import gplx.*; import gplx.xowa.
|
||||
import gplx.core.intls.*;
|
||||
import gplx.langs.regxs.*;
|
||||
import org.luaj.vm2.lib.StringLib;
|
||||
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;
|
||||
//import org.luaj.vm2.lib.Str_find_mgr__regx;
|
||||
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) {
|
||||
// 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;
|
||||
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);
|
||||
mgr.Process();
|
||||
|
||||
// convert to Regx_match
|
||||
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());
|
||||
boolean found = find_bgn != -1;
|
||||
if (!found) {
|
||||
return Regx_match.Ary_empty;
|
||||
}
|
||||
int[] captures = mgr.Capture_ints();
|
||||
Regx_group[] groups = null;
|
||||
if (found && captures != null) {
|
||||
int captures_len = captures.length;
|
||||
groups = new Regx_group[captures_len / 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])));
|
||||
}
|
||||
}
|
||||
Regx_match rv = new Regx_match(found, find_bgn, find_end, groups);
|
||||
return new Regx_match[] {rv};
|
||||
// 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);
|
||||
// Str_find_mgr__regx mgr = new Str_find_mgr__regx(text_ucs.Src_string(), find_str, src_bgn, false, true);
|
||||
// mgr.Process();
|
||||
//
|
||||
// // convert to Regx_match
|
||||
// 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());
|
||||
// boolean found = find_bgn != -1;
|
||||
// if (!found) {
|
||||
// return Regx_match.Ary_empty;
|
||||
// }
|
||||
// int[] captures = mgr.Capture_ints();
|
||||
// Regx_group[] groups = null;
|
||||
// if (found && captures != null) {
|
||||
// int captures_len = captures.length;
|
||||
// groups = new Regx_group[captures_len / 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])));
|
||||
// }
|
||||
// }
|
||||
// Regx_match rv = new Regx_match(found, find_bgn, find_end, groups);
|
||||
// return new Regx_match[] {rv};
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user