From 90a7b4ee918c7edcd80d2660c912d999a943a792 Mon Sep 17 00:00:00 2001 From: reviewher <24845478+reviewher@users.noreply.github.com> Date: Wed, 16 Mar 2022 21:38:06 -0700 Subject: [PATCH] remove SSF._general_int --- bits/10_ssf.js | 5 +---- bits/20_jsutils.js | 2 +- bits/66_wscommon.js | 4 ++-- bits/75_xlml.js | 2 +- bits/76_xls.js | 2 +- misc/flowdeps.js | 1 - packages/ssf/bits/40_general.js | 5 +---- packages/ssf/misc/flow.js | 1 - 8 files changed, 7 insertions(+), 15 deletions(-) diff --git a/bits/10_ssf.js b/bits/10_ssf.js index ee649ef..c1bacdf 100644 --- a/bits/10_ssf.js +++ b/bits/10_ssf.js @@ -199,10 +199,6 @@ function datenum_local(v/*:Date*/, date1904/*:?boolean*/)/*:number*/ { else if(v >= base1904) epoch += 24*60*60*1000; return (epoch - (dnthresh + (v.getTimezoneOffset() - basedate.getTimezoneOffset()) * 60000)) / (24 * 60 * 60 * 1000); } -/* The longest 32-bit integer text is "-4294967296", exactly 11 chars */ -function general_fmt_int(v/*:number*/)/*:string*/ { return v.toString(10); } -SSF._general_int = general_fmt_int; - /* ECMA-376 18.8.30 numFmt*/ /* Note: `toPrecision` uses standard form when prec > E and E >= -6 */ var general_fmt_num = (function make_general_fmt_num() { @@ -255,6 +251,7 @@ SSF._general_num = general_fmt_num; - "up to 11 characters" displayed for numbers - Default date format (code 14) used for Dates + The longest 32-bit integer text is "-2147483648", exactly 11 chars TODO: technically the display depends on the width of the cell */ function general_fmt(v/*:any*/, opts/*:any*/) { diff --git a/bits/20_jsutils.js b/bits/20_jsutils.js index 7617579..855801e 100644 --- a/bits/20_jsutils.js +++ b/bits/20_jsutils.js @@ -124,7 +124,7 @@ function cc2str(arr/*:Array*/, debomit)/*:string*/ { "\u02dc": "\x98", "\u2122": "\x99", "\u0161": "\x9a", "\u203a": "\x9b", "\u0153": "\x9c", "\u017e": "\x9e", "\u0178": "\x9f" }; - return new TextDecoder("latin1").decode(arr).replace(/[\x80\x9F]/g, function(c) { return rev[c] || c; }); + return new TextDecoder("latin1").decode(arr).replace(/[€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ]/g, function(c) { return rev[c] || c; }); } catch(e) {} var o = []; diff --git a/bits/66_wscommon.js b/bits/66_wscommon.js index 03d8122..88e50a5 100644 --- a/bits/66_wscommon.js +++ b/bits/66_wscommon.js @@ -92,12 +92,12 @@ function safe_format(p/*:Cell*/, fmtid/*:number*/, fillid/*:?number*/, opts, the if(p.t === 'e') p.w = p.w || BErr[p.v]; else if(fmtid === 0) { if(p.t === 'n') { - if((p.v|0) === p.v) p.w = SSF._general_int(p.v); + if((p.v|0) === p.v) p.w = p.v.toString(10); else p.w = SSF._general_num(p.v); } else if(p.t === 'd') { var dd = datenum(p.v); - if((dd|0) === dd) p.w = SSF._general_int(dd); + if((dd|0) === dd) p.w = dd.toString(10); else p.w = SSF._general_num(dd); } else if(p.v === undefined) return ""; diff --git a/bits/75_xlml.js b/bits/75_xlml.js index e837768..2057455 100644 --- a/bits/75_xlml.js +++ b/bits/75_xlml.js @@ -62,7 +62,7 @@ function safe_format_xlml(cell/*:Cell*/, nf, o) { if(cell.t === 'e') { cell.w = cell.w || BErr[cell.v]; } else if(nf === "General") { if(cell.t === 'n') { - if((cell.v|0) === cell.v) cell.w = SSF._general_int(cell.v); + if((cell.v|0) === cell.v) cell.w = cell.v.toString(10); else cell.w = SSF._general_num(cell.v); } else cell.w = SSF._general(cell.v); diff --git a/bits/76_xls.js b/bits/76_xls.js index e2e03fb..c3e1e3c 100644 --- a/bits/76_xls.js +++ b/bits/76_xls.js @@ -83,7 +83,7 @@ function safe_format_xf(p/*:any*/, opts/*:ParseOpts*/, date1904/*:?boolean*/) { if(p.t === 'e') { p.w = p.w || BErr[p.v]; } else if(fmtid === 0 || fmtid == "General") { if(p.t === 'n') { - if((p.v|0) === p.v) p.w = SSF._general_int(p.v); + if((p.v|0) === p.v) p.w = p.v.toString(10); else p.w = SSF._general_num(p.v); } else p.w = SSF._general(p.v); diff --git a/misc/flowdeps.js b/misc/flowdeps.js index 50941af..5107977 100644 --- a/misc/flowdeps.js +++ b/misc/flowdeps.js @@ -30,7 +30,6 @@ type SSFModule = { _table:SSFTable; init_table:any; - _general_int:(v:number)=>string; _general_num:(v:number)=>string; _general:(v:number, o:?any)=>string; _eval:any; diff --git a/packages/ssf/bits/40_general.js b/packages/ssf/bits/40_general.js index 3590e3f..bcdc562 100644 --- a/packages/ssf/bits/40_general.js +++ b/packages/ssf/bits/40_general.js @@ -1,7 +1,3 @@ -/* The longest 32-bit integer text is "-4294967296", exactly 11 chars */ -function general_fmt_int(v/*:number*/)/*:string*/ { return v.toString(10); } -SSF._general_int = general_fmt_int; - /* ECMA-376 18.8.30 numFmt*/ /* Note: `toPrecision` uses standard form when prec > E and E >= -6 */ var general_fmt_num = (function make_general_fmt_num() { @@ -54,6 +50,7 @@ SSF._general_num = general_fmt_num; - "up to 11 characters" displayed for numbers - Default date format (code 14) used for Dates + The longest 32-bit integer text is "-2147483648", exactly 11 chars TODO: technically the display depends on the width of the cell */ function general_fmt(v/*:any*/, opts/*:any*/) { diff --git a/packages/ssf/misc/flow.js b/packages/ssf/misc/flow.js index 3572e3c..c54735c 100644 --- a/packages/ssf/misc/flow.js +++ b/packages/ssf/misc/flow.js @@ -20,7 +20,6 @@ type SSFModule = { _table:SSFTable; init_table:any; - _general_int:(v:number)=>string; _general_num:(v:number)=>string; _general:(v:number, o:?any)=>string; _eval:any;