formatting: fix missing '+' for %+e with negative exponent

modern-harvey2
Jon Harper 2017-02-26 15:15:47 +01:00 committed by John Benediktsson
parent 80e9d7c115
commit e1df9df735
2 changed files with 2 additions and 1 deletions

View File

@ -39,6 +39,7 @@ IN: formatting.tests
{ " +1.0E+01" } [ 10 "%+10.1E" sprintf ] unit-test
{ "-001.0E+01" } [ -10 "%+010.1E" sprintf ] unit-test
{ "+001.0E+01" } [ 10 "%+010.1E" sprintf ] unit-test
{ "+001.0E-01" } [ 0.1 "%+010.1E" sprintf ] unit-test
{ "ff" } [ 0xff "%x" sprintf ] unit-test
{ "FF" } [ 0xff "%X" sprintf ] unit-test

View File

@ -47,7 +47,7 @@ pad-align = ("-")? => [[ \ pad-tail \ pad-head ? ]]
pad-width = ([0-9])* => [[ >digits ]]
pad = pad-align pad-char pad-width => [[ <reversed> >quotation dup first 0 = [ drop [ ] ] when ]]
sign_ = [+ ] => [[ '[ dup CHAR: - swap index [ _ prefix ] unless ] ]]
sign_ = [+ ] => [[ '[ dup first CHAR: - = [ _ prefix ] unless ] ]]
sign = (sign_)? => [[ [ ] or ]]
width_ = "." ([0-9])* => [[ second >digits '[ _ short head ] ]]