Skip to content

Commit e3c72b0

Browse files
authored
Merge pull request #56 from JuliaString/spj/update
Clean up
2 parents ce122ee + 6e1b6b6 commit e3c72b0

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ keywords = ["Strings", "Formatting"]
2323
license = "MIT"
2424
name = "Format"
2525
uuid = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8"
26-
version = "1.2.0"
26+
version = "1.2.1"
2727

2828
[deps]
2929
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

src/cformat.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cfmt(fmtstr::ASCIIStr, x) = cfmt(_get_formatter(fmtstr), x)
2626

2727
function generate_formatter(fmt::ASCIIStr)
2828
fspec = _get_formatter(fmt)
29-
fspec.tsep ? x -> _cfmt_comma(fspec, x) : x -> _cfmt(fspec, x)
29+
fspec.tsep == 0 ? x -> _cfmt(fspec, x) : x -> _cfmt_comma(fspec, x)
3030
end
3131

3232
function addcommasreal(s)

src/printf.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ struct FmtChr <: FmtType end
99
struct FmtStr <: FmtType end
1010
struct FmtPtr <: FmtType end
1111

12-
struct Fmt_e <: FmtType end
13-
struct Fmt_f <: FmtType end
14-
struct Fmt_g <: FmtType end
15-
struct Fmt_a <: FmtType end
12+
struct FmtFltE <: FmtType end
13+
struct FmtFltF <: FmtType end
14+
struct FmtFltG <: FmtType end
15+
struct FmtFltA <: FmtType end
1616

17-
struct Fmt_n <: FmtType end
17+
struct FmtN <: FmtType end
1818

1919
const VALID_FMTS = b"duoxefgacsipnDUOXEFGACS"
2020

21-
const FMT_TYPES = [FmtDec, FmtDec, FmtOct, FmtHex, Fmt_e, Fmt_f, Fmt_g, Fmt_a, FmtChr, FmtStr,
22-
FmtDec, FmtPtr, Fmt_n]
21+
const FMT_TYPES = [FmtDec, FmtDec, FmtOct, FmtHex, FmtFltE, FmtFltF, FmtFltG, FmtFltA, FmtChr, FmtStr,
22+
FmtDec, FmtPtr, FmtN]
2323

2424
# format specifier categories
2525
const FmtInts = Union{FmtDec, FmtOct, FmtHex}
26-
const FmtFlts = Union{Fmt_e, Fmt_f, Fmt_g, Fmt_a}
26+
const FmtFlts = Union{FmtFltE, FmtFltF, FmtFltG, FmtFltA}
2727

2828
"""
2929
Typed representation of a format specifier.
@@ -58,7 +58,7 @@ Base.string(f::FmtSpec; modifier::String="") =
5858
Base.show(io::IO, f::FmtSpec) = print(io, string(f))
5959

6060
floatfmt(s::FmtSpec) =
61-
FmtSpec{Fmt_f}(s.char, s.tsep, s.leftalign, s.plus, s.space, s.zero, s.altf, s.width, 0)
61+
FmtSpec{FmtFltF}(s.char, s.tsep, s.leftalign, s.plus, s.space, s.zero, s.altf, s.width, 0)
6262
ptrfmt(s::FmtSpec, x) =
6363
FmtSpec{FmtHex}(s.char, s.tsep, s.leftalign, s.plus, s.space, s.zero, true, s.width,
6464
ifelse(sizeof(x) == 8, 16, 8))
@@ -163,7 +163,7 @@ function FmtSpec(f::AbstractString)
163163
if fmttyp <: FmtInts && prec > 0
164164
zero = false
165165
elseif !parsedprecdigits
166-
if (fmttyp === FmtStr || fmttyp === FmtChr || fmttyp === Fmt_a)
166+
if (fmttyp === FmtStr || fmttyp === FmtChr || fmttyp === FmtFltA)
167167
prec = -1
168168
elseif fmttyp <: FmtFlts
169169
prec = 6
@@ -172,7 +172,7 @@ function FmtSpec(f::AbstractString)
172172
FmtSpec{fmttyp}(b, tsep, leftalign, plus, space, zero, altf, width, prec)
173173
end
174174

175-
@inline gethexbase(spec) = spec.char < 'a' ? b"0123456789ABCDEF" : b"0123456789abcdef"
175+
@inline gethexbase(spec) = spec.char < UInt8('a') ? b"0123456789ABCDEF" : b"0123456789abcdef"
176176

177177
@inline upchar(spec, ch) = (spec.char & 0x20) | UInt8(ch)
178178

@@ -462,19 +462,19 @@ function _fmt(buf, pos, spec::FmtSpec{T}, arg) where {T <: FmtFlts}
462462
buflen < needed && resize!(buf, pos + needed)
463463

464464
x = tofloat(arg)
465-
if T === Fmt_e
465+
if T === FmtFltE
466466
newpos = Ryu.writeexp(buf, pos, x, spec.prec, spec.plus, spec.space,
467467
spec.altf, upchar(spec, 'E'), UInt8('.'))
468-
elseif T === Fmt_f
469-
newpos = Ryu.writefixed(buf, pos, x, spec.prec, prec, spec.plus, spec.space,
470-
spec.altf, UInt8('.'))
471-
elseif T === Fmt_g
468+
elseif T === FmtFltF
469+
newpos = Ryu.writefixed(buf, pos, x, spec.prec, spec.plus, spec.space, spec.altf,
470+
UInt8('.'))
471+
elseif T === FmtFltG
472472
prec = spec.prec
473473
prec = prec == 0 ? 1 : prec
474474
x = round(x, sigdigits=prec)
475475
newpos = Ryu.writeshortest(buf, pos, x, spec.plus, spec.space, spec.altf, prec,
476476
upchar(spec, 'E'), true, UInt8('.'))
477-
elseif T === Fmt_a
477+
elseif T === FmtFltA
478478
newpos = output_fmt_a(buf, pos, spec, x < 0, abs(x))
479479
end
480480
if newpos - pos < width
@@ -486,7 +486,7 @@ function _fmt(buf, pos, spec::FmtSpec{T}, arg) where {T <: FmtFlts}
486486
# right aligned
487487
n = width - (newpos - pos)
488488
if spec.zero
489-
ex = (arg < 0 || (spec.plus | spec.space)) + ifelse(T === Fmt_a, 2, 0)
489+
ex = (arg < 0 || (spec.plus | spec.space)) + ifelse(T === FmtFltA, 2, 0)
490490
so = pos + ex
491491
len = (newpos - pos) - ex
492492
copyto!(buf, so + n, buf, so, len)

0 commit comments

Comments
 (0)