1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-29 06:50:50 +00:00

Scribunto: Do not convert zero padded numbers to integer

This commit is contained in:
gnosygnu 2016-11-23 13:47:24 -05:00
parent eb5173b3a0
commit a6540d6200
2 changed files with 6 additions and 1 deletions

View File

@ -191,6 +191,7 @@ public class Scrib_lib_mw implements Scrib_lib {
if (key_missing) // key missing; EX: {{a|val}} if (key_missing) // key missing; EX: {{a|val}}
key_as_int = ++arg_idx;// NOTE: MW requires a key; if none, then default to int index; NOTE: must be int, not String; NOTE: must be indexed to keyless args; EX: in "key1=val1,val2", "val2" must be "1" (1st keyless arg) not "2" (2nd arg); DATE:2013-11-09 key_as_int = ++arg_idx;// NOTE: MW requires a key; if none, then default to int index; NOTE: must be int, not String; NOTE: must be indexed to keyless args; EX: in "key1=val1,val2", "val2" must be "1" (1st keyless arg) not "2" (2nd arg); DATE:2013-11-09
else { // key exists; EX:{{a|key=val}} else { // key exists; EX:{{a|key=val}}
if (key_len > 0 && tmp_bfr.Bfr()[0] != Byte_ascii.Num_0) // do not convert zero-padded numbers to int; EX: "01" -> "01" x> 1; PAGE:ru.w:Красноказарменный_проезд; DATE:2016-11-23
key_as_int = Bry_.To_int_or(tmp_bfr.Bfr(), 0, tmp_bfr.Len(), Int_.Min_value); key_as_int = Bry_.To_int_or(tmp_bfr.Bfr(), 0, tmp_bfr.Len(), Int_.Min_value);
if (key_as_int == Int_.Min_value) { // key is not int; create str if (key_as_int == Int_.Min_value) { // key is not int; create str
key_as_str = tmp_bfr.To_str_and_clear(); key_as_str = tmp_bfr.To_str_and_clear();

View File

@ -38,6 +38,10 @@ public class Scrib_lib_mw__lib_tst {
fxt.Init_frame_parent("test", Keyval_.new_("1", "a1"), Keyval_.new_("2", "a2")); fxt.Init_frame_parent("test", Keyval_.new_("1", "a1"), Keyval_.new_("2", "a2"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_mw.Invk_getAllExpandedArguments, Object_.Ary("parent"), "1=\n 1=a1\n 2=a2"); fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_mw.Invk_getAllExpandedArguments, Object_.Ary("parent"), "1=\n 1=a1\n 2=a2");
} }
@Test public void GetAllExpandedArguments__zero_padded_number() { // PURPOSE: DATE:2016-11-23
fxt.Init_frame_current(Keyval_.new_("01", "v1"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_mw.Invk_getAllExpandedArguments, Object_.Ary("current"), "1=\n 01=v1");
}
@Test public void GetExpandedArgument() { @Test public void GetExpandedArgument() {
fxt.Init_frame_current(Keyval_.int_(1, "val_1"), Keyval_.new_("key_2", "val_2"), Keyval_.int_(3, "val_3")); fxt.Init_frame_current(Keyval_.int_(1, "val_1"), Keyval_.new_("key_2", "val_2"), Keyval_.int_(3, "val_3"));
fxt.Test_scrib_proc_str (lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , "val_1"); // get 1st by idx fxt.Test_scrib_proc_str (lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , "val_1"); // get 1st by idx