From 665f4479cab7f4bd8faa9e515d46b34f4dc25501 Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Thu, 17 Sep 2020 11:00:38 -0400 Subject: [PATCH] Use Printf.Format instead of Printf.parse --- Project.toml | 2 +- src/cformat.jl | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 3b658ed..4a7a436 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/cformat.jl b/src/cformat.jl index 89cc717..e9737a9 100644 --- a/src/cformat.jl +++ b/src/cformat.jl @@ -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 )