mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.1.1
This commit is contained in:
@@ -142,17 +142,17 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
return invk.Args_get_by_key(src, Bry_.To_a7_bry(idx + 1, 1));
|
||||
}
|
||||
private static boolean Verify_arg_key(byte[] src, int idx, Arg_nde_tkn nde) {
|
||||
int key_int = Bry_.NotFound;
|
||||
int key_int = Bry_find_.Not_found;
|
||||
byte[] key_dat_ary = nde.Key_tkn().Dat_ary();
|
||||
if (Env_.Mode_testing() && src == null) // some tests will always pass a null src;
|
||||
key_int = Bry_.To_int_or(key_dat_ary, 0, key_dat_ary.length, Bry_.NotFound);
|
||||
key_int = Bry_.To_int_or(key_dat_ary, 0, key_dat_ary.length, Bry_find_.Not_found);
|
||||
else {
|
||||
if (Bry_.Len_eq_0(key_dat_ary)) // should be called by current context;
|
||||
key_int = Bry_.To_int_or(src, nde.Key_tkn().Src_bgn(), nde.Key_tkn().Src_end(), Bry_.NotFound);
|
||||
key_int = Bry_.To_int_or(src, nde.Key_tkn().Src_bgn(), nde.Key_tkn().Src_end(), Bry_find_.Not_found);
|
||||
else // will be called by parent context; note that this calls Xot_defn_tmpl_.Make_itm which sets a key_dat_ary; DATE:2013-09-23
|
||||
key_int = Bry_.To_int_or(key_dat_ary, 0, key_dat_ary.length, Bry_.NotFound);
|
||||
key_int = Bry_.To_int_or(key_dat_ary, 0, key_dat_ary.length, Bry_find_.Not_found);
|
||||
}
|
||||
if (key_int == Bry_.NotFound) // key is not-numeric
|
||||
if (key_int == Bry_find_.Not_found) // key is not-numeric
|
||||
return false;
|
||||
else // key is numeric
|
||||
return idx == key_int;
|
||||
@@ -286,7 +286,7 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
byte[] fnc_name = fnc_name_ref.Val();
|
||||
int fnc_name_len = fnc_name.length;
|
||||
int fnc_name_colon_pos = Bry_find_.Find_fwd(fnc_name, Byte_ascii.Colon, 0, fnc_name_len);
|
||||
if (fnc_name_colon_pos == Bry_.NotFound) {
|
||||
if (fnc_name_colon_pos == Bry_find_.Not_found) {
|
||||
KeyVal arg_argx = (KeyVal)rv.Get_at(0);
|
||||
argx_ref.Val_(arg_argx.Val_to_bry());
|
||||
rv.Del_at(0);
|
||||
|
||||
@@ -119,11 +119,11 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
String anchor_str = args.Cast_str_or_null(2);
|
||||
String xwiki_str = args.Cast_str_or_null(3);
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_k004();
|
||||
if (xwiki_str != null) tmp_bfr.Add_str(xwiki_str).Add_byte(Byte_ascii.Colon);
|
||||
if (xwiki_str != null) tmp_bfr.Add_str_u8(xwiki_str).Add_byte(Byte_ascii.Colon);
|
||||
if (Bry_.Len_gt_0(ns_bry)) // only prefix ns if available; EX:"Template:Title"; else will get ":Title"; DATE:2014-10-30
|
||||
tmp_bfr.Add(ns_bry).Add_byte(Byte_ascii.Colon);
|
||||
tmp_bfr.Add_str(ttl_str);
|
||||
if (anchor_str != null) tmp_bfr.Add_byte(Byte_ascii.Hash).Add_str(anchor_str);
|
||||
tmp_bfr.Add_str_u8(ttl_str);
|
||||
if (anchor_str != null) tmp_bfr.Add_byte(Byte_ascii.Hash).Add_str_u8(anchor_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, tmp_bfr.To_bry_and_rls());
|
||||
if (ttl == null) return rslt.Init_obj(null); // invalid title; exit;
|
||||
return rslt.Init_obj(GetInexpensiveTitleData(ttl));
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Scrib_lib_ustring implements Scrib_lib {
|
||||
return rslt.Init_many_objs(bgn_codepoint_idx + Scrib_lib_ustring.Base1, bgn_codepoint_idx + Scrib_lib_ustring.Base1 - 1);
|
||||
if (plain) {
|
||||
int pos = String_.FindFwd(text_str, regx, bgn_codepoint_idx);
|
||||
boolean found = pos != Bry_.NotFound;
|
||||
boolean found = pos != Bry_find_.Not_found;
|
||||
return found
|
||||
? rslt.Init_many_objs(pos + Scrib_lib_ustring.Base1, pos + Scrib_lib_ustring.Base1 + String_.Len(regx) - Scrib_lib_ustring.End_adj)
|
||||
: rslt.Init_ary_empty()
|
||||
@@ -224,14 +224,14 @@ class Scrib_lib_ustring_gsub_mgr {
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (limit > -1 && repl_count == limit) break;
|
||||
Regx_match rslt = rslts[i];
|
||||
tmp_bfr.Add_str(String_.Mid(text, pos, rslt.Find_bgn())); // NOTE: regx returns char pos (not bry); must add as String, not bry; DATE:2013-07-17
|
||||
tmp_bfr.Add_str_u8(String_.Mid(text, pos, rslt.Find_bgn())); // NOTE: regx returns char pos (not bry); must add as String, not bry; DATE:2013-07-17
|
||||
Exec_repl_itm(tmp_bfr, repl_tid, repl_bry, text, rslt);
|
||||
pos = rslt.Find_end();
|
||||
++repl_count;
|
||||
}
|
||||
int text_len = String_.Len(text);
|
||||
if (pos < text_len)
|
||||
tmp_bfr.Add_str(String_.Mid(text, pos, text_len)); // NOTE: regx returns char pos (not bry); must add as String, not bry; DATE:2013-07-17
|
||||
tmp_bfr.Add_str_u8(String_.Mid(text, pos, text_len)); // NOTE: regx returns char pos (not bry); must add as String, not bry; DATE:2013-07-17
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
}
|
||||
private void Exec_repl_itm(Bry_bfr tmp_bfr, byte repl_tid, byte[] repl_bry, String text, Regx_match match) {
|
||||
@@ -257,7 +257,7 @@ class Scrib_lib_ustring_gsub_mgr {
|
||||
idx -= List_adp_.Base1;
|
||||
if (idx < match.Groups().length) { // retrieve numbered capture; TODO: support more than 9 captures
|
||||
Regx_group grp = match.Groups()[idx];
|
||||
tmp_bfr.Add_str(String_.Mid(text, grp.Bgn(), grp.End())); // NOTE: grp.Bgn() / .End() is for String pos (bry pos will fail for utf8 strings)
|
||||
tmp_bfr.Add_str_u8(String_.Mid(text, grp.Bgn(), grp.End())); // NOTE: grp.Bgn() / .End() is for String pos (bry pos will fail for utf8 strings)
|
||||
}
|
||||
else {
|
||||
tmp_bfr.Add_byte(Byte_ascii.Percent);
|
||||
@@ -297,7 +297,7 @@ class Scrib_lib_ustring_gsub_mgr {
|
||||
String find_str = String_.Mid(text, match_bgn, match_end); // NOTE: rslt.Bgn() / .End() is for String pos (bry pos will fail for utf8 strings)
|
||||
Object actl_repl_obj = repl_hash.Get_by(find_str);
|
||||
if (actl_repl_obj == null) // match found, but no replacement specified; EX:"abc", "[ab]", "a:A"; "b" in regex but not in tbl; EX:d:DVD; DATE:2014-03-31
|
||||
tmp_bfr.Add_str(find_str);
|
||||
tmp_bfr.Add_str_u8(find_str);
|
||||
else
|
||||
tmp_bfr.Add((byte[])actl_repl_obj);
|
||||
break;
|
||||
@@ -319,7 +319,7 @@ class Scrib_lib_ustring_gsub_mgr {
|
||||
}
|
||||
}
|
||||
KeyVal[] rslts = core.Interpreter().CallFunction(repl_func.Id(), luacbk_args);
|
||||
tmp_bfr.Add_str(Scrib_kv_utl_.Val_to_str(rslts, 0));
|
||||
tmp_bfr.Add_str_u8(Scrib_kv_utl_.Val_to_str(rslts, 0));
|
||||
break;
|
||||
}
|
||||
default: throw Err_.new_unhandled(repl_tid);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Scrib_lib_wikibase implements Scrib_lib {
|
||||
}
|
||||
public boolean ResolvePropertyId(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] prop = args.Pull_bry(0); if (Bry_.Len_eq_0(prop)) return rslt.Init_ary_empty();
|
||||
Wdata_doc wdoc = Get_wdoc(Bry_.Add(Byte_ascii.Ltr_p, prop)); if (wdoc == null) return rslt.Init_ary_empty();
|
||||
Wdata_doc wdoc = Get_wdoc(prop); if (wdoc == null) return rslt.Init_ary_empty(); // prop should be of form "P123"; do not add "P"; PAGE:no.w:Anne_Enger; DATE:2015-10-27
|
||||
return rslt.Init_obj(wdoc.Label_list__get_or_fallback(core.Lang()));
|
||||
}
|
||||
public boolean GetSiteLinkPageName(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
|
||||
@@ -406,12 +406,12 @@ class Scrib_lib_wikibase_srl_fxt {
|
||||
}
|
||||
private void Xto_str(Bry_bfr bfr, KeyVal kv, int depth) {
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, depth * 2);
|
||||
bfr.Add_str(kv.Key()).Add_byte(Byte_ascii.Colon);
|
||||
bfr.Add_str_u8(kv.Key()).Add_byte(Byte_ascii.Colon);
|
||||
Object kv_val = kv.Val();
|
||||
if (kv_val == null) {bfr.Add_str_a7("null").Add_byte_nl(); return;}
|
||||
Class<?> kv_val_cls = kv_val.getClass();
|
||||
if (Type_adp_.Eq(kv_val_cls, KeyVal[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (KeyVal[])kv_val, depth + 1);}
|
||||
else if (Type_adp_.Eq(kv_val_cls, KeyVal[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (KeyVal)kv_val, depth + 1);}
|
||||
else bfr.Add_byte(Byte_ascii.Apos).Add_str(Object_.Xto_str_strict_or_empty(kv_val)).Add_byte(Byte_ascii.Apos).Add_byte_nl();
|
||||
else bfr.Add_byte(Byte_ascii.Apos).Add_str_u8(Object_.Xto_str_strict_or_empty(kv_val)).Add_byte(Byte_ascii.Apos).Add_byte_nl();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,6 @@ public class Scrib_lib_wikibase_tst {
|
||||
}
|
||||
@Test public void ResolvePropertyId() {
|
||||
wdata_fxt.Init_pages_add(wdata_fxt.Wdoc_bldr("Property:p2").Add_label("zh-hans", "prop_a").Xto_wdoc());
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase.Invk_resolvePropertyId, Object_.Ary("2"), "prop_a");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase.Invk_resolvePropertyId, Object_.Ary("p2"), "prop_a");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user