mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.1.1
This commit is contained in:
@@ -30,10 +30,10 @@ public class Pfunc_explode extends Pf_func_base {
|
||||
if (Bry_.Len_eq_0(dlm)) dlm = Byte_ascii.Space_bry; // handle empty String; EX: {{#explode:a b||1}}
|
||||
if (args_len > 1) {
|
||||
byte[] pos_bry = Pf_func_.Eval_arg_or(ctx, src, caller, self, args_len, 1, null);
|
||||
if (pos_bry != null) idx = Bry_.Xto_int_or(pos_bry, 0);
|
||||
if (pos_bry != null) idx = Bry_.To_int_or(pos_bry, 0);
|
||||
if (args_len > 2) {
|
||||
byte[] limit_bry = Pf_func_.Eval_arg_or(ctx, src, caller, self, args_len, 2, null);
|
||||
if (limit_bry != null) limit = Bry_.Xto_int_or(pos_bry, -1);
|
||||
if (limit_bry != null) limit = Bry_.To_int_or(pos_bry, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Pfunc_pos extends Pf_func_base {
|
||||
int self_args_len = self.Args_len();
|
||||
byte[] find = Pf_func_.Eval_arg_or(ctx, src, caller, self, self_args_len, 0, Byte_ascii.Space_bry); // MW: use " " if find is missing
|
||||
byte[] offset_bry = Pf_func_.Eval_arg_or(ctx, src, caller, self, self_args_len, 1, null);
|
||||
int offset = offset_bry == null ? 0 : Bry_.Xto_int(offset_bry);
|
||||
int offset = offset_bry == null ? 0 : Bry_.To_int_or_neg1(offset_bry);
|
||||
int pos = Bry_finder.Find_fwd(str, find, offset);
|
||||
if (pos != Bry_finder.Not_found)
|
||||
trg.Add_int_variable(pos);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Pfunc_replace extends Pf_func_base {
|
||||
if (Bry_.Len_eq_0(find)) find = Byte_ascii.Space_bry; // NOTE: MW defaults empty finds to space (" "); note that leaving it as "" would cause Replace to loop infinitely
|
||||
byte[] repl = Pf_func_.Eval_arg_or(ctx, src, caller, self, self_args_len, 1, Bry_.Empty);
|
||||
byte[] limit_bry = Pf_func_.Eval_arg_or(ctx, src, caller, self, self_args_len, 2, null);
|
||||
int limit = limit_bry == null ? Int_.MaxValue : Bry_.Xto_int(limit_bry);
|
||||
int limit = limit_bry == null ? Int_.MaxValue : Bry_.To_int_or_neg1(limit_bry);
|
||||
Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_b128();
|
||||
byte[] rv = Bry_.Replace(tmp_bfr, str, find, repl, 0, str.length, limit);
|
||||
tmp_bfr.Mkr_rls();
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Pfunc_rpos extends Pf_func_base {
|
||||
int self_args_len = self.Args_len();
|
||||
byte[] find = Pf_func_.Eval_arg_or(ctx, src, caller, self, self_args_len, 0, Byte_ascii.Space_bry); // MW: use " " if find is missing
|
||||
byte[] offset_bry = Pf_func_.Eval_arg_or(ctx, src, caller, self, self_args_len, 1, null);
|
||||
int offset = offset_bry == null ? str.length : Bry_.Xto_int(offset_bry);
|
||||
int offset = offset_bry == null ? str.length : Bry_.To_int_or_neg1(offset_bry);
|
||||
int pos = Bry_finder.Find_bwd(str, find, offset);
|
||||
if (pos == Bry_finder.Not_found) pos = -1;
|
||||
trg.Add_int_variable(pos);
|
||||
|
||||
@@ -26,10 +26,10 @@ public class Pfunc_sub extends Pf_func_base {
|
||||
int bgn = 0, len = Int_.MinValue;
|
||||
if (self_args_len > 0) {
|
||||
byte[] bgn_bry = Pf_func_.Eval_arg_or(ctx, src, caller, self, self_args_len, 0, null);
|
||||
if (bgn_bry != null) bgn = Bry_.Xto_int_or(bgn_bry, 0);
|
||||
if (bgn_bry != null) bgn = Bry_.To_int_or(bgn_bry, 0);
|
||||
if (self_args_len > 1) {
|
||||
byte[] len_bry = Pf_func_.Eval_arg_or(ctx, src, caller, self, self_args_len, 1, null);
|
||||
if (len_bry != null) len = Bry_.Xto_int_or(len_bry, Int_.MinValue);
|
||||
if (len_bry != null) len = Bry_.To_int_or(len_bry, Int_.MinValue);
|
||||
}
|
||||
}
|
||||
int s_len = s.length;
|
||||
|
||||
Reference in New Issue
Block a user