Skip to content

Commit

Permalink
Merge pull request #53 from JuliaString/spj/printfparse
Browse files Browse the repository at this point in the history
Use Printf.Format instead of Printf.parse
  • Loading branch information
ScottPJones authored Sep 17, 2020
2 parents 4bbf367 + 665f447 commit dffbbd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ keywords = ["Strings", "Formatting"]
license = "MIT"
name = "Format"
uuid = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8"
version = "1.1.0"
version = "1.2.0"

[deps]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand Down
12 changes: 9 additions & 3 deletions src/cformat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ formatters = Dict{ ASCIIStr, Function }()
cfmt( fmt::ASCIIStr, x ) = m_eval(Expr(:call, generate_formatter( fmt ), x))

function checkfmt(fmt)
test = Printf.parse( fmt )
(length( test ) == 1 && typeof( test[1] ) <: Tuple) ||
error( "Only one AND undecorated format string is allowed")
@static if VERSION > v"1.6.0-DEV.854"
test = Printf.Format(fmt)
length(test.formats) == 1 ||
error( "Only one AND undecorated format string is allowed")
else
test = @static VERSION >= v"1.4.0-DEV.180" ? Printf.parse(fmt) : Base.Printf.parse( fmt )
(length( test ) == 1 && typeof( test[1] ) <: Tuple) ||
error( "Only one AND undecorated format string is allowed")
end
end

function generate_formatter( fmt::ASCIIStr )
Expand Down

0 comments on commit dffbbd7

Please sign in to comment.