1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Xomw: Change Php classes to Xophp; move to root namespace

This commit is contained in:
gnosygnu 2017-02-24 07:56:49 -05:00
parent a8c7f27ff5
commit d8c2eaba1d
42 changed files with 408 additions and 864 deletions

View File

@ -33,8 +33,8 @@ public class Swt_app_main {
public static void main(String[] args) { public static void main(String[] args) {
// Drag_drop(); // Drag_drop();
// List_fonts(); // List_fonts();
keystrokes(args); // keystrokes(args);
// Permission_denied(); Permission_denied();
// Combo_default(); // Combo_default();
// Combo_composite(); // Combo_composite();
} }

View File

@ -44,14 +44,21 @@ public class Http_download_wkr__jre extends Http_download_wkr__base {
HttpURLConnection src_conn = null; HttpURLConnection src_conn = null;
try { try {
// open connection // open connection
Gfo_usr_dlg_.Instance.Warn_many("", "", "a1");
src_conn = (HttpURLConnection)src_url_itm.openConnection(); src_conn = (HttpURLConnection)src_url_itm.openConnection();
Gfo_usr_dlg_.Instance.Warn_many("", "", "a2");
if (prog_resumed) if (prog_resumed)
src_conn.addRequestProperty("Range", "bytes=" + Long_.To_str(prog_data_cur) + "-"); src_conn.addRequestProperty("Range", "bytes=" + Long_.To_str(prog_data_cur) + "-");
Gfo_usr_dlg_.Instance.Warn_many("", "", "a3");
src_conn.setReadTimeout(10000); // explicitly set timeout; NOTE:needed on Mac OS X, else error never thrown; DATE:2016-09-03 src_conn.setReadTimeout(10000); // explicitly set timeout; NOTE:needed on Mac OS X, else error never thrown; DATE:2016-09-03
Gfo_usr_dlg_.Instance.Warn_many("", "", "a4");
src_conn.connect(); src_conn.connect();
Gfo_usr_dlg_.Instance.Warn_many("", "", "a5");
// check response code // check response code
Gfo_usr_dlg_.Instance.Warn_many("", "", "a6");
int response_code = src_conn.getResponseCode(); int response_code = src_conn.getResponseCode();
Gfo_usr_dlg_.Instance.Warn_many("", "", "a7");
if (prog_resumed) { if (prog_resumed) {
if (response_code != HttpURLConnection.HTTP_PARTIAL) { if (response_code != HttpURLConnection.HTTP_PARTIAL) {
try {if (trg_stream != null) trg_stream.close();} try {if (trg_stream != null) trg_stream.close();}

View File

@ -1,213 +0,0 @@
100_core/src/gplx/Array_.java | 20 +-
100_core/src/gplx/Array__tst.java | 20 +-
100_core/src/gplx/Bool_.java | 20 +-
100_core/src/gplx/Bool__tst.java | 20 +-
100_core/src/gplx/Bry_.java | 20 +-
100_core/src/gplx/Bry__tst.java | 20 +-
100_core/src/gplx/Bry_bfr.java | 20 +-
100_core/src/gplx/Bry_bfr_.java | 20 +-
100_core/src/gplx/Bry_bfr_tst.java | 20 +-
100_core/src/gplx/Bry_find_.java | 20 +-
100_core/src/gplx/Bry_find__tst.java | 20 +-
100_core/src/gplx/Bry_fmt.java | 20 +-
100_core/src/gplx/Bry_split_.java | 20 +-
100_core/src/gplx/Bry_split__tst.java | 20 +-
100_core/src/gplx/Byte_.java | 20 +-
100_core/src/gplx/Byte__tst.java | 20 +-
100_core/src/gplx/Byte_ascii.java | 20 +-
100_core/src/gplx/Cancelable.java | 20 +-
100_core/src/gplx/Cancelable_.java | 20 +-
100_core/src/gplx/Char_.java | 20 +-
100_core/src/gplx/CompareAble.java | 20 +-
100_core/src/gplx/CompareAble_.java | 20 +-
100_core/src/gplx/DateAdp.java | 20 +-
100_core/src/gplx/DateAdp_.java | 20 +-
100_core/src/gplx/DateAdp__tst.java | 20 +-
100_core/src/gplx/Datetime_now.java | 20 +-
100_core/src/gplx/Decimal_adp.java | 20 +-
100_core/src/gplx/Decimal_adp_.java | 20 +-
100_core/src/gplx/Decimal_adp__tst.java | 20 +-
100_core/src/gplx/Double_.java | 20 +-
100_core/src/gplx/Double__tst.java | 20 +-
100_core/src/gplx/Enm_.java | 20 +-
100_core/src/gplx/Err.java | 20 +-
100_core/src/gplx/Err_.java | 20 +-
100_core/src/gplx/Err_tst.java | 20 +-
100_core/src/gplx/Float_.java | 20 +-
100_core/src/gplx/GfoMsg.java | 20 +-
100_core/src/gplx/GfoMsgUtl.java | 20 +-
100_core/src/gplx/GfoMsg_.java | 20 +-
100_core/src/gplx/GfoMsg_tst.java | 20 +-
100_core/src/gplx/GfoTemplate.java | 20 +-
100_core/src/gplx/GfoTemplateFactory.java | 20 +-
100_core/src/gplx/Gfo_evt_itm.java | 20 +-
100_core/src/gplx/Gfo_evt_mgr.java | 20 +-
100_core/src/gplx/Gfo_evt_mgr_.java | 20 +-
100_core/src/gplx/Gfo_evt_mgr_owner.java | 20 +-
100_core/src/gplx/Gfo_evt_mgr_tst.java | 20 +-
100_core/src/gplx/Gfo_invk.java | 20 +-
100_core/src/gplx/Gfo_invk_.java | 20 +-
100_core/src/gplx/Gfo_invk_cmd.java | 20 +-
100_core/src/gplx/Gfo_invk_cmd_mgr.java | 20 +-
100_core/src/gplx/Gfo_invk_cmd_mgr_owner.java | 20 +-
100_core/src/gplx/Gfo_invk_root_wkr.java | 20 +-
100_core/src/gplx/Gfo_invk_to_str.java | 20 +-
100_core/src/gplx/Gfo_log.java | 20 +-
100_core/src/gplx/Gfo_log_.java | 20 +-
100_core/src/gplx/Gfo_log_bfr.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg_.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__gui.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__gui_.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__gui_test.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__log.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__log_.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__log_base.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg_base.java | 20 +-
100_core/src/gplx/GfsCtx.java | 20 +-
100_core/src/gplx/Guid_adp.java | 20 +-
100_core/src/gplx/Guid_adp_.java | 20 +-
100_core/src/gplx/Guid_adp__tst.java | 20 +-
100_core/src/gplx/Hash_adp.java | 20 +-
100_core/src/gplx/Hash_adp_.java | 20 +-
100_core/src/gplx/Hash_adp_bry.java | 20 +-
100_core/src/gplx/Hash_adp_bry_tst.java | 20 +-
100_core/src/gplx/Int_.java | 20 +-
100_core/src/gplx/Int__tst.java | 20 +-
100_core/src/gplx/Internal.java | 20 +-
100_core/src/gplx/Io_mgr.java | 20 +-
100_core/src/gplx/Io_mgr__tst.java | 20 +-
100_core/src/gplx/Io_url.java | 20 +-
100_core/src/gplx/Io_url_.java | 20 +-
100_core/src/gplx/Io_url__tst.java | 20 +-
100_core/src/gplx/Keyval.java | 20 +-
100_core/src/gplx/Keyval_.java | 20 +-
100_core/src/gplx/Keyval_hash.java | 20 +-
100_core/src/gplx/Keyval_list.java | 20 +-
100_core/src/gplx/List_adp.java | 20 +-
100_core/src/gplx/List_adp_.java | 20 +-
100_core/src/gplx/List_adp_base.java | 20 +-
100_core/src/gplx/List_adp_tst.java | 20 +-
100_core/src/gplx/Long_.java | 20 +-
100_core/src/gplx/Long__tst.java | 20 +-
100_core/src/gplx/Math_.java | 20 +-
100_core/src/gplx/Math__tst.java | 20 +-
100_core/src/gplx/New.java | 20 +-
100_core/src/gplx/ObjAry.java | 20 +-
100_core/src/gplx/Object_.java | 20 +-
100_core/src/gplx/Object__tst.java | 20 +-
100_core/src/gplx/Ordered_hash.java | 20 +-
100_core/src/gplx/Ordered_hash_.java | 20 +-
100_core/src/gplx/Ordered_hash_base.java | 20 +-
100_core/src/gplx/Ordered_hash_tst.java | 20 +-
100_core/src/gplx/RandomAdp.java | 20 +-
100_core/src/gplx/RandomAdp_.java | 20 +-
100_core/src/gplx/Rls_able.java | 20 +-
100_core/src/gplx/Rls_able_.java | 20 +-
100_core/src/gplx/Short_.java | 20 +-
100_core/src/gplx/String_.java | 20 +-
100_core/src/gplx/String__tst.java | 20 +-
100_core/src/gplx/Tfds.java | 20 +-
100_core/src/gplx/TfdsTstr_fxt.java | 20 +-
100_core/src/gplx/Time_span.java | 20 +-
100_core/src/gplx/Time_span_.java | 20 +-
100_core/src/gplx/To_str_able.java | 20 +-
100_core/src/gplx/To_str_able_.java | 20 +-
100_core/src/gplx/Type_adp_.java | 20 +-
100_core/src/gplx/UsrDlg.java | 20 +-
100_core/src/gplx/UsrDlg_.java | 20 +-
100_core/src/gplx/UsrMsg.java | 20 +-
100_core/src/gplx/UsrMsgWkr.java | 20 +-
100_core/src/gplx/UsrMsgWkr_.java | 20 +-
100_core/src/gplx/UsrMsgWkr_console.java | 20 +-
100_core/src/gplx/UsrMsgWkr_test.java | 20 +-
100_core/src/gplx/Virtual.java | 20 +-
100_core/src/gplx/Yn.java | 20 +-
100_core/src/gplx/core/bits/Bitmask_.java | 20 +-
100_core/src/gplx/core/brys/Bfr_arg.java | 20 +-
100_core/src/gplx/core/brys/Bfr_arg_.java | 20 +-
100_core/src/gplx/core/brys/Bfr_arg_clearable.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_able.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_able_.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_mkr.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_mkr_mgr.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_mkr_tst.java | 20 +-
100_core/src/gplx/core/brys/Bry_err_wkr.java | 20 +-
100_core/src/gplx/core/brys/Bry_rdr.java | 20 +-
100_core/src/gplx/core/brys/Bry_rdr_old.java | 20 +-
100_core/src/gplx/core/brys/Bry_rdr_tst.java | 20 +-
100_core/src/gplx/core/brys/Bry_split_wkr.java | 20 +-
100_core/src/gplx/core/brys/args/Bfr_arg__bry.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__bry_ary.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__bry_fmt.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__bry_fmtr.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__byte.java | 20 +-
.../gplx/core/brys/args/Bfr_arg__decimal_int.java | 20 +-
100_core/src/gplx/core/brys/args/Bfr_arg__int.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__time.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__time_tst.java | 20 +-
100_core/src/gplx/core/brys/fmtrs/Bry_fmtr.java | 20 +-
.../gplx/core/brys/fmtrs/Bry_fmtr_eval_mgr.java | 20 +-
.../gplx/core/brys/fmtrs/Bry_fmtr_eval_mgr_.java | 20 +-
.../core/brys/fmtrs/Bry_fmtr_eval_mgr_gfs.java | 20 +-
.../src/gplx/core/brys/fmtrs/Bry_fmtr_itm.java | 20 +-
.../src/gplx/core/brys/fmtrs/Bry_fmtr_tst.java | 20 +-
.../src/gplx/core/brys/fmtrs/Bry_fmtr_vals.java | 20 +-
100_core/src/gplx/core/brys/fmts/Bfr_fmt_arg.java | 20 +-
100_core/src/gplx/core/brys/fmts/Bry_fmt_itm.java | 20 +-
.../src/gplx/core/brys/fmts/Bry_fmt_parser_.java | 20 +-
100_core/src/gplx/core/brys/fmts/Bry_fmt_tst.java | 20 +-
.../gplx/core/brys/fmts/Bry_keys_parser_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_bwd_mgr.java | 20 +-
.../src/gplx/core/btries/Btrie_bwd_mgr_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_fast_mgr.java | 20 +-
.../src/gplx/core/btries/Btrie_fast_mgr_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_itm_stub.java | 20 +-
100_core/src/gplx/core/btries/Btrie_mgr.java | 20 +-
100_core/src/gplx/core/btries/Btrie_rv.java | 20 +-
100_core/src/gplx/core/btries/Btrie_slim_itm.java | 20 +-
.../src/gplx/core/btries/Btrie_slim_itm_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_slim_mgr.java | 20 +-
.../src/gplx/core/btries/Btrie_slim_mgr_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_u8_itm.java | 20 +-
100_core/src/gplx/core/btries/Btrie_u8_mgr.java | 20 +-
100_core/src/gplx/core/consoles/Console_adp.java | 20 +-
100_core/src/gplx/core/consoles/Console_adp_.java | 20 +-
.../src/gplx/core/consoles/Console_adp__mem.java | 20 +-
.../src/gplx/core/consoles/Console_adp__sys.java | 20 +-
100_core/src/gplx/core/criterias/Criteria.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_.java | 20 +-
.../src/gplx/core/criterias/Criteria_between.java | 20 +-
.../gplx/core/criterias/Criteria_bool_base.java | 20 +-
.../src/gplx/core/criterias/Criteria_comp.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_eq.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_fld.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_in.java | 20 +-
.../gplx/core/criterias/Criteria_ioItm_tst.java | 20 +-
.../src/gplx/core/criterias/Criteria_ioMatch.java | 20 +-
.../src/gplx/core/criterias/Criteria_like.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_not.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_tst.java | 20 +-
100_core/src/gplx/core/encoders/B85_fp_.java | 20 +-
100_core/src/gplx/core/encoders/B85_fp__tst.java | 20 +-
100_core/src/gplx/core/encoders/Base85_.java | 20 +-
100_core/src/gplx/core/encoders/Base85__tst.java | 20 +-
100_core/src/gplx/core/encoders/Gfo_hzip_int_.java | 20 +-
100_core/src/gplx/core/encoders/Hex_utl_.java | 20 +-
100_core/src/gplx/core/encoders/Hex_utl__tst.java | 20 +-
100_core/src/gplx/core/envs/Env_.java | 20 +-
100_core/src/gplx/core/envs/Jar_adp_.java | 20 +-
100_core/src/gplx/core/envs/Op_sys.java | 20 +-
100_core/src/gplx/core/envs/Op_sys_.java | 20 +-
100_core/src/gplx/core/envs/Process_adp.java | 20 +-
100_core/src/gplx/core/envs/Process_adp_tst.java | 20 +-
100_core/src/gplx/core/envs/Runtime_.java | 20 +-
100_core/src/gplx/core/envs/System_.java | 20 +-
100_core/src/gplx/core/errs/Err_msg.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoFld.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoFldList.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoFldList_.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoNde.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoNdeFxt.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoNdeList.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoNdeList_.java | 20 [

View File

@ -13,8 +13,8 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
public class Php_ary_ { public class XophpArray {
public static boolean Pop_bool_or_n(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));} public static boolean popBoolOrN(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));}
public static byte[] Pop_bry_or_null(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);} public static byte[] popBryOrNull(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);}
} }

View File

@ -13,8 +13,8 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
public class Php_encode_ { public class XophpEncode {
public static byte[] rawurlencode(byte[] v) { public static byte[] rawurlencode(byte[] v) {
return gplx.langs.htmls.encoders.Gfo_url_encoder_.Php_rawurlencode.Encode(v); return gplx.langs.htmls.encoders.Gfo_url_encoder_.Php_rawurlencode.Encode(v);
} }

View File

@ -13,9 +13,9 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
public class Php_math_ { public class XophpMath {
public static double Round(double v, int places) { public static double round(double v, int places) {
if (places < 0) { // -1 means round to 10; -2 means round to 100; etc.. if (places < 0) { // -1 means round to 10; -2 means round to 100; etc..
int factor = (int)Math_.Pow(10, places * -1); int factor = (int)Math_.Pow(10, places * -1);
return ((int)(Math_.Round(v, 0) / factor)) * factor; // EX: ((int)Round(123, 0) / 10) * 10: 123 -> 12.3 -> 12 -> 120 return ((int)(Math_.Round(v, 0) / factor)) * factor; // EX: ((int)Round(123, 0) / 10) * 10: 123 -> 12.3 -> 12 -> 120

View File

@ -13,11 +13,11 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
import gplx.core.btries.*; import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.brys.*;
import gplx.core.primitives.*; import gplx.core.primitives.*;
public class Php_preg_ { public class XophpPreg {
public static byte[][] Split(Int_list list, byte[] src, int src_bgn, int src_end, byte[] dlm, boolean extend) { public static byte[][] split(Int_list list, byte[] src, int src_bgn, int src_end, byte[] dlm, boolean extend) {
// find delimiters // find delimiters
int dlm_len = dlm.length; int dlm_len = dlm.length;
byte dlm_nth = dlm[dlm_len - 1]; byte dlm_nth = dlm[dlm_len - 1];
@ -57,7 +57,7 @@ public class Php_preg_ {
list.Clear(); list.Clear();
return rv; return rv;
} }
public static Object Match(Btrie_slim_mgr trie, Btrie_rv trv, byte[] src, int src_bgn, int src_end) { public static Object match(Btrie_slim_mgr trie, Btrie_rv trv, byte[] src, int src_bgn, int src_end) {
trv.Match_bgn = -1; trv.Match_bgn = -1;
int cur = src_bgn; int cur = src_bgn;
while (cur < src_end) { while (cur < src_end) {
@ -73,7 +73,7 @@ public class Php_preg_ {
return null; return null;
} }
public static void Replace(Bry_tmp bry, Bry_bfr tmp, Btrie_slim_mgr find_trie, Btrie_rv trv, byte[] repl_bry) { public static void replace(Bry_tmp bry, Bry_bfr tmp, Btrie_slim_mgr find_trie, Btrie_rv trv, byte[] repl_bry) {
byte[] src = bry.src; byte[] src = bry.src;
int src_bgn = bry.src_bgn; int src_bgn = bry.src_bgn;
int src_end = bry.src_end; int src_end = bry.src_end;

View File

@ -0,0 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
import org.junit.*; import gplx.core.tests.*;
public class XophpPregTest {
private final XophpPregFxt fxt = new XophpPregFxt();
@Test public void Basic() {fxt.Test_split("a''b''c" , "''", Bool_.Y, "a", "''", "b", "''", "c");}
@Test public void Extend() {fxt.Test_split("a'''b'''c" , "''", Bool_.Y, "a", "'''", "b", "'''", "c");}
@Test public void Eos() {fxt.Test_split("a''" , "''", Bool_.Y, "a", "''");}
}
class XophpPregFxt {
private final gplx.core.primitives.Int_list rv = new gplx.core.primitives.Int_list();
public void Test_split(String src, String dlm, boolean extend, String... expd) {Test_split(src, 0, String_.Len(src), dlm, extend, expd);}
public void Test_split(String src, int src_bgn, int src_end, String dlm, boolean extend, String... expd) {
byte[][] actl = XophpPreg.split(rv, Bry_.new_u8(src), src_bgn, src_end, Bry_.new_u8(dlm), extend);
Gftest.Eq__ary(expd, String_.Ary(actl), "find_failed");
}
}

View File

@ -13,15 +13,15 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
import gplx.core.btries.*; import gplx.core.btries.*;
public class Php_str_ { public class XophpString {
public static int Strpos(byte[] src, byte find) {return Strpos(src, find, 0, src.length);} public static int strpos(byte[] src, byte find) {return strpos(src, find, 0, src.length);}
public static int Strpos(byte[] src, byte find, int bgn, int end) { public static int strpos(byte[] src, byte find, int bgn, int end) {
return Bry_find_.Find_fwd(src, find, bgn, end); return Bry_find_.Find_fwd(src, find, bgn, end);
} }
public static byte[] Substr(byte[] src, int bgn) {return Substr(src, bgn, src.length);} public static byte[] substr(byte[] src, int bgn) {return substr(src, bgn, src.length);}
public static byte[] Substr(byte[] src, int bgn, int len) { public static byte[] substr(byte[] src, int bgn, int len) {
int src_len = src.length; int src_len = src.length;
if (bgn < 0) bgn = src_len + bgn; // handle negative if (bgn < 0) bgn = src_len + bgn; // handle negative
if (bgn < 0) bgn = 0; // handle out of bounds; EX: ("a", -1, -1) if (bgn < 0) bgn = 0; // handle out of bounds; EX: ("a", -1, -1)
@ -29,8 +29,8 @@ public class Php_str_ {
if (end > src.length) end = src.length;; // handle out of bounds; if (end > src.length) end = src.length;; // handle out of bounds;
return Bry_.Mid(src, bgn, end); return Bry_.Mid(src, bgn, end);
} }
public static byte Substr_byte(byte[] src, int bgn) {return Substr_byte(src, bgn, src.length);} public static byte substr_byte(byte[] src, int bgn) {return substr_byte(src, bgn, src.length);}
public static byte Substr_byte(byte[] src, int bgn, int len) { public static byte substr_byte(byte[] src, int bgn, int len) {
int src_len = src.length; int src_len = src.length;
if (src_len == 0) return Byte_ascii.Null; if (src_len == 0) return Byte_ascii.Null;
if (bgn < 0) bgn = src_len + bgn; // handle negative if (bgn < 0) bgn = src_len + bgn; // handle negative
@ -39,7 +39,7 @@ public class Php_str_ {
if (end > src.length) end = src.length;; // handle out of bounds; if (end > src.length) end = src.length;; // handle out of bounds;
return src[bgn]; return src[bgn];
} }
public static int Strspn_fwd__ary(byte[] src, boolean[] find, int bgn, int max, int src_len) { public static int strspn_fwd__ary(byte[] src, boolean[] find, int bgn, int max, int src_len) {
if (max == -1) max = src_len; if (max == -1) max = src_len;
int rv = 0; int rv = 0;
for (int i = bgn; i < src_len; i++) { for (int i = bgn; i < src_len; i++) {
@ -50,7 +50,7 @@ public class Php_str_ {
} }
return rv; return rv;
} }
public static int Strspn_fwd__byte(byte[] src, byte find, int bgn, int max, int src_len) { public static int strspn_fwd__byte(byte[] src, byte find, int bgn, int max, int src_len) {
if (max == -1) max = src_len; if (max == -1) max = src_len;
int rv = 0; int rv = 0;
for (int i = bgn; i < src_len; i++) { for (int i = bgn; i < src_len; i++) {
@ -61,7 +61,7 @@ public class Php_str_ {
} }
return rv; return rv;
} }
public static int Strspn_fwd__space_or_tab(byte[] src, int bgn, int max, int src_len) { public static int strspn_fwd__space_or_tab(byte[] src, int bgn, int max, int src_len) {
if (max == -1) max = src_len; if (max == -1) max = src_len;
int rv = 0; int rv = 0;
for (int i = bgn; i < src_len; i++) { for (int i = bgn; i < src_len; i++) {
@ -78,7 +78,7 @@ public class Php_str_ {
} }
return rv; return rv;
} }
public static int Strspn_bwd__byte(byte[] src, byte find, int bgn, int max) { public static int strspn_bwd__byte(byte[] src, byte find, int bgn, int max) {
if (max == -1) max = Int_.Max_value; if (max == -1) max = Int_.Max_value;
int rv = 0; int rv = 0;
for (int i = bgn - 1; i > -1; i--) { for (int i = bgn - 1; i > -1; i--) {
@ -89,7 +89,7 @@ public class Php_str_ {
} }
return rv; return rv;
} }
public static int Strspn_bwd__ary(byte[] src, boolean[] find, int bgn, int max) { public static int strspn_bwd__ary(byte[] src, boolean[] find, int bgn, int max) {
if (max == -1) max = Int_.Max_value; if (max == -1) max = Int_.Max_value;
int rv = 0; int rv = 0;
for (int i = bgn - 1; i > -1; i--) { for (int i = bgn - 1; i > -1; i--) {
@ -100,7 +100,7 @@ public class Php_str_ {
} }
return rv; return rv;
} }
public static int Strspn_bwd__space_or_tab(byte[] src, int bgn, int max) { public static int strspn_bwd__space_or_tab(byte[] src, int bgn, int max) {
if (max == -1) max = Int_.Max_value; if (max == -1) max = Int_.Max_value;
int rv = 0; int rv = 0;
for (int i = bgn - 1; i > -1; i--) { for (int i = bgn - 1; i > -1; i--) {
@ -117,7 +117,7 @@ public class Php_str_ {
} }
return rv; return rv;
} }
public static byte[] Strtr(byte[] src, Btrie_slim_mgr trie, Bry_bfr tmp, Btrie_rv trv) { public static byte[] strtr(byte[] src, Btrie_slim_mgr trie, Bry_bfr tmp, Btrie_rv trv) {
boolean dirty = false; boolean dirty = false;
int src_bgn = 0; int src_bgn = 0;
int src_end = src.length; int src_end = src.length;

View File

@ -0,0 +1,85 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
import org.junit.*; import gplx.core.tests.*; import gplx.core.btries.*;
public class XophpStringTest {
private final XophpStringFxt fxt = new XophpStringFxt();
@Test public void Strspn_fwd__byte() {
fxt.Test_strspn_fwd__byte("aaaaab", Byte_ascii.Ltr_a, 0, -1, 5); // basic
fxt.Test_strspn_fwd__byte("aaaaab", Byte_ascii.Ltr_a, 1, -1, 4); // bgn
fxt.Test_strspn_fwd__byte("aaaaab", Byte_ascii.Ltr_a, 1, 2, 2); // max
}
@Test public void Strspn_fwd__space_or_tab() {
fxt.Test_strspn_fwd__space_or_tab(" a", 0, -1, 5); // basic
fxt.Test_strspn_fwd__space_or_tab(" a", 1, -1, 4); // bgn
fxt.Test_strspn_fwd__space_or_tab(" a", 1, 2, 2); // max
}
@Test public void Strspn_bwd__byte() {
fxt.Test_strspn_bwd__byte("aaaaab", Byte_ascii.Ltr_a, 5, -1, 5); // basic
fxt.Test_strspn_bwd__byte("aaaaab", Byte_ascii.Ltr_a, 4, -1, 4); // bgn
fxt.Test_strspn_bwd__byte("aaaaab", Byte_ascii.Ltr_a, 4, 2, 2); // max
}
@Test public void Strspn_bwd__space_or_tab() {
fxt.Test_strspn_bwd__space_or_tab(" a", 5, -1, 5); // basic
fxt.Test_strspn_bwd__space_or_tab(" a", 4, -1, 4); // bgn
fxt.Test_strspn_bwd__space_or_tab(" a", 4, 2, 2); // max
}
@Test public void Substr__bgn_is_neg() {
fxt.Test_substr("abcde" , -1, "e");
fxt.Test_substr("abcde" , -3, -1, "cd");
}
@Test public void Strtr() {
fxt.Init_strtr_by_trie("01", "89", "02", "79");
fxt.Test_strtr_by_trie("abc" , "abc"); // found=none
fxt.Test_strtr_by_trie("ab_01_cd" , "ab_89_cd"); // found=one
fxt.Test_strtr_by_trie("ab_01_cd_02_ef", "ab_89_cd_79_ef"); // found=many
fxt.Test_strtr_by_trie("01_ab" , "89_ab"); // BOS
fxt.Test_strtr_by_trie("ab_01" , "ab_89"); // EOS
}
}
class XophpStringFxt {
public void Test_strspn_fwd__byte(String src_str, byte find, int bgn, int max, int expd) {
byte[] src_bry = Bry_.new_u8(src_str);
Gftest.Eq__int(expd, XophpString.strspn_fwd__byte(src_bry, find, bgn, max, src_bry.length));
}
public void Test_strspn_fwd__space_or_tab(String src_str, int bgn, int max, int expd) {
byte[] src_bry = Bry_.new_u8(src_str);
Gftest.Eq__int(expd, XophpString.strspn_fwd__space_or_tab(src_bry, bgn, max, src_bry.length));
}
public void Test_strspn_bwd__byte(String src_str, byte find, int bgn, int max, int expd) {
Gftest.Eq__int(expd, XophpString.strspn_bwd__byte(Bry_.new_u8(src_str), find, bgn, max));
}
public void Test_strspn_bwd__space_or_tab(String src_str, int bgn, int max, int expd) {
Gftest.Eq__int(expd, XophpString.strspn_bwd__space_or_tab(Bry_.new_u8(src_str), bgn, max));
}
public void Test_substr(String src_str, int bgn, String expd) {Test_substr(src_str, bgn, String_.Len(src_str), expd);}
public void Test_substr(String src_str, int bgn, int len, String expd) {
Gftest.Eq__str(expd, XophpString.substr(Bry_.new_u8(src_str), bgn, len));
}
private Btrie_slim_mgr strtr_trie;
public void Init_strtr_by_trie(String... kvs) {
if (strtr_trie == null) strtr_trie = Btrie_slim_mgr.cs();
int len = kvs.length;
for (int i = 0; i < len; i += 2) {
strtr_trie.Add_str_str(kvs[i], kvs[i + 1]);
}
}
public void Test_strtr_by_trie(String src, String expd) {
Bry_bfr tmp = Bry_bfr_.New();
Btrie_rv trv = new Btrie_rv();
Gftest.Eq__str(expd, XophpString.strtr(Bry_.new_u8(src), strtr_trie, tmp, trv));
}
}

View File

@ -13,8 +13,8 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
public class Php_utl_ { public class XophpUtility {
public static boolean empty(byte[] v) {return v == null || v.length == 0;} public static boolean empty(byte[] v) {return v == null || v.length == 0;}
public static boolean empty(boolean v) {return v == false;} public static boolean empty(boolean v) {return v == false;}
public static boolean empty(int v) {return v == 0;} public static boolean empty(int v) {return v == 0;}
@ -37,6 +37,7 @@ public class Php_utl_ {
} }
return true; return true;
} }
public static final int Null_int = Int_.Max_value; public static final int Null_int = Int_.Max_value;
public static final double Null_double = Double_.MinValue; public static final double Null_double = Double_.MinValue;
public static final byte[] Null_bry = null; public static final byte[] Null_bry = null;

View File

@ -2596,11 +2596,11 @@ public class XomwGlobalFunctions {
// * @return String // * @return String
// */ // */
// function wfShellWikiCmd( $script, array $parameters = [], array $options = [] ) { // function wfShellWikiCmd( $script, array $parameters = [], array $options = [] ) {
// global $wgPhpCli; // global $wgXophpCli;
// // Give site config file a chance to run the script in a wrapper. // // Give site config file a chance to run the script in a wrapper.
// // The caller may likely want to call wfBasename() on $script. // // The caller may likely want to call wfBasename() on $script.
// Hooks::run( 'wfShellWikiCmd', [ &$script, &$parameters, &$options ] ); // Hooks::run( 'wfShellWikiCmd', [ &$script, &$parameters, &$options ] );
// $cmd = isset( $options['php'] ) ? [ $options['php'] ] : [ $wgPhpCli ]; // $cmd = isset( $options['php'] ) ? [ $options['php'] ] : [ $wgXophpCli ];
// if ( isset( $options['wrapper'] ) ) { // if ( isset( $options['wrapper'] ) ) {
// $cmd[] = $options['wrapper']; // $cmd[] = $options['wrapper'];
// } // }

View File

@ -19,7 +19,6 @@ import gplx.langs.htmls.*;
import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.linkers.*; import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.linkers.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.media.*; import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.media.*;
import gplx.xowa.mediawiki.includes.parsers.lnkis.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.utls.*;
/* TODO.XO /* TODO.XO
* thumb = $file->getUnscaledThumb(handlerParams); * thumb = $file->getUnscaledThumb(handlerParams);
* P8: wfMessage * P8: wfMessage
@ -342,16 +341,16 @@ public class XomwLinker {
// Clean up parameters // Clean up parameters
int page = handlerParams.page; int page = handlerParams.page;
if (!Php_utl_.isset(frameParams.align)) { if (!XophpUtility.isset(frameParams.align)) {
frameParams.align = Bry_.Empty; frameParams.align = Bry_.Empty;
} }
if (!Php_utl_.isset(frameParams.alt)) { if (!XophpUtility.isset(frameParams.alt)) {
frameParams.alt = Bry_.Empty; frameParams.alt = Bry_.Empty;
} }
if (!Php_utl_.isset(frameParams.title)) { if (!XophpUtility.isset(frameParams.title)) {
frameParams.title = Bry_.Empty; frameParams.title = Bry_.Empty;
} }
if (!Php_utl_.isset(frameParams.cls)) { if (!XophpUtility.isset(frameParams.cls)) {
frameParams.cls = Bry_.Empty; frameParams.cls = Bry_.Empty;
} }
@ -362,8 +361,8 @@ public class XomwLinker {
postfix = Gfh_tag_.Div_rhs; postfix = Gfh_tag_.Div_rhs;
frameParams.align = Align__frame__none; frameParams.align = Align__frame__none;
} }
if (file != null && !Php_utl_.isset(handlerParams.width)) { if (file != null && !XophpUtility.isset(handlerParams.width)) {
if (Php_utl_.isset(handlerParams.height) && file.isVectorized()) { if (XophpUtility.isset(handlerParams.height) && file.isVectorized()) {
// If its a vector image, and user only specifies height // If its a vector image, and user only specifies height
// we don't want it to be limited by its "normal" width. // we don't want it to be limited by its "normal" width.
handlerParams.width = env.Global__wgSVGMaxSize; handlerParams.width = env.Global__wgSVGMaxSize;
@ -372,13 +371,13 @@ public class XomwLinker {
handlerParams.width = file.getWidth(page); handlerParams.width = file.getWidth(page);
} }
if ( Php_utl_.isset(frameParams.thumbnail) if ( XophpUtility.isset(frameParams.thumbnail)
|| Php_utl_.isset(frameParams.manualthumb) || XophpUtility.isset(frameParams.manualthumb)
|| Php_utl_.isset(frameParams.framed) || XophpUtility.isset(frameParams.framed)
|| Php_utl_.isset(frameParams.frameless) || XophpUtility.isset(frameParams.frameless)
|| !Php_utl_.istrue(handlerParams.width) || !XophpUtility.istrue(handlerParams.width)
) { ) {
if (widthOption == Php_utl_.Null_int) { // XO.MW: MW does extra validation that widthOption is in array; ("!isset( $wgThumbLimits[$widthOption] )") if (widthOption == XophpUtility.Null_int) { // XO.MW: MW does extra validation that widthOption is in array; ("!isset( $wgThumbLimits[$widthOption] )")
widthOption = env.User__default__thumbsize; widthOption = env.User__default__thumbsize;
} }
@ -390,13 +389,13 @@ public class XomwLinker {
// For caching health: If width scaled down due to upright // For caching health: If width scaled down due to upright
// parameter, round to full __0 pixel to avoid the creation of a // parameter, round to full __0 pixel to avoid the creation of a
// lot of odd thumbs. // lot of odd thumbs.
int prefWidth = Php_utl_.isset(frameParams.upright) ? int prefWidth = XophpUtility.isset(frameParams.upright) ?
(int)Php_math_.Round(widthOption * frameParams.upright, -1) : (int)XophpMath.round(widthOption * frameParams.upright, -1) :
widthOption; widthOption;
// Use width which is smaller: real image width or user preference width // Use width which is smaller: real image width or user preference width
// Unless image is scalable vector. // Unless image is scalable vector.
if (handlerParams.height == Php_utl_.Null_int && handlerParams.width <= 0 || if (handlerParams.height == XophpUtility.Null_int && handlerParams.width <= 0 ||
prefWidth < handlerParams.width || file.isVectorized()) { prefWidth < handlerParams.width || file.isVectorized()) {
handlerParams.width = prefWidth; handlerParams.width = prefWidth;
} }
@ -425,13 +424,13 @@ public class XomwLinker {
// For "frameless" option: do not present an image bigger than the // For "frameless" option: do not present an image bigger than the
// source (for bitmap-style images). This is the same behavior as the // source (for bitmap-style images). This is the same behavior as the
// "thumb" option does it already. // "thumb" option does it already.
if (Php_utl_.istrue(srcWidth) && !file.mustRender() && handlerParams.width > srcWidth) { if (XophpUtility.istrue(srcWidth) && !file.mustRender() && handlerParams.width > srcWidth) {
handlerParams.width = srcWidth; handlerParams.width = srcWidth;
} }
} }
XomwMediaTransformOutput thumb = null; XomwMediaTransformOutput thumb = null;
if (file != null && Php_utl_.isset(handlerParams.width)) { if (file != null && XophpUtility.isset(handlerParams.width)) {
// Create a resized image, without the additional thumbnail features // Create a resized image, without the additional thumbnail features
thumb = file.transform(handlerParams); thumb = file.transform(handlerParams);
} }
@ -482,9 +481,9 @@ public class XomwLinker {
// @return array // @return array
// XO.MW:SYNC:1.29; DATE:2017-02-08 // XO.MW:SYNC:1.29; DATE:2017-02-08
private static void getImageLinkMTOParams(Xomw_params_mto rv, Xomw_params_frame frameParams, byte[] query, XomwParserIface parser) { private static void getImageLinkMTOParams(Xomw_params_mto rv, Xomw_params_frame frameParams, byte[] query, XomwParserIface parser) {
if (Php_utl_.isset(frameParams.link_url) && frameParams.link_url != Bry_.Empty) { if (XophpUtility.isset(frameParams.link_url) && frameParams.link_url != Bry_.Empty) {
rv.custom_url_link = frameParams.link_url; rv.custom_url_link = frameParams.link_url;
if (Php_utl_.isset(frameParams.link_target)) { if (XophpUtility.isset(frameParams.link_target)) {
rv.custom_target_link = frameParams.link_target; rv.custom_target_link = frameParams.link_target;
} }
if (parser != null) { if (parser != null) {
@ -495,10 +494,10 @@ public class XomwLinker {
// } // }
} }
} }
else if (Php_utl_.isset(frameParams.link_title) && frameParams.link_title != Bry_.Empty) { else if (XophpUtility.isset(frameParams.link_title) && frameParams.link_title != Bry_.Empty) {
// rv.custom_title_link = Title::newFromLinkTarget(Normalize_speecial_page(frameParams.link_title)); // rv.custom_title_link = Title::newFromLinkTarget(Normalize_speecial_page(frameParams.link_title));
} }
else if (!Php_utl_.empty(frameParams.no_link)) { else if (!XophpUtility.empty(frameParams.no_link)) {
// No link // No link
} }
else { else {
@ -539,22 +538,22 @@ public class XomwLinker {
boolean exists = file != null && file.exists(); boolean exists = file != null && file.exists();
int page = handlerParams.page; int page = handlerParams.page;
if (!Php_utl_.isset(frameParams.align)) { if (!XophpUtility.isset(frameParams.align)) {
frameParams.align = Align__frame__right; frameParams.align = Align__frame__right;
} }
if (!Php_utl_.isset(frameParams.alt)) { if (!XophpUtility.isset(frameParams.alt)) {
frameParams.alt = Bry_.Empty; frameParams.alt = Bry_.Empty;
} }
if (!Php_utl_.isset(frameParams.title)) { if (!XophpUtility.isset(frameParams.title)) {
frameParams.title = Bry_.Empty; frameParams.title = Bry_.Empty;
} }
if (!Php_utl_.isset(frameParams.caption)) { if (!XophpUtility.isset(frameParams.caption)) {
frameParams.caption = Bry_.Empty; frameParams.caption = Bry_.Empty;
} }
if (Php_utl_.empty(handlerParams.width)) { if (XophpUtility.empty(handlerParams.width)) {
// Reduce width for upright images when parameter 'upright' is used // Reduce width for upright images when parameter 'upright' is used
handlerParams.width = Php_utl_.isset(frameParams.upright) ? 130 : 180; handlerParams.width = XophpUtility.isset(frameParams.upright) ? 130 : 180;
} }
XomwMediaTransformOutput thumb = null; XomwMediaTransformOutput thumb = null;
boolean noscale = false; boolean noscale = false;
@ -565,7 +564,7 @@ public class XomwLinker {
outerWidth = handlerParams.width + 2; outerWidth = handlerParams.width + 2;
} }
else { else {
if (Php_utl_.isset(frameParams.manualthumb)) { if (XophpUtility.isset(frameParams.manualthumb)) {
// Use manually specified thumbnail // Use manually specified thumbnail
// $manual_title = Title::makeTitleSafe(NS_FILE, frameParams['manualthumb']); // $manual_title = Title::makeTitleSafe(NS_FILE, frameParams['manualthumb']);
// if ($manual_title) { // if ($manual_title) {
@ -578,7 +577,7 @@ public class XomwLinker {
// } // }
// } // }
} }
else if (Php_utl_.isset(frameParams.framed)) { else if (XophpUtility.isset(frameParams.framed)) {
// Use image dimensions, don't scale // Use image dimensions, don't scale
// thumb = $file->getUnscaledThumb(handlerParams); // thumb = $file->getUnscaledThumb(handlerParams);
thumb = new XomwThumbnailImage(file, file.getUrl(), file.getUrl(), file.getWidth(), file.getHeight()); thumb = new XomwThumbnailImage(file, file.getUrl(), file.getUrl(), file.getWidth(), file.getHeight());
@ -588,7 +587,7 @@ public class XomwLinker {
// Do not present an image bigger than the source, for bitmap-style images // Do not present an image bigger than the source, for bitmap-style images
// This is a hack to maintain compatibility with arbitrary pre-1.10 behavior // This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
int srcWidth = file.getWidth(page); int srcWidth = file.getWidth(page);
if (Php_utl_.istrue(srcWidth) && !file.mustRender() && handlerParams.width > srcWidth) { if (XophpUtility.istrue(srcWidth) && !file.mustRender() && handlerParams.width > srcWidth) {
handlerParams.width = srcWidth; handlerParams.width = srcWidth;
} }
thumb = file.transform(handlerParams); thumb = file.transform(handlerParams);
@ -611,9 +610,9 @@ public class XomwLinker {
// $url = wfAppendQuery($url, [ 'page' => $page ]); // $url = wfAppendQuery($url, [ 'page' => $page ]);
// } // }
if (manualthumb if (manualthumb
&& !Php_utl_.isset(frameParams.link_title) && !XophpUtility.isset(frameParams.link_title)
&& !Php_utl_.isset(frameParams.link_url) && !XophpUtility.isset(frameParams.link_url)
&& !Php_utl_.isset(frameParams.no_link) && !XophpUtility.isset(frameParams.no_link)
) { ) {
frameParams.link_url = url; frameParams.link_url = url;
} }
@ -643,7 +642,7 @@ public class XomwLinker {
getImageLinkMTOParams(prms, frameParams, query, null); getImageLinkMTOParams(prms, frameParams, query, null);
thumb.toHtml(bfr, tmp, prms); thumb.toHtml(bfr, tmp, prms);
if (Php_utl_.isset(frameParams.framed)) { if (XophpUtility.isset(frameParams.framed)) {
zoom_icon = Bry_.Empty; zoom_icon = Bry_.Empty;
} }
else { else {

View File

@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.encoders.*; import gplx.core.primitives.*; import gplx.langs.htmls.entitys.*; import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.encoders.*; import gplx.core.primitives.*; import gplx.langs.htmls.entitys.*;
import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.htmls.*;
import gplx.langs.htmls.*; import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.utls.*; import gplx.langs.htmls.*; import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.libs.*; import gplx.xowa.mediawiki.includes.libs.*;
public class XomwSanitizer { public class XomwSanitizer {
private final Mwh_doc_wkr__atr_bldr atr_bldr = new Mwh_doc_wkr__atr_bldr(); private final Mwh_doc_wkr__atr_bldr atr_bldr = new Mwh_doc_wkr__atr_bldr();
@ -1233,7 +1233,7 @@ public class XomwSanitizer {
// ' ', // ' ',
// $text); // $text);
normalizeWhitespaceBry.Init(text, 0, text.length); normalizeWhitespaceBry.Init(text, 0, text.length);
Php_preg_.Replace(normalizeWhitespaceBry, tmp_bfr_2, normalizeWhitespaceTrie, trv, Byte_ascii.Space_bry); XophpPreg.replace(normalizeWhitespaceBry, tmp_bfr_2, normalizeWhitespaceTrie, trv, Byte_ascii.Space_bry);
return normalizeWhitespaceBry.src; return normalizeWhitespaceBry.src;
} }
@ -1722,7 +1722,7 @@ public class XomwSanitizer {
// https://tools.ietf.org/html/rfc3454#section-3.1 // https://tools.ietf.org/html/rfc3454#section-3.1
// Strip them before further processing so blacklists and such work. // Strip them before further processing so blacklists and such work.
// XO.MW.MOVED: see invalid_idn_trie // XO.MW.MOVED: see invalid_idn_trie
Php_preg_.Replace(tmp_host.Init(url, regex_find_domain.host_bgn, regex_find_domain.host_end), tmp_bfr, invalid_idn_trie, trv, Bry_.Empty); XophpPreg.replace(tmp_host.Init(url, regex_find_domain.host_bgn, regex_find_domain.host_end), tmp_bfr, invalid_idn_trie, trv, Bry_.Empty);
// IPv6 host names are bracketed with []. Url-decode these. // IPv6 host names are bracketed with []. Url-decode these.
// if (substr_compare("//%5B", $host, 0, 5) === 0 && // if (substr_compare("//%5B", $host, 0, 5) === 0 &&

View File

@ -382,7 +382,7 @@ public class XomwSetup {
// $wgMinUploadChunkSize = min( // $wgMinUploadChunkSize = min(
// $wgMinUploadChunkSize, // $wgMinUploadChunkSize,
// UploadBase::getMaxUploadSize( 'file' ), // UploadBase::getMaxUploadSize( 'file' ),
// UploadBase::getMaxPhpUploadSize(), // UploadBase::getMaxXophpUploadSize(),
// ( wfShorthandToInteger( // ( wfShorthandToInteger(
// ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ), // ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ),
// PHP_INT_MAX // PHP_INT_MAX

View File

@ -14,7 +14,6 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.title.*; import gplx.xowa.mediawiki.includes.title.*;
/** /**
* Represents a title within MediaWiki. * Represents a title within MediaWiki.
@ -308,7 +307,7 @@ public class XomwTitle {
byte[] filteredText = text; byte[] filteredText = text;
XomwTitle t = new XomwTitle(); XomwTitle t = new XomwTitle();
t.mDbkeyform = Php_str_.strtr(filteredText, Byte_ascii.Space, Byte_ascii.Underline); t.mDbkeyform = XophpString.strtr(filteredText, Byte_ascii.Space, Byte_ascii.Underline);
t.mDefaultNamespace = defaultNamespace; t.mDefaultNamespace = defaultNamespace;
t.secureAndSplit(); t.secureAndSplit();
@ -1434,7 +1433,7 @@ public class XomwTitle {
*/ */
public byte[] getPrefixedDBkey() { public byte[] getPrefixedDBkey() {
byte[] s = this.prefix(this.mDbkeyform); byte[] s = this.prefix(this.mDbkeyform);
s = Php_str_.strtr(s, Byte_ascii.Space, Byte_ascii.Underline); s = XophpString.strtr(s, Byte_ascii.Space, Byte_ascii.Underline);
return s; return s;
} }
@ -1447,7 +1446,7 @@ public class XomwTitle {
public byte[] getPrefixedText() { public byte[] getPrefixedText() {
if (this.mPrefixedText == null) { if (this.mPrefixedText == null) {
byte[] s = this.prefix(this.mTextform); byte[] s = this.prefix(this.mTextform);
s = Php_str_.strtr(s, Byte_ascii.Underline, Byte_ascii.Space); s = XophpString.strtr(s, Byte_ascii.Underline, Byte_ascii.Space);
this.mPrefixedText = s; this.mPrefixedText = s;
} }
return this.mPrefixedText; return this.mPrefixedText;
@ -3378,7 +3377,7 @@ public class XomwTitle {
this.mDbkeyform = parts.dbkey; this.mDbkeyform = parts.dbkey;
// this.mUrlform = wfUrlencode(this.mDbkeyform); // this.mUrlform = wfUrlencode(this.mDbkeyform);
this.mTextform = Php_str_.strtr(this.mDbkeyform, Byte_ascii.Underline, Byte_ascii.Space); this.mTextform = XophpString.strtr(this.mDbkeyform, Byte_ascii.Underline, Byte_ascii.Space);
// We already know that some pages won't be in the database! // We already know that some pages won't be in the database!
if (this.isExternal() || this.mNamespace == XomwDefines.NS_SPECIAL) { if (this.isExternal() || this.mNamespace == XomwDefines.NS_SPECIAL) {
@ -4836,4 +4835,105 @@ public class XomwTitle {
// this.mTextform = strtr(this.mDbkeyform, '_', ' '); // this.mTextform = strtr(this.mDbkeyform, '_', ' ');
// } // }
private static final byte[] Bry__wgArticlePath__wiki = Bry_.new_a7("/wiki/"); private static final byte[] Bry__wgArticlePath__wiki = Bry_.new_a7("/wiki/");
// REF.MW: DefaultSettings.php
// Allowed title characters -- regex character class
// Don't change this unless you know what you're doing
//
// Problematic punctuation:
// - []{}|# Are needed for link syntax, never enable these
// - <> Causes problems with HTML escaping, don't use
// - % Enabled by default, minor problems with path to query rewrite rules, see below
// - + Enabled by default, but doesn't work with path to query rewrite rules,
// corrupted by apache
// - ? Enabled by default, but doesn't work with path to PATH_INFO rewrites
//
// All three of these punctuation problems can be avoided by using an alias,
// instead of a rewrite rule of either variety.
//
// The problem with % is that when using a path to query rewrite rule, URLs are
// double-unescaped: once by Apache's path conversion code, and again by PHP. So
// %253F, for example, becomes "?". Our code does not double-escape to compensate
// for this, indeed double escaping would break if the double-escaped title was
// passed in the query String rather than the path. This is a minor security issue
// because articles can be created such that they are hard to view or edit.
//
// In some rare cases you may wish to remove + for compatibility with old links.
//
// Theoretically 0x80-0x9F of ISO 8859-1 should be disallowed, but
// this breaks interlanguage links
// $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
//
// REGEX:
// without-backslash escaping --> \s%!"$&'()*,-./0-9:;=?@A-Z\^_`a-z~x80-xFF+
// rearranged
// letters --> 0-9A-Za-z
// unicode-chars --> x80-xFF
// symbols --> \s%!"$&'()*,-./:;=?@\^_`~+"
// deliberately ignores
// control chars: 00-31,127
// []{}|#<>
public static int Find_fwd_while_title(byte[] src, int src_bgn, int src_end, boolean[] valid) {
int cur = src_bgn;
while (true) {
if (cur == src_end) break;
byte b = src[cur];
int b_len = gplx.core.intls.Utf8_.Len_of_char_by_1st_byte(b);
if (b_len == 1) { // ASCII
if (valid[b & 0xFF]) // valid; EX: "a0A B&$"; PATCH.JAVA:need to convert to unsigned byte
cur++;
else // invalid; EX: "<title>"
break;
}
else { // Multi-byte UTF8; NOTE: all sequences are valid
cur += b_len;
}
}
return cur;
}
private static boolean[] title_chars_valid;
public static boolean[] Title_chars_valid() {
if (title_chars_valid == null) {
title_chars_valid = new boolean[128];
// add num and alpha
for (int i = Byte_ascii.Num_0; i <= Byte_ascii.Num_9; i++)
title_chars_valid[i] = true;
for (int i = Byte_ascii.Ltr_A; i <= Byte_ascii.Ltr_Z; i++)
title_chars_valid[i] = true;
for (int i = Byte_ascii.Ltr_a; i <= Byte_ascii.Ltr_z; i++)
title_chars_valid[i] = true;
// add symbols: \s%!"$&'()*,-./:;=?@\^_`~+"
byte[] symbols = new byte[]
{ Byte_ascii.Space
, Byte_ascii.Percent
, Byte_ascii.Bang
, Byte_ascii.Quote
, Byte_ascii.Amp
, Byte_ascii.Apos
, Byte_ascii.Paren_bgn
, Byte_ascii.Paren_end
, Byte_ascii.Star
, Byte_ascii.Comma
, Byte_ascii.Dash
, Byte_ascii.Dot
, Byte_ascii.Slash
, Byte_ascii.Colon
, Byte_ascii.Semic
, Byte_ascii.Eq
, Byte_ascii.Question
, Byte_ascii.At
, Byte_ascii.Backslash
, Byte_ascii.Pow
, Byte_ascii.Underline
, Byte_ascii.Tick
, Byte_ascii.Tilde
, Byte_ascii.Plus
};
int symbols_len = symbols.length;
for (int i = 0; i < symbols_len; i++)
title_chars_valid[symbols[i]] = true;
}
return title_chars_valid;
}
} }

View File

@ -13,16 +13,16 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
import org.junit.*; import gplx.core.tests.*; import org.junit.*; import gplx.core.tests.*;
public class Xomw_ttl_utl__tst { public class XomwTitleTest {
private final Xomw_ttl_utl__fxt fxt = new Xomw_ttl_utl__fxt(); private final XomwTitleFxt fxt = new XomwTitleFxt();
@Test public void Alphanum() {fxt.Test__find_fwd_while_title("0aB" , 3);} @Test public void Alphanum() {fxt.Test__find_fwd_while_title("0aB" , 3);}
@Test public void Angle() {fxt.Test__find_fwd_while_title("0a<" , 2);} @Test public void Angle() {fxt.Test__find_fwd_while_title("0a<" , 2);}
} }
class Xomw_ttl_utl__fxt { class XomwTitleFxt {
public void Test__find_fwd_while_title(String src_str, int expd) { public void Test__find_fwd_while_title(String src_str, int expd) {
byte[] src_bry = Bry_.new_u8(src_str); byte[] src_bry = Bry_.new_u8(src_str);
Gftest.Eq__int(expd, Xomw_ttl_utl.Find_fwd_while_title(src_bry, 0, src_bry.length, Xomw_ttl_utl.Title_chars_valid())); Gftest.Eq__int(expd, XomwTitle.Find_fwd_while_title(src_bry, 0, src_bry.length, XomwTitle.Title_chars_valid()));
} }
} }

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.filerepo; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.filerepo; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.filerepo.file.*;
import gplx.xowa.mediawiki.includes.utls.*;
/* TODO.XO: /* TODO.XO:
* getZoneUrl * getZoneUrl
*/ */

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.filerepo.file; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.filerepo.*; package gplx.xowa.mediawiki.includes.filerepo.file; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.filerepo.*;
import gplx.xowa.mediawiki.includes.media.*; import gplx.xowa.mediawiki.includes.media.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*; import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
public class XomwFile { public class XomwFile {
/* TODO.XO: /* TODO.XO:
@ -279,7 +278,7 @@ public class XomwFile {
* @return String * @return String
*/ */
public byte[] getName() { public byte[] getName() {
if (!Php_utl_.isset(this.name)) { if (!XophpUtility.isset(this.name)) {
// this.assertRepoDefined(); // this.assertRepoDefined();
this.name = this.repo.getNameFromTitle(this.title); this.name = this.repo.getNameFromTitle(this.title);
} }
@ -293,10 +292,10 @@ public class XomwFile {
* @return String * @return String
*/ */
private byte[] getExtension() { private byte[] getExtension() {
if (!Php_utl_.isset(this.extension)) { if (!XophpUtility.isset(this.extension)) {
int n = Php_str_.Strpos(this.getName(), Byte_ascii.Dot); int n = XophpString.strpos(this.getName(), Byte_ascii.Dot);
this.extension = normalizeExtension( this.extension = normalizeExtension(
n != Bry_find_.Not_found ? Php_str_.Substr(this.getName(), n + 1) : Bry_.Empty); n != Bry_find_.Not_found ? XophpString.substr(this.getName(), n + 1) : Bry_.Empty);
} }
return this.extension; return this.extension;
@ -330,7 +329,7 @@ public class XomwFile {
* @return String * @return String
*/ */
public byte[] getUrl() { public byte[] getUrl() {
if (!Php_utl_.isset(this.url)) { if (!XophpUtility.isset(this.url)) {
// this.assertRepoDefined(); // this.assertRepoDefined();
byte[] ext = this.getExtension(); byte[] ext = this.getExtension();
this.url = Bry_.Add(this.repo.getZoneUrl(XomwFileRepo.Zone__public, ext), Byte_ascii.Slash_bry, this.getUrlRel()); this.url = Bry_.Add(this.repo.getZoneUrl(XomwFileRepo.Zone__public, ext), Byte_ascii.Slash_bry, this.getUrlRel());
@ -1497,7 +1496,7 @@ public class XomwFile {
* @return String * @return String
*/ */
private byte[] getHashPath() { private byte[] getHashPath() {
if (!Php_utl_.isset(this.hashPath)) { if (!XophpUtility.isset(this.hashPath)) {
// this.assertRepoDefined(); // this.assertRepoDefined();
this.hashPath = this.repo.getHashPath(this.getName()); this.hashPath = this.repo.getHashPath(this.getName());
} }
@ -1559,7 +1558,7 @@ public class XomwFile {
* @return String * @return String
*/ */
private byte[] getUrlRel() { private byte[] getUrlRel() {
return Bry_.Add(this.getHashPath(), Php_encode_.rawurlencode(this.getName())); return Bry_.Add(this.getHashPath(), XophpEncode.rawurlencode(this.getName()));
} }
// /** // /**

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.xowa.mediawiki.includes.utls.*;
public class XomwHtml { public class XomwHtml {
private final Bry_bfr tmp = Bry_bfr_.New(); private final Bry_bfr tmp = Bry_bfr_.New();
private final Btrie_rv trv = new Btrie_rv(); private final Btrie_rv trv = new Btrie_rv();
@ -128,7 +127,7 @@ public class XomwHtml {
} }
else { else {
// PORTED.HEADER:atr_val_encodings // PORTED.HEADER:atr_val_encodings
val = Php_str_.Strtr(val, atr_val_encodings, tmp, trv); val = XophpString.strtr(val, atr_val_encodings, tmp, trv);
bfr.Add_byte_space().Add(key).Add(Bry__atr__val__quote).Add(val).Add_byte_quote(); bfr.Add_byte_space().Add(key).Add(Bry__atr__val__quote).Add(val).Add_byte_quote();
} }
} }

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.libs.replacers.*; import gplx.xowa.mediawiki.includes.libs.replacers.*;
/** /**
* A collection of static methods to play with strings. * A collection of static methods to play with strings.

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*; import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.utls.*;
/* XO.TODO: /* XO.TODO:
* validateThumbParams * validateThumbParams
*/ */
@ -29,7 +28,7 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
* @return boolean * @return boolean
*/ */
@Override public boolean canRender(XomwFile file) { @Override public boolean canRender(XomwFile file) {
return (Php_utl_.istrue(file.getWidth()) && Php_utl_.istrue(file.getHeight())); return (XophpUtility.istrue(file.getWidth()) && XophpUtility.istrue(file.getHeight()));
} }
@Override public Xomw_param_map getParamMap() { @Override public Xomw_param_map getParamMap() {
@ -53,10 +52,10 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
@Override public byte[] makeParamString(Xomw_params_handler handlerParams) { @Override public byte[] makeParamString(Xomw_params_handler handlerParams) {
int width = 0; int width = 0;
if (Php_utl_.isset(handlerParams.physicalWidth)) { if (XophpUtility.isset(handlerParams.physicalWidth)) {
width = handlerParams.physicalWidth; width = handlerParams.physicalWidth;
} }
else if (Php_utl_.isset(handlerParams.width)) { else if (XophpUtility.isset(handlerParams.width)) {
width = handlerParams.width; width = handlerParams.width;
} }
else { else {
@ -77,7 +76,7 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
// pos = Bry_find_.Find_fwd_while_num(src, 1, len); // skip numeric // pos = Bry_find_.Find_fwd_while_num(src, 1, len); // skip numeric
// if (Bry_.Match(src, pos, len, Xomw_lnki_wkr.Bry__px)) { // matches "px" // if (Bry_.Match(src, pos, len, Xomw_lnki_wkr.Bry__px)) { // matches "px"
// Xomw_params_handler rv = new Xomw_params_handler(); // Xomw_params_handler rv = new Xomw_params_handler();
// rv.width = Bry_.To_int_or(src, 0, pos, Php_utl_.Null_int); // rv.width = Bry_.To_int_or(src, 0, pos, XophpUtility.Null_int);
// return rv; // return rv;
// } // }
// } // }
@ -96,11 +95,11 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
@Override public boolean normaliseParams(XomwFile image, Xomw_params_handler handlerParams) { @Override public boolean normaliseParams(XomwFile image, Xomw_params_handler handlerParams) {
byte[] mimeType = image.getMimeType(); byte[] mimeType = image.getMimeType();
if (!Php_utl_.isset(handlerParams.width)) { if (!XophpUtility.isset(handlerParams.width)) {
return false; return false;
} }
if (!Php_utl_.isset(handlerParams.page)) { if (!XophpUtility.isset(handlerParams.page)) {
handlerParams.page = 1; handlerParams.page = 1;
} }
else { else {
@ -117,7 +116,7 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
int srcWidth = image.getWidth(handlerParams.page); int srcWidth = image.getWidth(handlerParams.page);
int srcHeight = image.getHeight(handlerParams.page); int srcHeight = image.getHeight(handlerParams.page);
if (Php_utl_.isset(handlerParams.height) && handlerParams.height != -1) { if (XophpUtility.isset(handlerParams.height) && handlerParams.height != -1) {
// Height & width were both set // Height & width were both set
if (handlerParams.width * srcHeight > handlerParams.height * srcWidth) { if (handlerParams.width * srcHeight > handlerParams.height * srcWidth) {
// Height is the relative smaller dimension, so scale width accordingly // Height is the relative smaller dimension, so scale width accordingly
@ -131,11 +130,11 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
handlerParams.physicalWidth = handlerParams.width; handlerParams.physicalWidth = handlerParams.width;
} else { } else {
// Height was crap, unset it so that it will be calculated later // Height was crap, unset it so that it will be calculated later
handlerParams.height = Php_utl_.Null_int; handlerParams.height = XophpUtility.Null_int;
} }
} }
if (!Php_utl_.isset(handlerParams.physicalWidth)) { if (!XophpUtility.isset(handlerParams.physicalWidth)) {
// Passed all validations, so set the physicalWidth // Passed all validations, so set the physicalWidth
handlerParams.physicalWidth = handlerParams.width; handlerParams.physicalWidth = handlerParams.width;
} }
@ -147,7 +146,7 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
handlerParams.physicalWidth); handlerParams.physicalWidth);
// Set the height if it was not validated in the if block higher up // Set the height if it was not validated in the if block higher up
if (!Php_utl_.isset(handlerParams.height) || handlerParams.height == -1) { if (!XophpUtility.isset(handlerParams.height) || handlerParams.height == -1) {
handlerParams.height = handlerParams.physicalHeight; handlerParams.height = handlerParams.physicalHeight;
} }

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import org.junit.*; import gplx.core.tests.*; import org.junit.*; import gplx.core.tests.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*; import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.filerepo.*; import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.filerepo.*; import gplx.xowa.mediawiki.includes.filerepo.file.*;
public class XomwImageHandlerTest { public class XomwImageHandlerTest {
@ -36,7 +35,7 @@ class XomwImageHandler_fxt {
public XomwImageHandler_fxt() { public XomwImageHandler_fxt() {
handler = new XomwTransformationalImageHandler(Bry_.new_a7("test_handler")); handler = new XomwTransformationalImageHandler(Bry_.new_a7("test_handler"));
} }
public Xomw_params_handler Make__handlerParams(int w) {return Make__handlerParams(w, Php_utl_.Null_int, Php_utl_.Null_int, Php_utl_.Null_int);} public Xomw_params_handler Make__handlerParams(int w) {return Make__handlerParams(w, XophpUtility.Null_int, XophpUtility.Null_int, XophpUtility.Null_int);}
public Xomw_params_handler Make__handlerParams(int w, int h, int phys_w, int phys_h) { public Xomw_params_handler Make__handlerParams(int w, int h, int phys_w, int phys_h) {
Xomw_params_handler rv = new Xomw_params_handler(); Xomw_params_handler rv = new Xomw_params_handler();
rv.width = w; rv.width = w;

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.parsers.lnkis.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.filerepo.file.*;
public abstract class XomwMediaTransformOutput { public abstract class XomwMediaTransformOutput {

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.parsers.lnkis.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.filerepo.file.*;
// Media transform output for images // Media transform output for images
@ -136,71 +135,71 @@ public class XomwThumbnailImage extends XomwMediaTransformOutput { private final
attribs.Add_many(Gfh_atr_.Bry__alt, alt); attribs.Add_many(Gfh_atr_.Bry__alt, alt);
attribs.Add_many(Gfh_atr_.Bry__src, url); attribs.Add_many(Gfh_atr_.Bry__src, url);
boolean link_attribs_is_null = false; boolean link_attribs_is_null = false;
if (!Php_utl_.empty(options.custom_url_link)) { if (!XophpUtility.empty(options.custom_url_link)) {
link_attribs.Clear(); link_attribs.Clear();
link_attribs.Add_many(Gfh_atr_.Bry__href, options.custom_url_link); link_attribs.Add_many(Gfh_atr_.Bry__href, options.custom_url_link);
if (!Php_utl_.empty(options.title)) { if (!XophpUtility.empty(options.title)) {
link_attribs.Add_many(Gfh_atr_.Bry__title, options.title); link_attribs.Add_many(Gfh_atr_.Bry__title, options.title);
} }
if (Php_utl_.empty(options.custom_target_link)) { if (XophpUtility.empty(options.custom_target_link)) {
link_attribs.Add_many(Gfh_atr_.Bry__target, options.custom_target_link); link_attribs.Add_many(Gfh_atr_.Bry__target, options.custom_target_link);
} }
else if (Php_utl_.empty(options.parser_extlink_target)) { else if (XophpUtility.empty(options.parser_extlink_target)) {
link_attribs.Add_many(Gfh_atr_.Bry__target, options.parser_extlink_target); link_attribs.Add_many(Gfh_atr_.Bry__target, options.parser_extlink_target);
} }
if (Php_utl_.empty(options.parser_extlink_rel)) { if (XophpUtility.empty(options.parser_extlink_rel)) {
link_attribs.Add_many(Gfh_atr_.Bry__rel, options.parser_extlink_rel); link_attribs.Add_many(Gfh_atr_.Bry__rel, options.parser_extlink_rel);
} }
} }
else if (!Php_utl_.empty(options.custom_title_link)) { else if (!XophpUtility.empty(options.custom_title_link)) {
// byte[] title = options.custom_title_link; // byte[] title = options.custom_title_link;
// link_attribs.Clear(); // link_attribs.Clear();
// link_attribs.Add_many(Gfh_atr_.Bry__href, title.Get_link_url()); // link_attribs.Add_many(Gfh_atr_.Bry__href, title.Get_link_url());
// byte[] options_title = options.title; // byte[] options_title = options.title;
// link_attribs.Add_many(Gfh_atr_.Bry__title, Php_utl_.empty(options_title) ? title.Get_full_text() : options_title); // link_attribs.Add_many(Gfh_atr_.Bry__title, XophpUtility.empty(options_title) ? title.Get_full_text() : options_title);
} }
else if (!Php_utl_.empty(options.desc_link)) { else if (!XophpUtility.empty(options.desc_link)) {
// link_attribs = this.getDescLinkAttribs( // link_attribs = this.getDescLinkAttribs(
// empty(options['title']) ? null : options['title'], // empty(options['title']) ? null : options['title'],
// $query // $query
// ); // );
link_attribs.Clear(); link_attribs.Clear();
this.getDescLinkAttribs(link_attribs, this.getDescLinkAttribs(link_attribs,
Php_utl_.empty(options.title) ? null : options.title, XophpUtility.empty(options.title) ? null : options.title,
null); null);
} }
else if (!Php_utl_.empty(options.file_link)) { else if (!XophpUtility.empty(options.file_link)) {
// link_attribs.Clear(); // link_attribs.Clear();
// link_attribs.Add_many(Gfh_atr_.Bry__href, file.Get_url()); // link_attribs.Add_many(Gfh_atr_.Bry__href, file.Get_url());
} }
else { else {
link_attribs_is_null = true; link_attribs_is_null = true;
if (!Php_utl_.empty(options.title)) { if (!XophpUtility.empty(options.title)) {
attribs.Add_many(Gfh_atr_.Bry__title, options.title); attribs.Add_many(Gfh_atr_.Bry__title, options.title);
} }
} }
if (Php_utl_.empty(options.no_dimensions)) { if (XophpUtility.empty(options.no_dimensions)) {
attribs.Add_many(Gfh_atr_.Bry__width, Int_.To_bry(width)); attribs.Add_many(Gfh_atr_.Bry__width, Int_.To_bry(width));
attribs.Add_many(Gfh_atr_.Bry__height, Int_.To_bry(height)); attribs.Add_many(Gfh_atr_.Bry__height, Int_.To_bry(height));
} }
if (!Php_utl_.empty(options.valign)) { if (!XophpUtility.empty(options.valign)) {
attribs.Add_many(Gfh_atr_.Bry__style, Bry_.Add(Bry__vertical_align, options.valign)); attribs.Add_many(Gfh_atr_.Bry__style, Bry_.Add(Bry__vertical_align, options.valign));
} }
if (!Php_utl_.empty(options.img_cls)) { if (!XophpUtility.empty(options.img_cls)) {
attribs.Add_many(Gfh_atr_.Bry__class, options.img_cls); attribs.Add_many(Gfh_atr_.Bry__class, options.img_cls);
} }
if (Php_utl_.isset(options.override_height)) { if (XophpUtility.isset(options.override_height)) {
attribs.Add_many(Gfh_atr_.Bry__class, options.override_height); attribs.Add_many(Gfh_atr_.Bry__class, options.override_height);
} }
if (Php_utl_.isset(options.override_width)) { if (XophpUtility.isset(options.override_width)) {
attribs.Add_many(Gfh_atr_.Bry__width, options.override_height); attribs.Add_many(Gfh_atr_.Bry__width, options.override_height);
} }
// Additional densities for responsive images, if specified. // Additional densities for responsive images, if specified.
// If any of these urls is the same as src url, it'll be excluded. // If any of these urls is the same as src url, it'll be excluded.
// $responsiveUrls = array_diff(this.responsiveUrls, [ this.url ]); // $responsiveUrls = array_diff(this.responsiveUrls, [ this.url ]);
// if (!Php_utl_.empty($responsiveUrls)) { // if (!XophpUtility.empty($responsiveUrls)) {
// $attribs['srcset'] = Html::srcSet($responsiveUrls); // $attribs['srcset'] = Html::srcSet($responsiveUrls);
// } // }

View File

@ -16,7 +16,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.mediawiki.includes.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.*;
import gplx.xowa.mediawiki.includes.utls.*;
public class Xomw_block_level_pass { public class Xomw_block_level_pass {
private final Bry_bfr tmp = Bry_bfr_.New(); private final Bry_bfr tmp = Bry_bfr_.New();
private final Btrie_rv trv = new Btrie_rv(); private final Btrie_rv trv = new Btrie_rv();
@ -106,8 +105,8 @@ public class Xomw_block_level_pass {
// If not in a <pre> element, scan for and figure out what prefixes are there. // If not in a <pre> element, scan for and figure out what prefixes are there.
if (!in_pre) { if (!in_pre) {
// Multiple prefixes may abut each other for nested lists. // Multiple prefixes may abut each other for nested lists.
prefix_len = Php_str_.Strspn_fwd__ary(src, block_chars_ary, line_bgn, line_end, line_end); // strspn($oLine, '*#:;'); prefix_len = XophpString.strspn_fwd__ary(src, block_chars_ary, line_bgn, line_end, line_end); // strspn($oLine, '*#:;');
prefix = Php_str_.Substr(src, line_bgn, prefix_len); prefix = XophpString.substr(src, line_bgn, prefix_len);
// eh? // eh?
// ; and : are both from definition-lists, so they're equivalent // ; and : are both from definition-lists, so they're equivalent
@ -130,7 +129,7 @@ public class Xomw_block_level_pass {
int common_prefix_len = -1; int common_prefix_len = -1;
if (prefix_len > 0 && Bry_.Eq(last_prefix, prefix2)) { if (prefix_len > 0 && Bry_.Eq(last_prefix, prefix2)) {
// Same as the last item, so no need to deal with nesting or opening stuff // Same as the last item, so no need to deal with nesting or opening stuff
bfr.Add(Next_item(Php_str_.Substr_byte(prefix, -1))); bfr.Add(Next_item(XophpString.substr_byte(prefix, -1)));
para_stack = Para_stack__none; para_stack = Para_stack__none;
if (prefix_len > 0 && prefix[prefix_len - 1] == Byte_ascii.Semic) { if (prefix_len > 0 && prefix[prefix_len - 1] == Byte_ascii.Semic) {
@ -170,7 +169,7 @@ public class Xomw_block_level_pass {
bfr.Add_byte_nl(); bfr.Add_byte_nl();
} }
while (prefix_len > common_prefix_len) { while (prefix_len > common_prefix_len) {
byte c = Php_str_.Substr_byte(prefix, common_prefix_len, 1); byte c = XophpString.substr_byte(prefix, common_prefix_len, 1);
bfr.Add(Open_list(c)); bfr.Add(Open_list(c));
if (c == Byte_ascii.Semic) { if (c == Byte_ascii.Semic) {
@ -195,8 +194,8 @@ public class Xomw_block_level_pass {
// No prefix (not in list)--go to paragraph mode // No prefix (not in list)--go to paragraph mode
// XXX: use a stack for nestable elements like span, table and div // XXX: use a stack for nestable elements like span, table and div
int t_len = t.length; int t_len = t.length;
boolean open_match = Php_preg_.Match(open_match_trie, trv, t, 0, t_len) != null; boolean open_match = XophpPreg.match(open_match_trie, trv, t, 0, t_len) != null;
boolean close_match = Php_preg_.Match(close_match_trie, trv, t, 0, t_len) != null; boolean close_match = XophpPreg.match(close_match_trie, trv, t, 0, t_len) != null;
if (open_match || close_match) { if (open_match || close_match) {
para_stack = Para_stack__none; para_stack = Para_stack__none;
@ -208,7 +207,7 @@ public class Xomw_block_level_pass {
int bq_offset = 0; int bq_offset = 0;
// PORTED:preg_match('/<(\\/?)blockquote[\s>]/i', t, $bqMatch, PREG_OFFSET_CAPTURE, $bq_offset) // PORTED:preg_match('/<(\\/?)blockquote[\s>]/i', t, $bqMatch, PREG_OFFSET_CAPTURE, $bq_offset)
while (true) { while (true) {
Object o = Php_preg_.Match(blockquote_trie, trv, t, bq_offset, t_len); Object o = XophpPreg.match(blockquote_trie, trv, t, bq_offset, t_len);
if (o == null) { // no more blockquotes found; exit if (o == null) { // no more blockquotes found; exit
break; break;
} }
@ -221,7 +220,7 @@ public class Xomw_block_level_pass {
in_block_elem = !close_match; in_block_elem = !close_match;
} }
else if (!in_block_elem && !in_pre) { else if (!in_block_elem && !in_pre) {
if ( Php_str_.Substr_byte(t, 0) == Byte_ascii.Space if ( XophpString.substr_byte(t, 0) == Byte_ascii.Space
&& (last_section == Last_section__pre || Bry_.Trim(t) != Bry_.Empty) && (last_section == Last_section__pre || Bry_.Trim(t) != Bry_.Empty)
&& !in_blockquote && !in_blockquote
) { ) {
@ -391,17 +390,17 @@ public class Xomw_block_level_pass {
// to prevent illegal overlapping. // to prevent illegal overlapping.
private int Find_colon_no_links(byte[] str, byte[] before, byte[] after) { private int Find_colon_no_links(byte[] str, byte[] before, byte[] after) {
int len = str.length; int len = str.length;
int colon_pos = Php_str_.Strpos(str, Byte_ascii.Colon, 0, len); int colon_pos = XophpString.strpos(str, Byte_ascii.Colon, 0, len);
if (colon_pos == Bry_find_.Not_found) { if (colon_pos == Bry_find_.Not_found) {
// Nothing to find! // Nothing to find!
return Bry_find_.Not_found; return Bry_find_.Not_found;
} }
int lt_pos = Php_str_.Strpos(str, Byte_ascii.Angle_bgn, 0, len); int lt_pos = XophpString.strpos(str, Byte_ascii.Angle_bgn, 0, len);
if (lt_pos == Bry_find_.Not_found || lt_pos > colon_pos) { if (lt_pos == Bry_find_.Not_found || lt_pos > colon_pos) {
// Easy; no tag nesting to worry about // Easy; no tag nesting to worry about
find_colon_no_links__before = Php_str_.Substr(str, 0, colon_pos); find_colon_no_links__before = XophpString.substr(str, 0, colon_pos);
find_colon_no_links__after = Php_str_.Substr(str, colon_pos + 1); find_colon_no_links__after = XophpString.substr(str, colon_pos + 1);
return colon_pos; return colon_pos;
} }
@ -421,25 +420,25 @@ public class Xomw_block_level_pass {
case Byte_ascii.Colon: case Byte_ascii.Colon:
if (level == 0) { if (level == 0) {
// We found it! // We found it!
find_colon_no_links__before = Php_str_.Substr(str, 0, i); find_colon_no_links__before = XophpString.substr(str, 0, i);
find_colon_no_links__after = Php_str_.Substr(str, i + 1); find_colon_no_links__after = XophpString.substr(str, i + 1);
return i; return i;
} }
// Embedded in a tag; don't break it. // Embedded in a tag; don't break it.
break; break;
default: default:
// Skip ahead looking for something interesting // Skip ahead looking for something interesting
colon_pos = Php_str_.Strpos(str, Byte_ascii.Colon, i, len); colon_pos = XophpString.strpos(str, Byte_ascii.Colon, i, len);
if (colon_pos == Bry_find_.Not_found) { if (colon_pos == Bry_find_.Not_found) {
// Nothing else interesting // Nothing else interesting
return Bry_find_.Not_found; return Bry_find_.Not_found;
} }
lt_pos = Php_str_.Strpos(str, Byte_ascii.Angle_bgn, i, len); lt_pos = XophpString.strpos(str, Byte_ascii.Angle_bgn, i, len);
if (level == 0) { if (level == 0) {
if (lt_pos == Bry_find_.Not_found || colon_pos < lt_pos) { if (lt_pos == Bry_find_.Not_found || colon_pos < lt_pos) {
// We found it! // We found it!
find_colon_no_links__before = Php_str_.Substr(str, 0, colon_pos); find_colon_no_links__before = XophpString.substr(str, 0, colon_pos);
find_colon_no_links__after = Php_str_.Substr(str, colon_pos + 1); find_colon_no_links__after = XophpString.substr(str, colon_pos + 1);
return i; return i;
} }
} }

View File

@ -18,7 +18,7 @@ import gplx.core.btries.*; import gplx.core.net.*;
import gplx.xowa.mediawiki.includes.parsers.prepros.*; import gplx.xowa.mediawiki.includes.parsers.headings.*; import gplx.xowa.mediawiki.includes.parsers.prepros.*; import gplx.xowa.mediawiki.includes.parsers.headings.*;
import gplx.xowa.mediawiki.includes.parsers.quotes.*; import gplx.xowa.mediawiki.includes.parsers.tables.*; import gplx.xowa.mediawiki.includes.parsers.hrs.*; import gplx.xowa.mediawiki.includes.parsers.nbsps.*; import gplx.xowa.mediawiki.includes.parsers.quotes.*; import gplx.xowa.mediawiki.includes.parsers.tables.*; import gplx.xowa.mediawiki.includes.parsers.hrs.*; import gplx.xowa.mediawiki.includes.parsers.nbsps.*;
import gplx.xowa.mediawiki.includes.parsers.lnkes.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*; import gplx.xowa.mediawiki.includes.parsers.magiclinks.*; import gplx.xowa.mediawiki.includes.parsers.doubleunders.*; import gplx.xowa.mediawiki.includes.parsers.lnkes.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*; import gplx.xowa.mediawiki.includes.parsers.magiclinks.*; import gplx.xowa.mediawiki.includes.parsers.doubleunders.*;
import gplx.xowa.mediawiki.includes.utls.*; import gplx.xowa.mediawiki.includes.linkers.*; import gplx.xowa.mediawiki.includes.linkers.*;
import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.htmls.*;
public class Xomw_parser implements XomwParserIface { public class Xomw_parser implements XomwParserIface {
private final Xomw_parser_ctx pctx = new Xomw_parser_ctx(); private final Xomw_parser_ctx pctx = new Xomw_parser_ctx();

View File

@ -14,7 +14,6 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.hrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.hrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.utls.*;
public class Xomw_hr_wkr {// THREAD.UNSAFE: caching for repeated calls public class Xomw_hr_wkr {// THREAD.UNSAFE: caching for repeated calls
private Bry_bfr bfr; private Bry_bfr bfr;
public void replaceHrs(Xomw_parser_ctx pctx, Xomw_parser_bfr pbfr) { // REF.MW: text = preg_replace('/(^|\n)-----*/', '\\1<hr />', text); public void replaceHrs(Xomw_parser_ctx pctx, Xomw_parser_bfr pbfr) { // REF.MW: text = preg_replace('/(^|\n)-----*/', '\\1<hr />', text);

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.core.btries.*; import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.primitives.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.htmls.*;
/* TODO.XO /* TODO.XO
* P3: $langObj->formatNum( ++$this->mAutonumber ); * P3: $langObj->formatNum( ++$this->mAutonumber );
@ -165,7 +164,7 @@ public class Xomw_lnke_wkr {// THREAD.UNSAFE: caching for repeated calls
// The characters '<' and '>' (which were escaped by // The characters '<' and '>' (which were escaped by
// removeHTMLtags()) should not be included in // removeHTMLtags()) should not be included in
// URLs, per RFC 2396. // URLs, per RFC 2396.
if (Php_preg_.Match(angle_entities_trie, trv, src, url_bgn, url_end) != null) { if (XophpPreg.match(angle_entities_trie, trv, src, url_bgn, url_end) != null) {
int angle_bgn = trv.Match_bgn; int angle_bgn = trv.Match_bgn;
text_bgn = angle_bgn; text_bgn = angle_bgn;
url_end = angle_bgn; url_end = angle_bgn;

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.core.btries.*; import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.primitives.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.xwikis.*;
import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.parsers.quotes.*; import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.parsers.quotes.*;
import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.linkers.*; import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.linkers.*;
@ -70,7 +69,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
this.env = env; this.env = env;
this.wiki = wiki; this.wiki = wiki;
if (title_chars_for_lnki == null) { if (title_chars_for_lnki == null) {
title_chars_for_lnki = (boolean[])Array_.Clone(Xomw_ttl_utl.Title_chars_valid()); title_chars_for_lnki = (boolean[])Array_.Clone(XomwTitle.Title_chars_valid());
// the % is needed to support urlencoded titles as well // the % is needed to support urlencoded titles as well
title_chars_for_lnki[Byte_ascii.Hash] = true; title_chars_for_lnki[Byte_ascii.Hash] = true;
title_chars_for_lnki[Byte_ascii.Percent] = true; title_chars_for_lnki[Byte_ascii.Percent] = true;
@ -156,7 +155,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// PORTED.BGN: if (preg_match($e1, $line, $m)) && else if (preg_match($e1_img, $line, $m)) // PORTED.BGN: if (preg_match($e1, $line, $m)) && else if (preg_match($e1_img, $line, $m))
// NOTE: both e1 and e1_img are effectively the same; e1_img allows nested "[["; EX: "[[A|b[[c]]d]]" will stop at "[[A|b" // NOTE: both e1 and e1_img are effectively the same; e1_img allows nested "[["; EX: "[[A|b[[c]]d]]" will stop at "[[A|b"
int ttl_bgn = cur; int ttl_bgn = cur;
int ttl_end = Xomw_ttl_utl.Find_fwd_while_title(src, cur, src_end, title_chars_for_lnki); int ttl_end = XomwTitle.Find_fwd_while_title(src, cur, src_end, title_chars_for_lnki);
cur = ttl_end; cur = ttl_end;
int capt_bgn = -1, capt_end = -1; int capt_bgn = -1, capt_end = -1;
int nxt_lnki = -1; int nxt_lnki = -1;
@ -590,7 +589,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
break; break;
default: default:
// Most other things appear to be empty or numeric... // Most other things appear to be empty or numeric...
validated = (val == null || Php_utl_.isnumeric(Bry_.Trim(val))); validated = (val == null || XophpUtility.isnumeric(Bry_.Trim(val)));
break; break;
} }
} }
@ -725,7 +724,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// Parsed a width param of imagelink like 300px or 200x300px // Parsed a width param of imagelink like 300px or 200x300px
// XO.MW.NOTE: for MW, "" -> null, null while "AxB" -> 0x0 // XO.MW.NOTE: for MW, "" -> null, null while "AxB" -> 0x0
public void parseWidthParam(int[] img_size, byte[] src) { public void parseWidthParam(int[] img_size, byte[] src) {
img_size[0] = img_size[1] = Php_utl_.Null_int; img_size[0] = img_size[1] = XophpUtility.Null_int;
if (src == Bry_.Empty) { if (src == Bry_.Empty) {
return; return;
} }

View File

@ -14,7 +14,6 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.utls.*;
public class Xomw_params_frame { public class Xomw_params_frame {
public byte[] align = null; public byte[] align = null;
public byte[] valign = null; public byte[] valign = null;
@ -45,12 +44,12 @@ public class Xomw_params_frame {
} }
public Xomw_params_frame Clear() { public Xomw_params_frame Clear() {
desc_link = false; desc_link = false;
upright = Php_utl_.Null_double; upright = XophpUtility.Null_double;
align = valign = caption = frame = framed = frameless align = valign = caption = frame = framed = frameless
= thumbnail = manualthumb = alt = title = cls = img_cls = thumbnail = manualthumb = alt = title = cls = img_cls
= link_title = link_url = link_target = no_link = link_title = link_url = link_target = no_link
= custom_url_link = custom_target_link = desc_query = custom_url_link = custom_target_link = desc_query
= Php_utl_.Null_bry; = XophpUtility.Null_bry;
return this; return this;
} }
public void Copy_to(Xomw_params_frame src) { public void Copy_to(Xomw_params_frame src) {

View File

@ -14,7 +14,6 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.utls.*;
public class Xomw_params_handler { public class Xomw_params_handler {
public int width; public int width;
public int height; public int height;
@ -23,7 +22,7 @@ public class Xomw_params_handler {
public int physicalHeight; public int physicalHeight;
public Xomw_params_handler Clear() { public Xomw_params_handler Clear() {
width = height = page width = height = page
= physicalWidth = physicalHeight = Php_utl_.Null_int; = physicalWidth = physicalHeight = XophpUtility.Null_int;
return this; return this;
} }
public void Copy_to(Xomw_params_handler src) { public void Copy_to(Xomw_params_handler src) {

View File

@ -14,7 +14,6 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.utls.*;
public class Xomw_params_scalar { public class Xomw_params_scalar {
public int physicalWidth; public int physicalWidth;
public int physicalHeight; public int physicalHeight;
@ -29,6 +28,6 @@ public class Xomw_params_scalar {
public byte[] dstUrl; public byte[] dstUrl;
public byte[] interlace; public byte[] interlace;
public Xomw_params_scalar() { public Xomw_params_scalar() {
physicalWidth = physicalHeight = clientWidth = clientHeight = srcWidth = srcHeight = Php_utl_.Null_int; physicalWidth = physicalHeight = clientWidth = clientHeight = srcWidth = srcHeight = XophpUtility.Null_int;
} }
} }

View File

@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.magiclinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.magiclinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.net.*; import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.net.*;
import gplx.xowa.mediawiki.includes.utls.*; import gplx.xowa.mediawiki.includes.htmls.*; import gplx.xowa.mediawiki.includes.htmls.*;
import gplx.langs.regxs.*; import gplx.langs.regxs.*;
// TODO.XO: this->getConverterLanguage()->markNoConversion($url, true), // TODO.XO: this->getConverterLanguage()->markNoConversion($url, true),
public class Xomw_magiclinks_wkr { public class Xomw_magiclinks_wkr {
@ -224,12 +224,12 @@ public class Xomw_magiclinks_wkr {
// XO.MW: if (strpos($url, '(') === false) {$sep .= ')';} // XO.MW: if (strpos($url, '(') === false) {$sep .= ')';}
url_separators[Byte_ascii.Paren_end] = Bry_find_.Find_fwd(url, Byte_ascii.Paren_bgn, 0, url_len) == Bry_find_.Not_found; url_separators[Byte_ascii.Paren_end] = Bry_find_.Find_fwd(url, Byte_ascii.Paren_bgn, 0, url_len) == Bry_find_.Not_found;
int num_sep_chars = Php_str_.Strspn_bwd__ary(url, url_separators, url_len, -1); int num_sep_chars = XophpString.strspn_bwd__ary(url, url_separators, url_len, -1);
// Don't break a trailing HTML entity by moving the ; into $trail // Don't break a trailing HTML entity by moving the ; into $trail
// This is in hot code, so use substr_compare to avoid having to // This is in hot code, so use substr_compare to avoid having to
// create a new String Object for the comparison // create a new String Object for the comparison
// XO.MW.NOTE: ignore semic if part of entity; EX: "http://a.org&apos;!." // XO.MW.NOTE: ignore semic if part of entity; EX: "http://a.org&apos;!."
if (num_sep_chars > 0 && Php_str_.Substr_byte(url, -num_sep_chars) == Byte_ascii.Semic) { if (num_sep_chars > 0 && XophpString.substr_byte(url, -num_sep_chars) == Byte_ascii.Semic) {
// more optimization: instead of running preg_match with a $ // more optimization: instead of running preg_match with a $
// anchor, which can be slow, do the match on the reversed // anchor, which can be slow, do the match on the reversed
// String starting at the desired offset. // String starting at the desired offset.
@ -241,8 +241,8 @@ public class Xomw_magiclinks_wkr {
} }
if (num_sep_chars > 0) { if (num_sep_chars > 0) {
trail = Bry_.Add(Php_str_.Substr(url, -num_sep_chars), trail); trail = Bry_.Add(XophpString.substr(url, -num_sep_chars), trail);
url = Php_str_.Substr(url, 0, -num_sep_chars); url = XophpString.substr(url, 0, -num_sep_chars);
} }
// Verify that we still have a real URL after trail removal, and // Verify that we still have a real URL after trail removal, and

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.prepros; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.prepros; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.xowa.mediawiki.includes.utls.*;
public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
private final Bry_bfr tmp_bfr = Bry_bfr_.New(); private final Bry_bfr tmp_bfr = Bry_bfr_.New();
private final List_adp comments_list = List_adp_.New(); private final List_adp comments_list = List_adp_.New();
@ -287,11 +286,11 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
} }
else { else {
// Search backwards for leading whitespace // Search backwards for leading whitespace
int ws_bgn = i > 0 ? i - Php_str_.Strspn_bwd__space_or_tab(src, i, -1) : 0; int ws_bgn = i > 0 ? i - XophpString.strspn_bwd__space_or_tab(src, i, -1) : 0;
// Search forwards for trailing whitespace // Search forwards for trailing whitespace
// $wsEnd will be the position of the last space (or the '>' if there's none) // $wsEnd will be the position of the last space (or the '>' if there's none)
int ws_end = end_pos + 2 + Php_str_.Strspn_fwd__space_or_tab(src, end_pos + 3, -1, src_len); int ws_end = end_pos + 2 + XophpString.strspn_fwd__space_or_tab(src, end_pos + 3, -1, src_len);
// Keep looking forward as long as we're finding more // Keep looking forward as long as we're finding more
// comments. // comments.
@ -302,7 +301,7 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
if (cur_char_pos == Bry_find_.Not_found) { if (cur_char_pos == Bry_find_.Not_found) {
break; break;
} }
cur_char_pos = cur_char_pos + 2 + Php_str_.Strspn_fwd__space_or_tab(src, cur_char_pos + 3, -1, src_len); cur_char_pos = cur_char_pos + 2 + XophpString.strspn_fwd__space_or_tab(src, cur_char_pos + 3, -1, src_len);
comments_list.Add(new int[] {ws_end + 1, cur_char_pos}); comments_list.Add(new int[] {ws_end + 1, cur_char_pos});
ws_end = cur_char_pos; ws_end = cur_char_pos;
} }
@ -321,7 +320,7 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
int ws_len = i - ws_bgn; int ws_len = i - ws_bgn;
int accum_len = accum.Len(); int accum_len = accum.Len();
if ( ws_len > 0 if ( ws_len > 0
&& Php_str_.Strspn_fwd__space_or_tab(accum.Bfr(), accum_len - ws_len, -1, accum_len) == ws_len) { && XophpString.strspn_fwd__space_or_tab(accum.Bfr(), accum_len - ws_len, -1, accum_len) == ws_len) {
accum.Del_by(ws_len); accum.Del_by(ws_len);
} }
@ -487,7 +486,7 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
i++; i++;
} }
int count = Php_str_.Strspn_fwd__byte(src, Byte_ascii.Eq, i, 6, src_len); int count = XophpString.strspn_fwd__byte(src, Byte_ascii.Eq, i, 6, src_len);
if (count == 1 && find_equals) { // EX: "{{a|\n=b=\n" if (count == 1 && find_equals) { // EX: "{{a|\n=b=\n"
// DWIM: This looks kind of like a name/value separator. // DWIM: This looks kind of like a name/value separator.
// Let's let the equals handler have it and break the // Let's let the equals handler have it and break the
@ -516,7 +515,7 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
// Search back through the input to see if it has a proper close. // Search back through the input to see if it has a proper close.
// Do this using the reversed String since the other solutions // Do this using the reversed String since the other solutions
// (end anchor, etc.) are inefficient. // (end anchor, etc.) are inefficient.
int ws_len = Php_str_.Strspn_bwd__space_or_tab(src, src_len - i, -1); int ws_len = XophpString.strspn_bwd__space_or_tab(src, src_len - i, -1);
int search_bgn = i - ws_len; int search_bgn = i - ws_len;
if (part.comment_end != -1 && search_bgn -1 == part.comment_end) { if (part.comment_end != -1 && search_bgn -1 == part.comment_end) {
@ -524,10 +523,10 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
// Search for equals signs before the comment // Search for equals signs before the comment
search_bgn = part.visual_end; search_bgn = part.visual_end;
search_bgn = Bry_find_.Find_bwd__while_space_or_tab(src, search_bgn, 0); search_bgn = Bry_find_.Find_bwd__while_space_or_tab(src, search_bgn, 0);
search_bgn -= Php_str_.Strspn_bwd__space_or_tab(src, search_bgn, -1); search_bgn -= XophpString.strspn_bwd__space_or_tab(src, search_bgn, -1);
} }
int count = piece.count; int count = piece.count;
int eq_len = Php_str_.Strspn_bwd__byte(src, Byte_ascii.Eq, search_bgn, -1); int eq_len = XophpString.strspn_bwd__byte(src, Byte_ascii.Eq, search_bgn, -1);
byte[] element = Bry_.Empty; byte[] element = Bry_.Empty;
if (eq_len > 0) { if (eq_len > 0) {
@ -580,7 +579,7 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
} }
else if (found == Found__open) { else if (found == Found__open) {
// count opening brace characters // count opening brace characters
int count = Php_str_.Strspn_fwd__byte(src, cur_char[0], i, -1, src_len); // NOTE: don't know how MediaWiki will handle "-{" int count = XophpString.strspn_fwd__byte(src, cur_char[0], i, -1, src_len); // NOTE: don't know how MediaWiki will handle "-{"
// we need to add to stack only if opening brace count is enough for one of the rules // we need to add to stack only if opening brace count is enough for one of the rules
if (count >= rule.min) { if (count >= rule.min) {
@ -605,7 +604,7 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
Xomw_prepro_piece piece = stack.top; Xomw_prepro_piece piece = stack.top;
// lets check if there are enough characters for closing brace // lets check if there are enough characters for closing brace
int max_count = piece.count; int max_count = piece.count;
int count = Php_str_.Strspn_fwd__byte(src, cur_char[0], i, max_count, src_len); int count = XophpString.strspn_fwd__byte(src, cur_char[0], i, max_count, src_len);
// check for maximum matching characters (if there are 5 closing characters, we will probably need only 3 - depending on the rules) // check for maximum matching characters (if there are 5 closing characters, we will probably need only 3 - depending on the rules)
rule = Get_rule(piece.open); rule = Get_rule(piece.open);

View File

@ -14,7 +14,6 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.quotes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.quotes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.htmls.*;
import gplx.core.primitives.*; import gplx.core.primitives.*;
public class Xomw_quote_wkr {// THREAD.UNSAFE: caching for repeated calls public class Xomw_quote_wkr {// THREAD.UNSAFE: caching for repeated calls
@ -54,7 +53,7 @@ public class Xomw_quote_wkr {// THREAD.UNSAFE: caching for repeated calls
return found ? tmp.To_bry_and_clear() : src; return found ? tmp.To_bry_and_clear() : src;
} }
private boolean Do_quotes(Bry_bfr bfr, boolean all_quotes_mode, byte[] src, int line_bgn, int line_end) { private boolean Do_quotes(Bry_bfr bfr, boolean all_quotes_mode, byte[] src, int line_bgn, int line_end) {
byte[][] arr = Php_preg_.Split(apos_pos_ary, src, line_bgn, line_end, Wtxt__apos, Bool_.Y); // PORTED.REGX: arr = preg_split("/(''+)/", text, -1, PREG_SPLIT_DELIM_CAPTURE); byte[][] arr = XophpPreg.split(apos_pos_ary, src, line_bgn, line_end, Wtxt__apos, Bool_.Y); // PORTED.REGX: arr = preg_split("/(''+)/", text, -1, PREG_SPLIT_DELIM_CAPTURE);
if (arr == null) { if (arr == null) {
if (all_quotes_mode) { if (all_quotes_mode) {
bfr.Add_mid(src, line_bgn, line_end).Add_byte_nl(); bfr.Add_mid(src, line_bgn, line_end).Add_byte_nl();
@ -111,8 +110,8 @@ public class Xomw_quote_wkr {// THREAD.UNSAFE: caching for repeated calls
for (int i = 1; i < arr_len; i += 2) { for (int i = 1; i < arr_len; i += 2) {
if (arr[i].length == 3) { if (arr[i].length == 3) {
byte[] prv = arr[i - 1]; byte[] prv = arr[i - 1];
byte prv__last_char = Php_str_.Substr_byte(prv, -1); byte prv__last_char = XophpString.substr_byte(prv, -1);
byte prv__last_minus_1_char = Php_str_.Substr_byte(prv, -2, 1); byte prv__last_minus_1_char = XophpString.substr_byte(prv, -2, 1);
if (prv__last_char == Byte_ascii.Space) { // NOTE: prv ends in space; EX: "''prv '''" if (prv__last_char == Byte_ascii.Space) { // NOTE: prv ends in space; EX: "''prv '''"
if (prv_ends_w_space == -1) { if (prv_ends_w_space == -1) {
prv_ends_w_space = i; prv_ends_w_space = i;

View File

@ -14,7 +14,6 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.tables; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.tables; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.htmls.*;
import gplx.xowa.mediawiki.includes.libs.*; import gplx.xowa.parsers.uniqs.*; import gplx.xowa.mediawiki.includes.libs.*; import gplx.xowa.parsers.uniqs.*;
public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.UNSAFE: caching for repeated calls public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.UNSAFE: caching for repeated calls
@ -49,13 +48,13 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
// Closing open td, tr && table // Closing open td, tr && table
while (td_history.Len() > 0) { while (td_history.Len() > 0) {
if (Php_ary_.Pop_bool_or_n(td_history)) { if (XophpArray.popBoolOrN(td_history)) {
bfr.Add_str_a7("</td>\n"); bfr.Add_str_a7("</td>\n");
} }
if (Php_ary_.Pop_bool_or_n(tr_history)) { if (XophpArray.popBoolOrN(tr_history)) {
bfr.Add_str_a7("</tr>\n"); bfr.Add_str_a7("</tr>\n");
} }
if (!Php_ary_.Pop_bool_or_n(has_opened_tr)) { if (!XophpArray.popBoolOrN(has_opened_tr)) {
bfr.Add_str_a7("<tr><td></td></tr>\n"); bfr.Add_str_a7("<tr><td></td></tr>\n");
} }
bfr.Add_str_a7("</table>\n"); bfr.Add_str_a7("</table>\n");
@ -124,20 +123,20 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
else if (Bry_.Eq(first_2, Wtxt__tb__end)) { else if (Bry_.Eq(first_2, Wtxt__tb__end)) {
// We are ending a table // We are ending a table
line = tmp.Add_str_a7("</table>").Add_mid(line, 2, line.length).To_bry_and_clear(); line = tmp.Add_str_a7("</table>").Add_mid(line, 2, line.length).To_bry_and_clear();
byte[] last_tag = Php_ary_.Pop_bry_or_null(last_tag_history); byte[] last_tag = XophpArray.popBryOrNull(last_tag_history);
if (!Php_ary_.Pop_bool_or_n(has_opened_tr)) { if (!XophpArray.popBoolOrN(has_opened_tr)) {
line = tmp.Add_str_a7("<tr><td></td></tr>").Add(line).To_bry_and_clear(); line = tmp.Add_str_a7("<tr><td></td></tr>").Add(line).To_bry_and_clear();
} }
if (Php_ary_.Pop_bool_or_n(tr_history)) { if (XophpArray.popBoolOrN(tr_history)) {
line = tmp.Add_str_a7("</tr>").Add(line).To_bry_and_clear(); line = tmp.Add_str_a7("</tr>").Add(line).To_bry_and_clear();
} }
if (Php_ary_.Pop_bool_or_n(td_history)) { if (XophpArray.popBoolOrN(td_history)) {
line = tmp.Add_str_a7("</").Add(last_tag).Add_byte(Byte_ascii.Angle_end).Add(line).To_bry_and_clear(); line = tmp.Add_str_a7("</").Add(last_tag).Add_byte(Byte_ascii.Angle_end).Add(line).To_bry_and_clear();
} }
Php_ary_.Pop_bry_or_null(tr_attributes); XophpArray.popBryOrNull(tr_attributes);
// PORTED:$outLine = $line . str_repeat( '</dd></dl>', $indent_level ); // PORTED:$outLine = $line . str_repeat( '</dd></dl>', $indent_level );
tmp.Add(line); tmp.Add(line);
for (int j = 0; j < indent_level; j++) for (int j = 0; j < indent_level; j++)
@ -153,19 +152,19 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
sanitizer.fixTagAttributes(tmp, Name__tr, atrs); sanitizer.fixTagAttributes(tmp, Name__tr, atrs);
atrs = tmp.To_bry_and_clear(); atrs = tmp.To_bry_and_clear();
Php_ary_.Pop_bry_or_null(tr_attributes); XophpArray.popBryOrNull(tr_attributes);
tr_attributes.Add(atrs); tr_attributes.Add(atrs);
line = Bry_.Empty; line = Bry_.Empty;
byte[] last_tag = Php_ary_.Pop_bry_or_null(last_tag_history); byte[] last_tag = XophpArray.popBryOrNull(last_tag_history);
Php_ary_.Pop_bool_or_n(has_opened_tr); XophpArray.popBoolOrN(has_opened_tr);
has_opened_tr.Add(true); has_opened_tr.Add(true);
if (Php_ary_.Pop_bool_or_n(tr_history)) { if (XophpArray.popBoolOrN(tr_history)) {
line = Html__tr__end; line = Html__tr__end;
} }
if (Php_ary_.Pop_bool_or_n(td_history)) { if (XophpArray.popBoolOrN(td_history)) {
line = tmp.Add_str_a7("</").Add(last_tag).Add_byte(Byte_ascii.Gt).Add(line).To_bry_and_clear(); line = tmp.Add_str_a7("</").Add(last_tag).Add_byte(Byte_ascii.Gt).Add(line).To_bry_and_clear();
} }
@ -206,19 +205,19 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
byte[] cell = cells[j]; byte[] cell = cells[j];
previous = Bry_.Empty; previous = Bry_.Empty;
if (first_char != Byte_ascii.Plus) { if (first_char != Byte_ascii.Plus) {
byte[] tr_after = Php_ary_.Pop_bry_or_null(tr_attributes); byte[] tr_after = XophpArray.popBryOrNull(tr_attributes);
if (!Php_ary_.Pop_bool_or_n(tr_history)) { if (!XophpArray.popBoolOrN(tr_history)) {
previous = tmp.Add_str_a7("<tr").Add(tr_after).Add_str_a7(">\n").To_bry_and_clear(); previous = tmp.Add_str_a7("<tr").Add(tr_after).Add_str_a7(">\n").To_bry_and_clear();
} }
tr_history.Add(true); tr_history.Add(true);
tr_attributes.Add(Bry_.Empty); tr_attributes.Add(Bry_.Empty);
Php_ary_.Pop_bool_or_n(has_opened_tr); XophpArray.popBoolOrN(has_opened_tr);
has_opened_tr.Add(true); has_opened_tr.Add(true);
} }
byte[] last_tag = Php_ary_.Pop_bry_or_null(last_tag_history); byte[] last_tag = XophpArray.popBryOrNull(last_tag_history);
if (Php_ary_.Pop_bool_or_n(td_history)) { if (XophpArray.popBoolOrN(td_history)) {
previous = tmp.Add_str_a7("</").Add(last_tag).Add_str_a7(">\n").Add(previous).To_bry_and_clear(); previous = tmp.Add_str_a7("</").Add(last_tag).Add_str_a7(">\n").Add(previous).To_bry_and_clear();
} }

View File

@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.title; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.title; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.xowa.mediawiki.languages.*; import gplx.xowa.mediawiki.languages.*;
import gplx.xowa.mediawiki.includes.utls.*;
public class XomwMediaWikiTitleCodec implements XomwTitleFormatter { public class XomwMediaWikiTitleCodec implements XomwTitleFormatter {
/** /**
* @var Language * @var Language
@ -235,7 +234,7 @@ public class XomwMediaWikiTitleCodec implements XomwTitleFormatter {
* 'user_case_dbkey', and 'dbkey'. * 'user_case_dbkey', and 'dbkey'.
*/ */
public XomwMediaWikiTitleCodecParts splitTitleString(byte[] text, int defaultNamespace) { public XomwMediaWikiTitleCodecParts splitTitleString(byte[] text, int defaultNamespace) {
byte[] dbkey = Php_str_.str_replace(Byte_ascii.Space, Byte_ascii.Underline, text); byte[] dbkey = XophpString.str_replace(Byte_ascii.Space, Byte_ascii.Underline, text);
// Initialisation // Initialisation
XomwMediaWikiTitleCodecParts parts = new XomwMediaWikiTitleCodecParts(dbkey, defaultNamespace); XomwMediaWikiTitleCodecParts parts = new XomwMediaWikiTitleCodecParts(dbkey, defaultNamespace);

View File

@ -1,31 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import org.junit.*; import gplx.core.tests.*;
public class Php_preg___tst {
private final Php_preg___fxt fxt = new Php_preg___fxt();
@Test public void Basic() {fxt.Test__split("a''b''c" , "''", Bool_.Y, "a", "''", "b", "''", "c");}
@Test public void Extend() {fxt.Test__split("a'''b'''c" , "''", Bool_.Y, "a", "'''", "b", "'''", "c");}
@Test public void Eos() {fxt.Test__split("a''" , "''", Bool_.Y, "a", "''");}
}
class Php_preg___fxt {
private final gplx.core.primitives.Int_list rv = new gplx.core.primitives.Int_list();
public void Test__split(String src, String dlm, boolean extend, String... expd) {Test__split(src, 0, String_.Len(src), dlm, extend, expd);}
public void Test__split(String src, int src_bgn, int src_end, String dlm, boolean extend, String... expd) {
byte[][] actl = Php_preg_.Split(rv, Bry_.new_u8(src), src_bgn, src_end, Bry_.new_u8(dlm), extend);
Gftest.Eq__ary(expd, String_.Ary(actl), "find_failed");
}
}

View File

@ -1,85 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import org.junit.*; import gplx.core.tests.*; import gplx.core.btries.*;
public class Php_str___tst {
private final Php_str___fxt fxt = new Php_str___fxt();
@Test public void Strspn_fwd__byte() {
fxt.Test__strspn_fwd__byte("aaaaab", Byte_ascii.Ltr_a, 0, -1, 5); // basic
fxt.Test__strspn_fwd__byte("aaaaab", Byte_ascii.Ltr_a, 1, -1, 4); // bgn
fxt.Test__strspn_fwd__byte("aaaaab", Byte_ascii.Ltr_a, 1, 2, 2); // max
}
@Test public void Strspn_fwd__space_or_tab() {
fxt.Test__strspn_fwd__space_or_tab(" a", 0, -1, 5); // basic
fxt.Test__strspn_fwd__space_or_tab(" a", 1, -1, 4); // bgn
fxt.Test__strspn_fwd__space_or_tab(" a", 1, 2, 2); // max
}
@Test public void Strspn_bwd__byte() {
fxt.Test__strspn_bwd__byte("aaaaab", Byte_ascii.Ltr_a, 5, -1, 5); // basic
fxt.Test__strspn_bwd__byte("aaaaab", Byte_ascii.Ltr_a, 4, -1, 4); // bgn
fxt.Test__strspn_bwd__byte("aaaaab", Byte_ascii.Ltr_a, 4, 2, 2); // max
}
@Test public void Strspn_bwd__space_or_tab() {
fxt.Test__strspn_bwd__space_or_tab(" a", 5, -1, 5); // basic
fxt.Test__strspn_bwd__space_or_tab(" a", 4, -1, 4); // bgn
fxt.Test__strspn_bwd__space_or_tab(" a", 4, 2, 2); // max
}
@Test public void Substr__bgn_is_neg() {
fxt.Test__substr("abcde" , -1, "e");
fxt.Test__substr("abcde" , -3, -1, "cd");
}
@Test public void Strtr() {
fxt.Init__strtr_by_trie("01", "89", "02", "79");
fxt.Test__strtr_by_trie("abc" , "abc"); // found=none
fxt.Test__strtr_by_trie("ab_01_cd" , "ab_89_cd"); // found=one
fxt.Test__strtr_by_trie("ab_01_cd_02_ef", "ab_89_cd_79_ef"); // found=many
fxt.Test__strtr_by_trie("01_ab" , "89_ab"); // BOS
fxt.Test__strtr_by_trie("ab_01" , "ab_89"); // EOS
}
}
class Php_str___fxt {
public void Test__strspn_fwd__byte(String src_str, byte find, int bgn, int max, int expd) {
byte[] src_bry = Bry_.new_u8(src_str);
Gftest.Eq__int(expd, Php_str_.Strspn_fwd__byte(src_bry, find, bgn, max, src_bry.length));
}
public void Test__strspn_fwd__space_or_tab(String src_str, int bgn, int max, int expd) {
byte[] src_bry = Bry_.new_u8(src_str);
Gftest.Eq__int(expd, Php_str_.Strspn_fwd__space_or_tab(src_bry, bgn, max, src_bry.length));
}
public void Test__strspn_bwd__byte(String src_str, byte find, int bgn, int max, int expd) {
Gftest.Eq__int(expd, Php_str_.Strspn_bwd__byte(Bry_.new_u8(src_str), find, bgn, max));
}
public void Test__strspn_bwd__space_or_tab(String src_str, int bgn, int max, int expd) {
Gftest.Eq__int(expd, Php_str_.Strspn_bwd__space_or_tab(Bry_.new_u8(src_str), bgn, max));
}
public void Test__substr(String src_str, int bgn, String expd) {Test__substr(src_str, bgn, String_.Len(src_str), expd);}
public void Test__substr(String src_str, int bgn, int len, String expd) {
Gftest.Eq__str(expd, Php_str_.Substr(Bry_.new_u8(src_str), bgn, len));
}
private Btrie_slim_mgr strtr_trie;
public void Init__strtr_by_trie(String... kvs) {
if (strtr_trie == null) strtr_trie = Btrie_slim_mgr.cs();
int len = kvs.length;
for (int i = 0; i < len; i += 2) {
strtr_trie.Add_str_str(kvs[i], kvs[i + 1]);
}
}
public void Test__strtr_by_trie(String src, String expd) {
Bry_bfr tmp = Bry_bfr_.New();
Btrie_rv trv = new Btrie_rv();
Gftest.Eq__str(expd, Php_str_.Strtr(Bry_.new_u8(src), strtr_trie, tmp, trv));
}
}

View File

@ -1,118 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
public class Xomw_ttl_utl {
// REF.MW: DefaultSettings.php
// Allowed title characters -- regex character class
// Don't change this unless you know what you're doing
//
// Problematic punctuation:
// - []{}|# Are needed for link syntax, never enable these
// - <> Causes problems with HTML escaping, don't use
// - % Enabled by default, minor problems with path to query rewrite rules, see below
// - + Enabled by default, but doesn't work with path to query rewrite rules,
// corrupted by apache
// - ? Enabled by default, but doesn't work with path to PATH_INFO rewrites
//
// All three of these punctuation problems can be avoided by using an alias,
// instead of a rewrite rule of either variety.
//
// The problem with % is that when using a path to query rewrite rule, URLs are
// double-unescaped: once by Apache's path conversion code, and again by PHP. So
// %253F, for example, becomes "?". Our code does not double-escape to compensate
// for this, indeed double escaping would break if the double-escaped title was
// passed in the query String rather than the path. This is a minor security issue
// because articles can be created such that they are hard to view or edit.
//
// In some rare cases you may wish to remove + for compatibility with old links.
//
// Theoretically 0x80-0x9F of ISO 8859-1 should be disallowed, but
// this breaks interlanguage links
// $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
//
// REGEX:
// without-backslash escaping --> \s%!"$&'()*,-./0-9:;=?@A-Z\^_`a-z~x80-xFF+
// rearranged
// letters --> 0-9A-Za-z
// unicode-chars --> x80-xFF
// symbols --> \s%!"$&'()*,-./:;=?@\^_`~+"
// deliberately ignores
// control chars: 00-31,127
// []{}|#<>
public static int Find_fwd_while_title(byte[] src, int src_bgn, int src_end, boolean[] valid) {
int cur = src_bgn;
while (true) {
if (cur == src_end) break;
byte b = src[cur];
int b_len = gplx.core.intls.Utf8_.Len_of_char_by_1st_byte(b);
if (b_len == 1) { // ASCII
if (valid[b & 0xFF]) // valid; EX: "a0A B&$"; PATCH.JAVA:need to convert to unsigned byte
cur++;
else // invalid; EX: "<title>"
break;
}
else { // Multi-byte UTF8; NOTE: all sequences are valid
cur += b_len;
}
}
return cur;
}
private static boolean[] title_chars_valid;
public static boolean[] Title_chars_valid() {
if (title_chars_valid == null) {
title_chars_valid = new boolean[128];
// add num and alpha
for (int i = Byte_ascii.Num_0; i <= Byte_ascii.Num_9; i++)
title_chars_valid[i] = true;
for (int i = Byte_ascii.Ltr_A; i <= Byte_ascii.Ltr_Z; i++)
title_chars_valid[i] = true;
for (int i = Byte_ascii.Ltr_a; i <= Byte_ascii.Ltr_z; i++)
title_chars_valid[i] = true;
// add symbols: \s%!"$&'()*,-./:;=?@\^_`~+"
byte[] symbols = new byte[]
{ Byte_ascii.Space
, Byte_ascii.Percent
, Byte_ascii.Bang
, Byte_ascii.Quote
, Byte_ascii.Amp
, Byte_ascii.Apos
, Byte_ascii.Paren_bgn
, Byte_ascii.Paren_end
, Byte_ascii.Star
, Byte_ascii.Comma
, Byte_ascii.Dash
, Byte_ascii.Dot
, Byte_ascii.Slash
, Byte_ascii.Colon
, Byte_ascii.Semic
, Byte_ascii.Eq
, Byte_ascii.Question
, Byte_ascii.At
, Byte_ascii.Backslash
, Byte_ascii.Pow
, Byte_ascii.Underline
, Byte_ascii.Tick
, Byte_ascii.Tilde
, Byte_ascii.Plus
};
int symbols_len = symbols.length;
for (int i = 0; i < symbols_len; i++)
title_chars_valid[symbols[i]] = true;
}
return title_chars_valid;
}
}

View File

@ -1,213 +0,0 @@
100_core/src/gplx/Array_.java | 20 +-
100_core/src/gplx/Array__tst.java | 20 +-
100_core/src/gplx/Bool_.java | 20 +-
100_core/src/gplx/Bool__tst.java | 20 +-
100_core/src/gplx/Bry_.java | 20 +-
100_core/src/gplx/Bry__tst.java | 20 +-
100_core/src/gplx/Bry_bfr.java | 20 +-
100_core/src/gplx/Bry_bfr_.java | 20 +-
100_core/src/gplx/Bry_bfr_tst.java | 20 +-
100_core/src/gplx/Bry_find_.java | 20 +-
100_core/src/gplx/Bry_find__tst.java | 20 +-
100_core/src/gplx/Bry_fmt.java | 20 +-
100_core/src/gplx/Bry_split_.java | 20 +-
100_core/src/gplx/Bry_split__tst.java | 20 +-
100_core/src/gplx/Byte_.java | 20 +-
100_core/src/gplx/Byte__tst.java | 20 +-
100_core/src/gplx/Byte_ascii.java | 20 +-
100_core/src/gplx/Cancelable.java | 20 +-
100_core/src/gplx/Cancelable_.java | 20 +-
100_core/src/gplx/Char_.java | 20 +-
100_core/src/gplx/CompareAble.java | 20 +-
100_core/src/gplx/CompareAble_.java | 20 +-
100_core/src/gplx/DateAdp.java | 20 +-
100_core/src/gplx/DateAdp_.java | 20 +-
100_core/src/gplx/DateAdp__tst.java | 20 +-
100_core/src/gplx/Datetime_now.java | 20 +-
100_core/src/gplx/Decimal_adp.java | 20 +-
100_core/src/gplx/Decimal_adp_.java | 20 +-
100_core/src/gplx/Decimal_adp__tst.java | 20 +-
100_core/src/gplx/Double_.java | 20 +-
100_core/src/gplx/Double__tst.java | 20 +-
100_core/src/gplx/Enm_.java | 20 +-
100_core/src/gplx/Err.java | 20 +-
100_core/src/gplx/Err_.java | 20 +-
100_core/src/gplx/Err_tst.java | 20 +-
100_core/src/gplx/Float_.java | 20 +-
100_core/src/gplx/GfoMsg.java | 20 +-
100_core/src/gplx/GfoMsgUtl.java | 20 +-
100_core/src/gplx/GfoMsg_.java | 20 +-
100_core/src/gplx/GfoMsg_tst.java | 20 +-
100_core/src/gplx/GfoTemplate.java | 20 +-
100_core/src/gplx/GfoTemplateFactory.java | 20 +-
100_core/src/gplx/Gfo_evt_itm.java | 20 +-
100_core/src/gplx/Gfo_evt_mgr.java | 20 +-
100_core/src/gplx/Gfo_evt_mgr_.java | 20 +-
100_core/src/gplx/Gfo_evt_mgr_owner.java | 20 +-
100_core/src/gplx/Gfo_evt_mgr_tst.java | 20 +-
100_core/src/gplx/Gfo_invk.java | 20 +-
100_core/src/gplx/Gfo_invk_.java | 20 +-
100_core/src/gplx/Gfo_invk_cmd.java | 20 +-
100_core/src/gplx/Gfo_invk_cmd_mgr.java | 20 +-
100_core/src/gplx/Gfo_invk_cmd_mgr_owner.java | 20 +-
100_core/src/gplx/Gfo_invk_root_wkr.java | 20 +-
100_core/src/gplx/Gfo_invk_to_str.java | 20 +-
100_core/src/gplx/Gfo_log.java | 20 +-
100_core/src/gplx/Gfo_log_.java | 20 +-
100_core/src/gplx/Gfo_log_bfr.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg_.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__gui.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__gui_.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__gui_test.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__log.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__log_.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg__log_base.java | 20 +-
100_core/src/gplx/Gfo_usr_dlg_base.java | 20 +-
100_core/src/gplx/GfsCtx.java | 20 +-
100_core/src/gplx/Guid_adp.java | 20 +-
100_core/src/gplx/Guid_adp_.java | 20 +-
100_core/src/gplx/Guid_adp__tst.java | 20 +-
100_core/src/gplx/Hash_adp.java | 20 +-
100_core/src/gplx/Hash_adp_.java | 20 +-
100_core/src/gplx/Hash_adp_bry.java | 20 +-
100_core/src/gplx/Hash_adp_bry_tst.java | 20 +-
100_core/src/gplx/Int_.java | 20 +-
100_core/src/gplx/Int__tst.java | 20 +-
100_core/src/gplx/Internal.java | 20 +-
100_core/src/gplx/Io_mgr.java | 20 +-
100_core/src/gplx/Io_mgr__tst.java | 20 +-
100_core/src/gplx/Io_url.java | 20 +-
100_core/src/gplx/Io_url_.java | 20 +-
100_core/src/gplx/Io_url__tst.java | 20 +-
100_core/src/gplx/Keyval.java | 20 +-
100_core/src/gplx/Keyval_.java | 20 +-
100_core/src/gplx/Keyval_hash.java | 20 +-
100_core/src/gplx/Keyval_list.java | 20 +-
100_core/src/gplx/List_adp.java | 20 +-
100_core/src/gplx/List_adp_.java | 20 +-
100_core/src/gplx/List_adp_base.java | 20 +-
100_core/src/gplx/List_adp_tst.java | 20 +-
100_core/src/gplx/Long_.java | 20 +-
100_core/src/gplx/Long__tst.java | 20 +-
100_core/src/gplx/Math_.java | 20 +-
100_core/src/gplx/Math__tst.java | 20 +-
100_core/src/gplx/New.java | 20 +-
100_core/src/gplx/ObjAry.java | 20 +-
100_core/src/gplx/Object_.java | 20 +-
100_core/src/gplx/Object__tst.java | 20 +-
100_core/src/gplx/Ordered_hash.java | 20 +-
100_core/src/gplx/Ordered_hash_.java | 20 +-
100_core/src/gplx/Ordered_hash_base.java | 20 +-
100_core/src/gplx/Ordered_hash_tst.java | 20 +-
100_core/src/gplx/RandomAdp.java | 20 +-
100_core/src/gplx/RandomAdp_.java | 20 +-
100_core/src/gplx/Rls_able.java | 20 +-
100_core/src/gplx/Rls_able_.java | 20 +-
100_core/src/gplx/Short_.java | 20 +-
100_core/src/gplx/String_.java | 20 +-
100_core/src/gplx/String__tst.java | 20 +-
100_core/src/gplx/Tfds.java | 20 +-
100_core/src/gplx/TfdsTstr_fxt.java | 20 +-
100_core/src/gplx/Time_span.java | 20 +-
100_core/src/gplx/Time_span_.java | 20 +-
100_core/src/gplx/To_str_able.java | 20 +-
100_core/src/gplx/To_str_able_.java | 20 +-
100_core/src/gplx/Type_adp_.java | 20 +-
100_core/src/gplx/UsrDlg.java | 20 +-
100_core/src/gplx/UsrDlg_.java | 20 +-
100_core/src/gplx/UsrMsg.java | 20 +-
100_core/src/gplx/UsrMsgWkr.java | 20 +-
100_core/src/gplx/UsrMsgWkr_.java | 20 +-
100_core/src/gplx/UsrMsgWkr_console.java | 20 +-
100_core/src/gplx/UsrMsgWkr_test.java | 20 +-
100_core/src/gplx/Virtual.java | 20 +-
100_core/src/gplx/Yn.java | 20 +-
100_core/src/gplx/core/bits/Bitmask_.java | 20 +-
100_core/src/gplx/core/brys/Bfr_arg.java | 20 +-
100_core/src/gplx/core/brys/Bfr_arg_.java | 20 +-
100_core/src/gplx/core/brys/Bfr_arg_clearable.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_able.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_able_.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_mkr.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_mkr_mgr.java | 20 +-
100_core/src/gplx/core/brys/Bry_bfr_mkr_tst.java | 20 +-
100_core/src/gplx/core/brys/Bry_err_wkr.java | 20 +-
100_core/src/gplx/core/brys/Bry_rdr.java | 20 +-
100_core/src/gplx/core/brys/Bry_rdr_old.java | 20 +-
100_core/src/gplx/core/brys/Bry_rdr_tst.java | 20 +-
100_core/src/gplx/core/brys/Bry_split_wkr.java | 20 +-
100_core/src/gplx/core/brys/args/Bfr_arg__bry.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__bry_ary.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__bry_fmt.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__bry_fmtr.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__byte.java | 20 +-
.../gplx/core/brys/args/Bfr_arg__decimal_int.java | 20 +-
100_core/src/gplx/core/brys/args/Bfr_arg__int.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__time.java | 20 +-
.../src/gplx/core/brys/args/Bfr_arg__time_tst.java | 20 +-
100_core/src/gplx/core/brys/fmtrs/Bry_fmtr.java | 20 +-
.../gplx/core/brys/fmtrs/Bry_fmtr_eval_mgr.java | 20 +-
.../gplx/core/brys/fmtrs/Bry_fmtr_eval_mgr_.java | 20 +-
.../core/brys/fmtrs/Bry_fmtr_eval_mgr_gfs.java | 20 +-
.../src/gplx/core/brys/fmtrs/Bry_fmtr_itm.java | 20 +-
.../src/gplx/core/brys/fmtrs/Bry_fmtr_tst.java | 20 +-
.../src/gplx/core/brys/fmtrs/Bry_fmtr_vals.java | 20 +-
100_core/src/gplx/core/brys/fmts/Bfr_fmt_arg.java | 20 +-
100_core/src/gplx/core/brys/fmts/Bry_fmt_itm.java | 20 +-
.../src/gplx/core/brys/fmts/Bry_fmt_parser_.java | 20 +-
100_core/src/gplx/core/brys/fmts/Bry_fmt_tst.java | 20 +-
.../gplx/core/brys/fmts/Bry_keys_parser_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_bwd_mgr.java | 20 +-
.../src/gplx/core/btries/Btrie_bwd_mgr_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_fast_mgr.java | 20 +-
.../src/gplx/core/btries/Btrie_fast_mgr_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_itm_stub.java | 20 +-
100_core/src/gplx/core/btries/Btrie_mgr.java | 20 +-
100_core/src/gplx/core/btries/Btrie_rv.java | 20 +-
100_core/src/gplx/core/btries/Btrie_slim_itm.java | 20 +-
.../src/gplx/core/btries/Btrie_slim_itm_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_slim_mgr.java | 20 +-
.../src/gplx/core/btries/Btrie_slim_mgr_tst.java | 20 +-
100_core/src/gplx/core/btries/Btrie_u8_itm.java | 20 +-
100_core/src/gplx/core/btries/Btrie_u8_mgr.java | 20 +-
100_core/src/gplx/core/consoles/Console_adp.java | 20 +-
100_core/src/gplx/core/consoles/Console_adp_.java | 20 +-
.../src/gplx/core/consoles/Console_adp__mem.java | 20 +-
.../src/gplx/core/consoles/Console_adp__sys.java | 20 +-
100_core/src/gplx/core/criterias/Criteria.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_.java | 20 +-
.../src/gplx/core/criterias/Criteria_between.java | 20 +-
.../gplx/core/criterias/Criteria_bool_base.java | 20 +-
.../src/gplx/core/criterias/Criteria_comp.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_eq.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_fld.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_in.java | 20 +-
.../gplx/core/criterias/Criteria_ioItm_tst.java | 20 +-
.../src/gplx/core/criterias/Criteria_ioMatch.java | 20 +-
.../src/gplx/core/criterias/Criteria_like.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_not.java | 20 +-
100_core/src/gplx/core/criterias/Criteria_tst.java | 20 +-
100_core/src/gplx/core/encoders/B85_fp_.java | 20 +-
100_core/src/gplx/core/encoders/B85_fp__tst.java | 20 +-
100_core/src/gplx/core/encoders/Base85_.java | 20 +-
100_core/src/gplx/core/encoders/Base85__tst.java | 20 +-
100_core/src/gplx/core/encoders/Gfo_hzip_int_.java | 20 +-
100_core/src/gplx/core/encoders/Hex_utl_.java | 20 +-
100_core/src/gplx/core/encoders/Hex_utl__tst.java | 20 +-
100_core/src/gplx/core/envs/Env_.java | 20 +-
100_core/src/gplx/core/envs/Jar_adp_.java | 20 +-
100_core/src/gplx/core/envs/Op_sys.java | 20 +-
100_core/src/gplx/core/envs/Op_sys_.java | 20 +-
100_core/src/gplx/core/envs/Process_adp.java | 20 +-
100_core/src/gplx/core/envs/Process_adp_tst.java | 20 +-
100_core/src/gplx/core/envs/Runtime_.java | 20 +-
100_core/src/gplx/core/envs/System_.java | 20 +-
100_core/src/gplx/core/errs/Err_msg.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoFld.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoFldList.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoFldList_.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoNde.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoNdeFxt.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoNdeList.java | 20 +-
100_core/src/gplx/core/gfo_ndes/GfoNdeList_.java | 20 [