Skip to content

Commit

Permalink
Fix up v0.6 checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottPJones committed Jan 30, 2017
1 parent a85acf5 commit 5b1e46c
Showing 1 changed file with 12 additions and 31 deletions.
43 changes: 12 additions & 31 deletions src/cformat.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
formatters = Dict{ ASCIIStr, Function }()

if VERSION >= v"0.5.0"
cfmt( fmt::ASCIIStr, x ) = eval(Expr(:call, generate_formatter( fmt ), x))
else
@static if VERSION < v"0.6-"
cfmt( fmt::ASCIIStr, x ) = (generate_formatter( fmt ))(x)
else
cfmt( fmt::ASCIIStr, x ) = eval(Expr(:call, generate_formatter( fmt ), x))
end

function checkfmt(fmt)
Expand Down Expand Up @@ -254,35 +254,21 @@ function format{T<:Real}( x::T;
den = tryden
end
fs = string( num, fractionsep, den)
if length(fs) < fractionwidth
fs = string(repeat( "0", fractionwidth - length(fs) ), fs)
end
s = rstrip(s)
if actualx != 0
s = string(rstrip(s), mixedfractionsep, fs)
elseif !nonneg
s = string('-', fs)
else
s = fs
end
length(fs) < fractionwidth &&
(fs = string(repeat( "0", fractionwidth - length(fs) ), fs))
s = (actualx != 0
? string(rstrip(s), mixedfractionsep, fs)
: (nonneg ? fs : string('-', fs)))
checkwidth = true
elseif !mixedfraction
s = replace( s, "//", fractionsep )
checkwidth = true
end
elseif stripzeros && in( actualconv[1], "fFeEs" )
dpos = findfirst( s, '.')
if in( actualconv[1], "eEs" )
if in( actualconv[1], "es" )
epos = findfirst( s, 'e' )
else
epos = findfirst( s, 'E' )
end
if epos == 0
rpos = length( s )
else
rpos = epos-1
end
if actualconv[1] in "eEs"
epos = findfirst(s, actualconv[1] == 'E' ? 'E' : 'e')
rpos = epos == 0 ? length( s ) : epos-1
else
rpos = length(s)
end
Expand Down Expand Up @@ -311,12 +297,7 @@ function format{T<:Real}( x::T;

if parens && !in( actualconv[1], "xX" )
# if zero or positive, we still need 1 white space on the right
if nonneg
s = string(' ', strip(s), ' ')
else
s = string('(', strip(s), ')')
end

s = nonneg ? string(' ', strip(s), ' ') : string('(', strip(s), ')')
checkwidth = true
end

Expand Down

0 comments on commit 5b1e46c

Please sign in to comment.