From fdd05c99a9d3788a4428b61ee79d9c53ea50fe85 Mon Sep 17 00:00:00 2001 From: gnosygnu Date: Fri, 27 Sep 2019 20:39:09 -0400 Subject: [PATCH] Parser: Do not reset attributes when tag has more than 16 attributes [#579] --- 100_core/src/gplx/Int_ary_.java | 9 +++++++++ 400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr.java | 2 +- .../src/gplx/xowa/parsers/htmls/Mwh_atr_mgr_tst.java | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/100_core/src/gplx/Int_ary_.java b/100_core/src/gplx/Int_ary_.java index 6070f9d6b..b6600e36e 100644 --- a/100_core/src/gplx/Int_ary_.java +++ b/100_core/src/gplx/Int_ary_.java @@ -25,6 +25,15 @@ public class Int_ary_ {//RF:DATE:2017-10-09 trg[i] = src[i]; } + public static int[] Mid(int[] src, int bgn, int end) { + int len = end - bgn + 1; + int[] rv = new int[len]; + for (int i = 0; i < len; i++) { + rv[i] = src[i + bgn]; + } + return rv; + } + public static String To_str(String spr, int... ary) { Bry_bfr bfr = Bry_bfr_.New(); int len = ary.length; diff --git a/400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr.java b/400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr.java index fb49ae0de..2c4b9c0b9 100644 --- a/400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr.java +++ b/400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr.java @@ -41,7 +41,7 @@ public class Mwh_atr_mgr { if (data_idx == data_max) { int new_data_max = data_max == 0 ? Idx__mult : data_max * 2; int[] new_data_ary = new int[new_data_max]; - Int_ary_.Copy_to(data_ary, data_max, data_ary); + Int_ary_.Copy_to(data_ary, data_max, new_data_ary); this.data_ary = new_data_ary; int text_max = text_ary.length; diff --git a/400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr_tst.java b/400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr_tst.java index 0bcdc7846..f21308d41 100644 --- a/400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr_tst.java +++ b/400_xowa/src/gplx/xowa/parsers/htmls/Mwh_atr_mgr_tst.java @@ -23,10 +23,15 @@ public class Mwh_atr_mgr_tst { // key=val key=val fxt.Test_atr_utl_make(Mwh_atr_itm_.Qte_tid__none, Mwh_atr_itm_.Mask__valid__y, Mwh_atr_itm_.Mask__repeated__y, Mwh_atr_itm_.Mask__key_exists__y, Mwh_atr_itm_.Mask__val_made__y, 120); } - @Test public void Resize() { + @Test public void Resize() {// ISSUE#: Mwh_atr_mgr atr_mgr = new Mwh_atr_mgr(1); + + int[] expd = new int[] {2, 3, 4, 5}; atr_mgr.Add(0, 1, true, true, true, 2, 3, 4, 5, Bry_.Empty, 0, 0, 0, 0, Bry_.Empty); + Gftest.Eq__ary(expd, Int_ary_.Mid(atr_mgr.Data_ary(), 3, 6)); + atr_mgr.Add(1, 0, true, true, true, 0, 0, 0, 0, Bry_.Empty, 0, 0, 0, 0, Bry_.Empty); + Gftest.Eq__ary(expd, Int_ary_.Mid(atr_mgr.Data_ary(), 3, 6)); } } class Mwh_atr_mgr_fxt {