1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.7.3.1'

This commit is contained in:
gnosygnu
2016-07-17 21:10:59 -04:00
parent b333db45f8
commit 7a851a41a5
290 changed files with 3048 additions and 2124 deletions

View File

@@ -43,15 +43,16 @@ public class Pfunc_iferror extends Pf_func_base {
byte state = State_null;
int pos = 0;
boolean valid = false;
Btrie_rv trv = new Btrie_rv();
while (true) {
if (pos == src_len) break;
byte b = src[pos];
Object o = trie.Match_bgn_w_byte(b, src, pos, src_len);
Object o = trie.Match_at_w_b0(trv, b, src, pos, src_len);
if (o == null)
++pos;
else {
Byte_obj_val bv = (Byte_obj_val)o;
int pos_nxt = trie.Match_pos();
int pos_nxt = trv.Pos();
if (pos_nxt == src_len) return false; // each of the three states requires at least one character afterwards
switch (bv.Val()) {
case State_close: // >: reset state
@@ -108,7 +109,7 @@ public class Pfunc_iferror extends Pf_func_base {
}
return false;
}
private static final Btrie_slim_mgr trie = trie_();
private static final Btrie_slim_mgr trie = trie_();
static final byte State_null = 0, State_nde = 1, State_class = 2, State_error = 3, State_close = 4;
private static Btrie_slim_mgr trie_() {
Btrie_slim_mgr rv = Btrie_slim_mgr.ci_a7(); // NOTE:ci.ascii:MW_const.en

View File

@@ -31,7 +31,6 @@ public class Pfunc_ifexist extends Pf_func_base {
bfr.Add(Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, args_len, 1));
}
public static boolean Exists(Xowe_wiki wiki, byte[] ttl_bry) {
synchronized (Mgr) {return Mgr.Exists(wiki, ttl_bry);}
return wiki.Parser_mgr().Ifexist_mgr().Exists(wiki, ttl_bry);
}
public static final Pfunc_ifexist_mgr Mgr = new Pfunc_ifexist_mgr();
}

View File

@@ -18,8 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.pfuncs.ifs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
import org.junit.*; import gplx.xowa.wikis.tdbs.metas.*;
public class Pfunc_ifexist_tst {
private final Xop_fxt fxt = new Xop_fxt();
@Before public void init() {fxt.Reset();}
private final Xop_fxt fxt = new Xop_fxt();
@Before public void init() {
fxt.Reset();
fxt.Wiki().Parser_mgr().Ifexist_mgr().Clear();
}
@Test public void Basic_pass() {fxt.Test_parse_tmpl_str_test("{{#ifexist: Abc | exists | doesn't exist }}" , "{{test}}" , "doesn't exist");}
@Test public void Empty() {fxt.Test_parse_tmpl_str_test("{{#ifexist:|y|n}}" , "{{test}}" , "n");} // NOTE: {{autolink}} can pass in ""
@Test public void Db_key() { // PURPOSE: test that (1) & is encoded; (2) " " becomes "_"; EX: {{#ifexist:File:Peter & Paul fortress in SPB 03.jpg|y|n}}
@@ -27,22 +30,18 @@ public class Pfunc_ifexist_tst {
fxt.Test_parse_tmpl_str_test("{{#ifexist:A & b|y|n}}", "{{test}}", "y");
}
@Test public void Media_n() {// DATE:2014-07-04
Pfunc_ifexist.Mgr.Clear();
fxt.Test_parse_tmpl_str_test("{{#ifexist:Media:A.png|y|n}}", "{{test}}", "n");
}
@Test public void Media_y_wiki() {// DATE:2014-07-04
Pfunc_ifexist.Mgr.Clear();
fxt.Init_page_create("File:A.png", "");
fxt.Test_parse_tmpl_str_test("{{#ifexist:Media:A.png|y|n}}", "{{test}}", "y");
}
@Test public void Media_y_commons() {// DATE:2014-07-04
Pfunc_ifexist.Mgr.Clear();
Xowe_wiki commons_wiki = fxt.App().Wiki_mgr().Get_by_or_make(gplx.xowa.wikis.domains.Xow_domain_itm_.Bry__commons);
fxt.Init_page_create(commons_wiki, "File:A.png", "");
fxt.Test_parse_tmpl_str_test("{{#ifexist:Media:A.png|y|n}}", "{{test}}", "y");
}
@Test public void Media_y_file_v1() {// DATE:2014-07-04
Pfunc_ifexist.Mgr.Clear();
Xof_meta_itm meta_itm = fxt.Wiki().File_mgr().Dbmeta_mgr().Get_itm_or_new(Bry_.new_a7("A.png"));
meta_itm.Orig_exists_(Bool_.Y_byte);
fxt.Test_parse_tmpl_str_test("{{#ifexist:Media:A.png|y|n}}", "{{test}}", "y");