mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.7.2.1
This commit is contained in:
@@ -22,7 +22,7 @@ class Pf_intl_language extends Pf_func_base {
|
||||
@Override public void Func_evaluate(Xop_ctx ctx, byte[] src, Xot_invk caller, Xot_invk self, Bry_bfr bfr) {
|
||||
byte[] argx = Eval_argx(ctx, src, caller, self);
|
||||
Hash_adp_bry regy = Xol_lang_itm_.Regy();
|
||||
if (argx.length == 0) return; // {{#language:}} should return ""; note that byte[0] will fail in MatchAtCurExact
|
||||
if (argx.length == 0) return; // {{#language:}} should return ""; note that byte[0] will fail in Match_exact
|
||||
Object o = regy.Get_by_bry(argx);
|
||||
if (o == null)
|
||||
bfr.Add(argx);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Pf_tag extends Pf_func_base {
|
||||
Bry_bfr tmp = app.Utl_bry_bfr_mkr().Get_b512();
|
||||
try {
|
||||
int tag_idx = ctx.Cur_page().Ref_mgr().Tag__next_id();
|
||||
Xop_xnde_tag tag = (Xop_xnde_tag)app.Xnde_tag_regy().XndeNames(ctx.Xnde_names_tid()).MatchAtCurExact(tag_name, 0, tag_name.length);
|
||||
Xop_xnde_tag tag = (Xop_xnde_tag)app.Xnde_tag_regy().XndeNames(ctx.Xnde_names_tid()).Match_exact(tag_name, 0, tag_name.length);
|
||||
boolean tag_is_ref = tag != null && tag.Id() == Xop_xnde_tag_.Tid_ref;
|
||||
if (tag_is_ref) // <ref>; add <xtag_bgn> to handle nested refs; PAGE:en.w:Battle_of_Midway; DATE:2014-06-27
|
||||
tmp.Add(Xtag_bgn_lhs).Add_int_pad_bgn(Byte_ascii.Num_0, 10, tag_idx).Add(Xtag_rhs);
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*;
|
||||
public class Pf_url_anchorencode extends Pf_func_base { // EX: {{anchorencode:a b}} -> a+b
|
||||
@Override public boolean Func_require_colon_arg() {return true;}
|
||||
@@ -97,7 +98,7 @@ public class Pf_url_anchorencode extends Pf_func_base { // EX: {{anchorencode:a
|
||||
Tkn(src, xnde.Subs_get(i), xnde, i, tmp_bfr);
|
||||
}
|
||||
}
|
||||
private static ByteTrieMgr_fast encode_trie = ByteTrieMgr_fast.cs_();
|
||||
private static Btrie_fast_mgr encode_trie = Btrie_fast_mgr.cs_();
|
||||
private static Xop_ctx anchor_ctx; static Xop_tkn_mkr anchor_tkn_mkr;
|
||||
private static Xop_parser anchor_parser;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
class Pf_url_ns extends Pf_func_base { // EX: {{ns:6}} -> File
|
||||
private boolean encode;
|
||||
public Pf_url_ns(boolean encode) {this.encode = encode; if (canonical == null) canonical_();}
|
||||
@Override public int Id() {return Xol_kwd_grp_.Id_url_ns;}
|
||||
@Override public Pf_func New(int id, byte[] name) {return new Pf_url_ns(encode).Name_(name);}
|
||||
@@ -43,15 +44,14 @@ class Pf_url_ns extends Pf_func_base { // EX: {{ns:6}} -> File
|
||||
bb.Add(encode ? itm.Name_enc() : itm.Name_txt());
|
||||
}
|
||||
}
|
||||
boolean encode;
|
||||
private static Hash_adp_bry canonical;
|
||||
private static void canonical_() {
|
||||
canonical = Hash_adp_bry.ci_ascii_(); // ASCII:canonical English names
|
||||
for (Xow_ns ns : Xow_ns_.Canonical)
|
||||
canonical_add(ns.Id(), ns.Name_bry());
|
||||
}
|
||||
private static void canonical_add(int ns_id, byte[] ns_name) {
|
||||
Xow_ns ns = new Xow_ns(ns_id, Xow_ns_case_.Id_all, ns_name, false);
|
||||
canonical.Add(ns_name, ns);
|
||||
}
|
||||
private static void canonical_() {
|
||||
canonical = Hash_adp_bry.ci_();
|
||||
for (Xow_ns ns : Xow_ns_.Canonical)
|
||||
canonical_add(ns.Id(), ns.Name_bry());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,18 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Pf_xtn_rel2abs extends Pf_func_base {
|
||||
@Override public boolean Func_require_colon_arg() {return true;}
|
||||
private static final byte[] Ary_dot_slash = Bry_.new_ascii_("./"), Ary_dot_dot = Bry_.new_ascii_(".."), Ary_dot_dot_slash = Bry_.new_ascii_("../");
|
||||
private static void qry_bgns_with_init() {
|
||||
qry_bgns_with = ByteTrieMgr_fast.cs_();
|
||||
qry_bgns_with = Btrie_fast_mgr.cs_();
|
||||
qry_bgns_with.Add(Byte_ascii.Slash, Int_obj_ref.new_(Id_slash));
|
||||
qry_bgns_with.Add(Byte_ascii.Dot, Int_obj_ref.new_(Id_dot));
|
||||
qry_bgns_with.Add(Ary_dot_slash, Int_obj_ref.new_(Id_dot_slash));
|
||||
qry_bgns_with.Add(Ary_dot_dot, Int_obj_ref.new_(Id_dot_dot));
|
||||
qry_bgns_with.Add(Ary_dot_dot_slash, Int_obj_ref.new_(Id_dot_dot_slash));
|
||||
} static ByteTrieMgr_fast qry_bgns_with;
|
||||
} static Btrie_fast_mgr qry_bgns_with;
|
||||
@Override public void Func_evaluate(Xop_ctx ctx, byte[] src, Xot_invk caller, Xot_invk self, Bry_bfr bb) {// REF.MW:ParserFunctions_body.php
|
||||
byte[] qry = Eval_argx(ctx, src, caller, self);
|
||||
byte[] orig = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, self.Args_len(), 0);
|
||||
@@ -66,7 +67,7 @@ public class Pf_xtn_rel2abs extends Pf_func_base {
|
||||
byte[] tmp = src;
|
||||
int tmp_adj = 0, i = 0, prv_slash_end = 0, tmp_len = src_len, seg_pos = 0;
|
||||
boolean tmp_is_1st = true;
|
||||
Object o = qry_bgns_with.MatchAtCur(qry, 0, qry_len); // check if qry begins with ".", "/", "./", "../"; if it doesn't return;
|
||||
Object o = qry_bgns_with.Match_bgn(qry, 0, qry_len); // check if qry begins with ".", "/", "./", "../"; if it doesn't return;
|
||||
if (o != null) {
|
||||
int id = ((Int_obj_ref)o).Val();
|
||||
rel2abs_tid.Val_(id);
|
||||
|
||||
Reference in New Issue
Block a user