Skip to content

Commit a0ec573

Browse files
authored
Merge pull request #20 from JuliaLang/yyc/0.6-depwarn
Fix depwarn on 0.5 and 0.6
2 parents 16446b1 + 6dde43c commit a0ec573

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
julia 0.3
2-
Compat
2+
Compat 0.8.0

src/cformat.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
formatters = Dict{ ASCIIString, Function }()
1+
formatters = Dict{ Compat.ASCIIString, Function }()
22

3-
function sprintf1( fmt::ASCIIString, x )
3+
function sprintf1( fmt::Compat.ASCIIString, x )
44
global formatters
55
f = generate_formatter( fmt )
66
f( x )
77
end
88

9-
function generate_formatter( fmt::ASCIIString )
9+
function generate_formatter( fmt::Compat.ASCIIString )
1010
global formatters
1111
if haskey( formatters, fmt )
1212
return formatters[fmt]
1313
end
14-
func = symbol( "sprintf_" * replace( base64encode( fmt ), "=", "!" ) )
14+
func = @compat Symbol("sprintf_", replace(base64encode(fmt), "=", "!"))
1515

1616
if !contains( fmt, "'" )
1717
test = Base.Printf.parse( fmt )
@@ -78,7 +78,7 @@ function generate_formatter( fmt::ASCIIString )
7878
f
7979
end
8080

81-
function addcommas( s::ASCIIString )
81+
function addcommas( s::Compat.ASCIIString )
8282
len = length(s)
8383
t = ""
8484
for i in 1:3:len
@@ -105,7 +105,7 @@ function generate_format_string(;
105105
signed::Bool=false,
106106
positivespace::Bool=false,
107107
alternative::Bool=false,
108-
conversion::ASCIIString="f" #aAdecEfFiosxX
108+
conversion::Compat.ASCIIString="f" #aAdecEfFiosxX
109109
)
110110
s = "%"
111111
if commas
@@ -155,7 +155,7 @@ function format{T<:Real}( x::T;
155155
tryden::Int = 0, # if 2 or higher, try to use this denominator, without losing precision
156156
suffix::AbstractString="", # useful for units/%
157157
autoscale::Symbol=:none, # :metric, :binary or :finance
158-
conversion::ASCIIString=""
158+
conversion::Compat.ASCIIString=""
159159
)
160160
checkwidth = commas
161161
if conversion == ""

src/fmtcore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ _signchar(x::Number, s::Char) = x < 0 ? '-' :
6767
s == '+' ? '+' :
6868
s == ' ' ? ' ' : '\0'
6969

70-
function _pfmt_int{Op}(out::IO, sch::Char, ip::ASCIIString, zs::Integer, ax::Integer, op::Op)
70+
function _pfmt_int{Op}(out::IO, sch::Char, ip::Compat.ASCIIString, zs::Integer, ax::Integer, op::Op)
7171
# print sign
7272
if sch != '\0'
7373
write(out, sch)

src/fmtspec.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,5 @@ end
200200

201201
printfmt(fs::FormatSpec, x) = printfmt(STDOUT, fs, x)
202202

203-
fmt(fs::FormatSpec, x) = (buf = IOBuffer(); printfmt(buf, fs, x); bytestring(buf))
203+
fmt(fs::FormatSpec, x) = sprint(printfmt, fs, x)
204204
fmt(spec::AbstractString, x) = fmt(FormatSpec(spec), x)

src/formatexpr.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function make_argspec(s::AbstractString, pos::Int)
3232
else
3333
iarg = ifil > 1 ? parse(Int,s[1:ifil-1]) : -1
3434
hasfil = true
35-
ff = eval(symbol(s[ifil+2:end]))
35+
ff = eval(@compat Symbol(s[ifil+2:end]))
3636
end
3737
end
3838

@@ -47,7 +47,7 @@ function make_argspec(s::AbstractString, pos::Int)
4747
else
4848
pos = -1
4949
end
50-
end
50+
end
5151

5252
return (ArgSpec(iarg, hasfil, ff), pos)
5353
end
@@ -78,10 +78,10 @@ end
7878
### Format expression
7979

8080
type FormatExpr
81-
prefix::UTF8String
82-
suffix::UTF8String
81+
prefix::Compat.UTF8String
82+
suffix::Compat.UTF8String
8383
entries::Vector{FormatEntry}
84-
inter::Vector{UTF8String}
84+
inter::Vector{Compat.UTF8String}
8585
end
8686

8787
_raise_unmatched_lbrace() = error("Unmatched { in format expression.")
@@ -100,7 +100,7 @@ function find_next_entry_open(s::AbstractString, si::Int)
100100
pre = replace(pre, "{{", '{')
101101
pre = replace(pre, "}}", '}')
102102
end
103-
return (p, utf8(pre))
103+
return (p, convert(Compat.UTF8String, pre))
104104
end
105105

106106
function find_next_entry_close(s::AbstractString, si::Int)
@@ -113,12 +113,12 @@ end
113113

114114
function FormatExpr(s::AbstractString)
115115
slen = length(s)
116-
116+
117117
# init
118-
prefix = utf8("")
119-
suffix = utf8("")
118+
prefix = convert(Compat.UTF8String, "")
119+
suffix = convert(Compat.UTF8String, "")
120120
entries = FormatEntry[]
121-
inter = UTF8String[]
121+
inter = Compat.UTF8String[]
122122

123123
# scan
124124
(p, prefix) = find_next_entry_open(s, 1)
@@ -166,4 +166,4 @@ printfmt(io::IO, fe::AbstractString, args...) = printfmt(io, FormatExpr(fe), arg
166166
@compat printfmtln(fe::Union{AbstractString,FormatExpr}, args...) = printfmtln(STDOUT, fe, args...)
167167

168168
@compat format(fe::Union{AbstractString,FormatExpr}, args...) =
169-
(buf = IOBuffer(); printfmt(buf, fe, args...); bytestring(buf))
169+
sprint(printfmt, fe, args...)

test/cformat.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using Formatting
2+
using Compat
23
using Base.Test
34

45
function test_equality()
56
println( "test cformat equality...")
67
srand(10)
7-
fmts = ASCIIString[ "%10.4f", "%f", "%e", "%10f", "%.3f", "%.3e" ]
8+
fmts = Compat.ASCIIString[ "%10.4f", "%f", "%e", "%10f", "%.3f", "%.3e" ]
89
for fmt in fmts
910
l = :( x-> x )
10-
l.args[2].args[2] = Expr( :macrocall, symbol( "@sprintf" ), fmt, :x )
11+
l.args[2].args[2] = @compat Expr(:macrocall, Symbol("@sprintf"), fmt, :x)
1112
mfmtr = eval( l )
1213
for i in 1:10000
1314
n = erfinv( rand() * 1.99 - 1.99/2.0 )
@@ -17,10 +18,10 @@ function test_equality()
1718
end
1819
end
1920

20-
fmts = ASCIIString[ "%d", "%10d", "%010d", "%-10d" ]
21+
fmts = Compat.ASCIIString[ "%d", "%10d", "%010d", "%-10d" ]
2122
for fmt in fmts
2223
l = :( x-> x )
23-
l.args[2].args[2] = Expr( :macrocall, symbol( "@sprintf" ), fmt, :x )
24+
l.args[2].args[2] = @compat Expr(:macrocall, Symbol("@sprintf"), fmt, :x)
2425
mfmtr = eval( l )
2526
for i in 1:10000
2627
j = round(Int, erfinv( rand() * 1.99 - 1.99/2.0 ) * 100000 )

0 commit comments

Comments
 (0)