mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.6.5.1
This commit is contained in:
@@ -42,7 +42,7 @@ public class Bry_rdr {
|
||||
public int Read_int_to_semic() {return Read_int_to(Byte_ascii.Semic);}
|
||||
public int Read_int_to_comma() {return Read_int_to(Byte_ascii.Comma);}
|
||||
public int Read_int_to_pipe() {return Read_int_to(Byte_ascii.Pipe);}
|
||||
public int Read_int_to_nl() {return Read_int_to(Byte_ascii.NewLine);}
|
||||
public int Read_int_to_nl() {return Read_int_to(Byte_ascii.Nl);}
|
||||
public int Read_int_to_quote() {return Read_int_to(Byte_ascii.Quote);}
|
||||
public int Read_int_to_non_num(){return Read_int_to(Byte_ascii.Nil);}
|
||||
public int Read_int_to(byte to_char) {
|
||||
@@ -74,7 +74,7 @@ public class Bry_rdr {
|
||||
}
|
||||
return bgn == pos ? or_int : rv * negative;
|
||||
}
|
||||
public byte[] Read_bry_to_nl() {return Read_bry_to(Byte_ascii.NewLine);}
|
||||
public byte[] Read_bry_to_nl() {return Read_bry_to(Byte_ascii.Nl);}
|
||||
public byte[] Read_bry_to_semic() {return Read_bry_to(Byte_ascii.Semic);}
|
||||
public byte[] Read_bry_to_pipe() {return Read_bry_to(Byte_ascii.Pipe);}
|
||||
public byte[] Read_bry_to_quote() {return Read_bry_to(Byte_ascii.Quote);}
|
||||
@@ -104,7 +104,7 @@ public class Bry_rdr {
|
||||
@gplx.Virtual public Bry_rdr Skip_ws() {
|
||||
while (pos < src_len) {
|
||||
switch (src[pos]) {
|
||||
case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn: case Byte_ascii.Space:
|
||||
case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Space:
|
||||
++pos;
|
||||
break;
|
||||
default:
|
||||
|
||||
107
100_core/src/gplx/core/js/Js_wtr.java
Normal file
107
100_core/src/gplx/core/js/Js_wtr.java
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.js; import gplx.*; import gplx.core.*;
|
||||
public class Js_wtr {
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
private int arg_idx = 0, ary_idx = 0;
|
||||
public byte Quote_char() {return quote_char;} public Js_wtr Quote_char_(byte v) {quote_char = v; return this;} private byte quote_char = Byte_ascii.Quote;
|
||||
public void Clear() {bfr.Clear();}
|
||||
public String To_str() {return bfr.Xto_str();}
|
||||
public String To_str_and_clear() {return bfr.Xto_str_and_clear();}
|
||||
public Js_wtr Func_init(String name) {return Func_init(Bry_.new_u8(name));}
|
||||
public Js_wtr Func_init(byte[] name) {
|
||||
bfr.Add(name).Add_byte(Byte_ascii.Paren_bgn);
|
||||
arg_idx = 0;
|
||||
return this;
|
||||
}
|
||||
public Js_wtr Func_term() {
|
||||
bfr.Add_byte(Byte_ascii.Paren_end).Add_byte_semic();
|
||||
return this;
|
||||
}
|
||||
public Js_wtr Prm_bry(byte[] bry) {
|
||||
Prm_spr();
|
||||
Write_val(bry);
|
||||
return this;
|
||||
}
|
||||
public Js_wtr Prm_obj_ary(Object[] ary) {
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; ++i) {
|
||||
Object itm = ary[i];
|
||||
if (i != 0) bfr.Add_byte(Byte_ascii.Comma);
|
||||
boolean val_needs_quotes = true;
|
||||
if ( ClassAdp_.Eq_typeSafe(itm, Bool_.Cls_ref_type)
|
||||
|| ClassAdp_.Eq_typeSafe(itm, Int_.Cls_ref_type)
|
||||
|| ClassAdp_.Eq_typeSafe(itm, Long_.Cls_ref_type)
|
||||
) {
|
||||
val_needs_quotes = false;
|
||||
}
|
||||
if (val_needs_quotes)
|
||||
Write_val(Bry_.new_u8(Object_.Xto_str_strict_or_null_mark(itm)));
|
||||
else
|
||||
bfr.Add_obj_strict(itm);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Js_wtr Ary_init() {
|
||||
ary_idx = 0;
|
||||
bfr.Add_byte(Byte_ascii.Brack_bgn);
|
||||
return this;
|
||||
}
|
||||
public Js_wtr Ary_term() {
|
||||
bfr.Add_byte(Byte_ascii.Brack_end);
|
||||
return this;
|
||||
}
|
||||
public void Prm_spr() {
|
||||
if (arg_idx != 0) bfr.Add_byte(Byte_ascii.Comma);
|
||||
++arg_idx;
|
||||
}
|
||||
private void Ary_spr() {
|
||||
if (ary_idx != 0) bfr.Add_byte(Byte_ascii.Comma);
|
||||
++ary_idx;
|
||||
}
|
||||
public Js_wtr Ary_bry(byte[] bry) {
|
||||
Ary_spr();
|
||||
Write_val(bry);
|
||||
return this;
|
||||
}
|
||||
private Js_wtr Write_keyword_return() {bfr.Add(Keyword_return); return this;}
|
||||
public Js_wtr Write_statement_return_func(String func, Object... args) {
|
||||
this.Write_keyword_return();
|
||||
this.Func_init(func);
|
||||
this.Prm_obj_ary(args);
|
||||
this.Func_term();
|
||||
return this;
|
||||
}
|
||||
public void Write_val(byte[] bry) {
|
||||
bfr.Add_byte(quote_char);
|
||||
int len = bry.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte b = bry[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Backslash: // "\" -> "\\"; needed else js will usurp \ as escape; EX: "\&" -> "&"; DATE:2014-06-24
|
||||
case Byte_ascii.Quote:
|
||||
case Byte_ascii.Apos: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(b); break;
|
||||
case Byte_ascii.Nl: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(Byte_ascii.Ltr_n); break; // "\n" -> "\\n"
|
||||
case Byte_ascii.Cr: break;// skip
|
||||
default: bfr.Add_byte(b); break;
|
||||
}
|
||||
}
|
||||
bfr.Add_byte(quote_char);
|
||||
}
|
||||
private static final byte[] Keyword_return = Bry_.new_a7("return ");
|
||||
}
|
||||
41
100_core/src/gplx/core/js/Js_wtr_tst.java
Normal file
41
100_core/src/gplx/core/js/Js_wtr_tst.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.js; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class Js_wtr_tst {
|
||||
@Before public void Init() {fxt.Clear();} private Js_wtr_fxt fxt = new Js_wtr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_write_val_html("abc" , "'abc'");
|
||||
fxt.Test_write_val_html("a'b" , "'a\\'b'");
|
||||
fxt.Test_write_val_html("a\"b" , "'a\\\"b'");
|
||||
fxt.Test_write_val_html("a\nb" , "'a\\nb'");
|
||||
fxt.Test_write_val_html("a\rb" , "'ab'");
|
||||
fxt.Test_write_val_html("a\\&b" , "'a\\\\&b'"); // PURPOSE: backslashes need to be escaped; need for MathJax and "\&"; PAGE:Electromagnetic_field_tensor; DATE:2014-06-24
|
||||
}
|
||||
}
|
||||
class Js_wtr_fxt {
|
||||
private Js_wtr wtr = new Js_wtr();
|
||||
public void Clear() {
|
||||
wtr.Clear();
|
||||
wtr.Quote_char_(Byte_ascii.Apos);
|
||||
}
|
||||
public void Test_write_val_html(String raw, String expd) {
|
||||
wtr.Write_val(Bry_.new_u8(raw));
|
||||
Tfds.Eq(expd, wtr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -364,7 +364,7 @@ public class Bry_ {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static final byte[] Trim_ary_ws = mask_(256, Byte_ascii.Tab, Byte_ascii.NewLine, Byte_ascii.CarriageReturn, Byte_ascii.Space);
|
||||
public static final byte[] Trim_ary_ws = mask_(256, Byte_ascii.Tab, Byte_ascii.Nl, Byte_ascii.Cr, Byte_ascii.Space);
|
||||
public static byte[] Trim(byte[] src) {return Trim(src, 0, src.length, true, true, Trim_ary_ws);}
|
||||
public static byte[] Trim(byte[] src, int bgn, int end) {return Trim(src, bgn, end, true, true, Trim_ary_ws);}
|
||||
public static byte[] Trim(byte[] src, int bgn, int end, boolean trim_bgn, boolean trim_end, byte[] trim_ary) {
|
||||
@@ -456,7 +456,7 @@ public class Bry_ {
|
||||
for (int i = src_bgn; i < src_len; i++) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
break;
|
||||
default:
|
||||
return i;
|
||||
@@ -468,7 +468,7 @@ public class Bry_ {
|
||||
for (int i = src_bgn; i > -1; i--) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
break;
|
||||
default:
|
||||
return i;
|
||||
@@ -676,7 +676,7 @@ public class Bry_ {
|
||||
break;
|
||||
case Byte_ascii.Dash:
|
||||
return i == bgn ? rv * -1 : or;
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
if (numbers_seen)
|
||||
ws_seen = true;
|
||||
break;
|
||||
@@ -930,7 +930,7 @@ public class Bry_ {
|
||||
public static int Trim_end_pos(byte[] src, int end) {
|
||||
for (int i = end - 1; i > -1; i--) {
|
||||
switch (src[i]) {
|
||||
case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn: case Byte_ascii.Space:
|
||||
case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Space:
|
||||
break;
|
||||
default:
|
||||
return i + 1;
|
||||
@@ -960,13 +960,13 @@ public class Bry_ {
|
||||
List_adp rv = List_adp_.new_();
|
||||
while (true) {
|
||||
boolean last = src_pos == src_len;
|
||||
byte b = last ? Byte_ascii.NewLine : src[src_pos];
|
||||
byte b = last ? Byte_ascii.Nl : src[src_pos];
|
||||
int nxt_bgn = src_pos + 1;
|
||||
switch (b) {
|
||||
case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.NewLine:
|
||||
if ( b == Byte_ascii.CarriageReturn // check for crlf
|
||||
&& nxt_bgn < src_len && src[nxt_bgn] == Byte_ascii.NewLine) {
|
||||
case Byte_ascii.Cr:
|
||||
case Byte_ascii.Nl:
|
||||
if ( b == Byte_ascii.Cr // check for crlf
|
||||
&& nxt_bgn < src_len && src[nxt_bgn] == Byte_ascii.Nl) {
|
||||
++nxt_bgn;
|
||||
}
|
||||
if (last && (src_pos - fld_bgn == 0)) {} // ignore trailing itms
|
||||
|
||||
@@ -159,7 +159,7 @@ public class Bry_bfr {
|
||||
public Bry_bfr Add_byte_backslash() {return Add_byte(Byte_ascii.Backslash);}
|
||||
public Bry_bfr Add_byte_quote() {return Add_byte(Byte_ascii.Quote);}
|
||||
public Bry_bfr Add_byte_space() {return Add_byte(Byte_ascii.Space);}
|
||||
public Bry_bfr Add_byte_nl() {return Add_byte(Byte_ascii.NewLine);}
|
||||
public Bry_bfr Add_byte_nl() {return Add_byte(Byte_ascii.Nl);}
|
||||
public Bry_bfr Add_byte_dot() {return Add_byte(Byte_ascii.Dot);}
|
||||
public Bry_bfr Add_byte(byte val) {
|
||||
int new_pos = bfr_len + 1;
|
||||
@@ -362,7 +362,7 @@ public class Bry_bfr {
|
||||
for (int i = bgn; i < end; i++) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.NewLine: bfr[bfr_len] = Byte_ascii.Backslash; bfr[bfr_len + 1] = Byte_ascii.Ltr_n; bfr_len += 2; break;
|
||||
case Byte_ascii.Nl: bfr[bfr_len] = Byte_ascii.Backslash; bfr[bfr_len + 1] = Byte_ascii.Ltr_n; bfr_len += 2; break;
|
||||
case Byte_ascii.Tab: bfr[bfr_len] = Byte_ascii.Backslash; bfr[bfr_len + 1] = Byte_ascii.Ltr_t; bfr_len += 2; break;
|
||||
case Byte_ascii.Backslash: bfr[bfr_len] = Byte_ascii.Backslash; bfr[bfr_len + 1] = Byte_ascii.Backslash; bfr_len += 2; break;
|
||||
default: bfr[bfr_len] = b; ++bfr_len; break;
|
||||
@@ -399,6 +399,23 @@ public class Bry_bfr {
|
||||
else ((Bry_fmtr_arg)o).XferAry(this, 0);
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_obj_strict(Object o) {
|
||||
if (o == null) return this; // treat null as empty String;
|
||||
Class<?> o_type = o.getClass();
|
||||
if (o_type == byte[].class) Add((byte[])o);
|
||||
else if (o_type == Integer.class) Add_int_variable(Int_.cast_(o));
|
||||
else if (o_type == Byte.class) Add_byte(Byte_.cast_(o));
|
||||
else if (o_type == Long.class) Add_long_variable(Long_.cast_(o));
|
||||
else if (o_type == String.class) Add_str((String)o);
|
||||
else if (o_type == Bry_bfr.class) Add_bfr_and_preserve((Bry_bfr)o);
|
||||
else if (o_type == DateAdp.class) Add_dte((DateAdp)o);
|
||||
else if (o_type == Io_url.class) Add(((Io_url)o).RawBry());
|
||||
else if (o_type == Boolean.class) Add_bool(Bool_.cast_(o));
|
||||
else if (o_type == Double.class) Add_double(Double_.cast_(o));
|
||||
else if (o_type == Float.class) Add_float(Float_.cast_(o));
|
||||
else ((Bry_fmtr_arg)o).XferAry(this, 0);
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_yn(boolean v) {Add_byte(v ? Byte_ascii.Ltr_y : Byte_ascii.Ltr_n); return this;}
|
||||
public Bry_bfr Add_base85_len_5(int v) {return Add_base85(v, 5);}
|
||||
public Bry_bfr Add_base85(int v, int pad) {
|
||||
@@ -409,7 +426,7 @@ public class Bry_bfr {
|
||||
return this;
|
||||
}
|
||||
public boolean Match_end_byt(byte b) {return bfr_len == 0 ? false : bfr[bfr_len - 1] == b;}
|
||||
public boolean Match_end_byt_nl_or_bos() {return bfr_len == 0 ? true : bfr[bfr_len - 1] == Byte_ascii.NewLine;}
|
||||
public boolean Match_end_byt_nl_or_bos() {return bfr_len == 0 ? true : bfr[bfr_len - 1] == Byte_ascii.Nl;}
|
||||
public boolean Match_end_ary(byte[] ary) {return Bry_.Match(bfr, bfr_len - ary.length, bfr_len, ary);}
|
||||
public Bry_bfr Insert_at(int add_pos, byte[] add_bry) {return Insert_at(add_pos, add_bry, 0, add_bry.length);}
|
||||
public Bry_bfr Insert_at(int add_pos, byte[] add_bry, int add_bgn, int add_end) {
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Bry_finder {
|
||||
for (int i = cur; i > -1; i--) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
rv = i;
|
||||
break;
|
||||
default:
|
||||
@@ -112,7 +112,7 @@ public class Bry_finder {
|
||||
for (int i = cur; i > -1; --i) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class Bry_finder {
|
||||
for (int i = cur; i < end; i++) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
rv = i;
|
||||
break;
|
||||
default:
|
||||
@@ -140,7 +140,7 @@ public class Bry_finder {
|
||||
for (int i = cur; i >= end; i--) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
break;
|
||||
default:
|
||||
return i;
|
||||
@@ -153,7 +153,7 @@ public class Bry_finder {
|
||||
for (int i = cur; i >= end; i--) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
break;
|
||||
default:
|
||||
return i;
|
||||
@@ -199,7 +199,7 @@ public class Bry_finder {
|
||||
while (true) {
|
||||
if (cur == end) return Bry_finder.Not_found;
|
||||
switch (src[cur]) {
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
return cur;
|
||||
default:
|
||||
++cur;
|
||||
@@ -240,7 +240,7 @@ public class Bry_finder {
|
||||
if (cur == end) return cur;
|
||||
try {
|
||||
switch (src[cur]) {
|
||||
case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: ++cur; break;
|
||||
default: return cur;
|
||||
}
|
||||
@@ -282,9 +282,9 @@ public class Bry_finder {
|
||||
if (cur == end) return cur;
|
||||
switch (src[cur]) {
|
||||
case Byte_ascii.Space:
|
||||
case Byte_ascii.NewLine:
|
||||
case Byte_ascii.Nl:
|
||||
case Byte_ascii.Tab:
|
||||
case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Cr:
|
||||
++cur;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -193,7 +193,7 @@ public class Bry_fmtr {
|
||||
}
|
||||
else { // ~{0}; ~~ -> ~; ~n -> newLine; ~t -> tab
|
||||
if (nxt_byte == char_escape) tmp_byte = char_escape;
|
||||
else if (nxt_byte == char_escape_nl) tmp_byte = Byte_ascii.NewLine;
|
||||
else if (nxt_byte == char_escape_nl) tmp_byte = Byte_ascii.Nl;
|
||||
else if (nxt_byte == char_escape_tab) tmp_byte = Byte_ascii.Tab;
|
||||
else {
|
||||
if (fail_when_invalid_escapes) throw Err_.new_("unknown escape code").Add("code", Char_.XbyInt(nxt_byte)).Add("fmt_pos", fmt_pos + 1);
|
||||
|
||||
@@ -19,10 +19,10 @@ package gplx;
|
||||
public class Byte_ascii {
|
||||
public static final byte
|
||||
Nil = 0 , Backfeed = 8, Tab = 9
|
||||
, NewLine = 10, Formfeed = 12, CarriageReturn = 13
|
||||
, Nl = 10, Formfeed = 12, Cr = 13
|
||||
, Space = 32, Bang = 33, Quote = 34
|
||||
, Hash = 35, Dollar = 36, Percent = 37, Amp = 38, Apos = 39
|
||||
, Paren_bgn = 40, Paren_end = 41, Asterisk = 42, Plus = 43, Comma = 44
|
||||
, Paren_bgn = 40, Paren_end = 41, Star = 42, Plus = 43, Comma = 44
|
||||
, Dash = 45, Dot = 46, Slash = 47, Num_0 = 48, Num_1 = 49
|
||||
, Num_2 = 50, Num_3 = 51, Num_4 = 52, Num_5 = 53, Num_6 = 54
|
||||
, Num_7 = 55, Num_8 = 56, Num_9 = 57, Colon = 58, Semic = 59
|
||||
@@ -49,7 +49,7 @@ public class Byte_ascii {
|
||||
switch (b) {
|
||||
case Byte_ascii.Bang: case Byte_ascii.Quote:
|
||||
case Byte_ascii.Hash: case Byte_ascii.Dollar: case Byte_ascii.Percent: case Byte_ascii.Amp: case Byte_ascii.Apos:
|
||||
case Byte_ascii.Paren_bgn: case Byte_ascii.Paren_end: case Byte_ascii.Asterisk: case Byte_ascii.Plus: case Byte_ascii.Comma:
|
||||
case Byte_ascii.Paren_bgn: case Byte_ascii.Paren_end: case Byte_ascii.Star: case Byte_ascii.Plus: case Byte_ascii.Comma:
|
||||
case Byte_ascii.Dash: case Byte_ascii.Dot: case Byte_ascii.Slash:
|
||||
case Byte_ascii.Colon: case Byte_ascii.Semic:
|
||||
case Byte_ascii.Lt: case Byte_ascii.Eq: case Byte_ascii.Gt: case Byte_ascii.Question: case Byte_ascii.At:
|
||||
@@ -68,7 +68,7 @@ public class Byte_ascii {
|
||||
}
|
||||
public static boolean Is_ws(byte b) {
|
||||
switch (b) {
|
||||
case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn: case Byte_ascii.Space: return true;
|
||||
case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Space: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
@@ -79,19 +79,17 @@ public class Byte_ascii {
|
||||
public static byte Case_upper(byte b) {
|
||||
return b > 96 && b < 123
|
||||
? (byte)(b - 32)
|
||||
: b
|
||||
;
|
||||
: b;
|
||||
}
|
||||
public static byte Case_lower(byte b) {
|
||||
return b > 64 && b < 91
|
||||
? (byte)(b + 32)
|
||||
: b
|
||||
;
|
||||
: b;
|
||||
}
|
||||
public static final byte[] Space_len2 = new byte[] {Space, Space}, Space_len4 = new byte[] {Space, Space, Space, Space};
|
||||
public static final byte[]
|
||||
Tab_bry = new byte[] {Byte_ascii.Tab}
|
||||
, NewLine_bry = new byte[] {Byte_ascii.NewLine}
|
||||
, Nl_bry = new byte[] {Byte_ascii.Nl}
|
||||
, Bang_bry = new byte[] {Byte_ascii.Bang}
|
||||
, Dot_bry = new byte[] {Byte_ascii.Dot}
|
||||
, Comma_bry = new byte[] {Byte_ascii.Comma}
|
||||
@@ -106,7 +104,7 @@ public class Byte_ascii {
|
||||
, Pipe_bry = new byte[] {Byte_ascii.Pipe}
|
||||
, Underline_bry = new byte[] {Byte_ascii.Underline}
|
||||
, Slash_bry = new byte[] {Byte_ascii.Slash}
|
||||
, Asterisk_bry = new byte[] {Byte_ascii.Asterisk}
|
||||
, Asterisk_bry = new byte[] {Byte_ascii.Star}
|
||||
, Dash_bry = new byte[] {Byte_ascii.Dash}
|
||||
, Space_bry = new byte[] {Byte_ascii.Space}
|
||||
;
|
||||
|
||||
@@ -225,7 +225,7 @@ public class Int_ implements GfoInvkAble {
|
||||
cur_val += (b - Byte_ascii.Num_0) * cur_mult;
|
||||
cur_mult *= 10;
|
||||
break;
|
||||
case Byte_ascii.Space: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn: case Byte_ascii.Tab:
|
||||
case Byte_ascii.Space: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Tab:
|
||||
break;
|
||||
case Byte_ascii.Comma:
|
||||
if (cur_idx < 0) return or;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Int_ary_ {
|
||||
num_bgn = pos;
|
||||
num_end = pos + 1; // num_end is always after pos; EX: "9": num_end = 1; "98,7": num_end=2
|
||||
break;
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn: // NOTE: parseNumList replaces ws with '', so "1 1" will become "11"
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: // NOTE: parseNumList replaces ws with '', so "1 1" will become "11"
|
||||
break;
|
||||
case Byte_ascii.Comma:
|
||||
if (pos == raw_len -1) return or; // eos; EX: "1,"
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TimeSpanAdp_ {
|
||||
if (i == 0 && unit_val > 0) // only if first char && unit_val > 0
|
||||
sign = -1;
|
||||
break;
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
if (fail_if_ws) return parse_null;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Op_sys_ {
|
||||
case Byte_ascii.Colon:
|
||||
case Byte_ascii.Pipe:
|
||||
case Byte_ascii.Question:
|
||||
case Byte_ascii.Asterisk:
|
||||
case Byte_ascii.Star:
|
||||
case Byte_ascii.Quote: return true;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user