Skip to content

Commit

Permalink
Merge pull request #13483 from JuliaLang/yyc/readdlm-bigint
Browse files Browse the repository at this point in the history
Fix BigInt parser. Add test for readdlm(BigInt)
  • Loading branch information
tkelman committed Oct 7, 2015
2 parents a70d7cf + eaf5532 commit 8c11f0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function tryparse_internal(::Type{BigInt}, s::AbstractString, startpos::Int, end
_n = Nullable{BigInt}()

# don't make a copy in the common case where we are parsing a whole bytestring
bstr = startpos == start(s) && endpos == endof(s) ? bytestring(s) : bytestring(SubString(s,i,endpos))
bstr = startpos == start(s) && endpos == endof(s) ? bytestring(s) : bytestring(SubString(s,startpos,endpos))

sgn, base, i = Base.parseint_preamble(true,base,bstr,start(bstr),endof(bstr))
if i == 0
Expand Down
5 changes: 5 additions & 0 deletions test/readdlm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,8 @@ end

# fix #13179 parsing unicode lines with default delmiters
@test isequaldlm(readdlm(IOBuffer("# Should ignore this π\n1\tα\n2\tβ\n")), Any[1 "α"; 2 "β"], Any)

# BigInt parser
let data = "1 2 3"
readdlm(IOBuffer(data), ' ', BigInt) == BigInt[1 2 3]
end

0 comments on commit 8c11f0c

Please sign in to comment.