Skip to content

Commit

Permalink
remove SSF._general_int
Browse files Browse the repository at this point in the history
  • Loading branch information
reviewher committed Mar 17, 2022
1 parent 61487bc commit 90a7b4e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 15 deletions.
5 changes: 1 addition & 4 deletions bits/10_ssf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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*/) {
Expand Down
2 changes: 1 addition & 1 deletion bits/20_jsutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function cc2str(arr/*:Array<number>*/, 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 = [];
Expand Down
4 changes: 2 additions & 2 deletions bits/66_wscommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down
2 changes: 1 addition & 1 deletion bits/75_xlml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion bits/76_xls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion misc/flowdeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions packages/ssf/bits/40_general.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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*/) {
Expand Down
1 change: 0 additions & 1 deletion packages/ssf/misc/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 90a7b4e

Please sign in to comment.