Skip to content

Commit

Permalink
generalize a few things that don't need to be restricted to ASCII
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Aug 21, 2015
1 parent 7676a6a commit 37b9a10
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ function write_prompt(terminal, p::Prompt)
write(terminal, Base.text_colors[:normal])
write(terminal, suffix)
end
write_prompt(terminal, s::ASCIIString) = write(terminal, s)
write_prompt(terminal, s::ByteString) = write(terminal, s)

### Keymap Support

Expand Down
2 changes: 2 additions & 0 deletions base/ascii.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,6 @@ function convert(::Type{ASCIIString}, a::Array{UInt8,1}, invalids_as::ASCIIStrin
end
convert(ASCIIString, a)
end
convert(::Type{ASCIIString}, a::Array{UInt8,1}, invalids_as::AbstractString) =
convert(ASCIIString, a, ascii(invalids_as))
convert(::Type{ASCIIString}, s::AbstractString) = ascii(bytestring(s))
8 changes: 4 additions & 4 deletions base/linalg/arpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import ..LinAlg: BlasInt, ARPACKException
## aupd and eupd wrappers

function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function, n::Integer,
sym::Bool, cmplx::Bool, bmat::ASCIIString,
nev::Integer, ncv::Integer, which::ASCIIString,
sym::Bool, cmplx::Bool, bmat::ByteString,
nev::Integer, ncv::Integer, which::ByteString,
tol::Real, maxiter::Integer, mode::Integer, v0::Vector)

lworkl = cmplx ? ncv * (3*ncv + 5) : (sym ? ncv * (ncv + 8) : ncv * (3*ncv + 6) )
Expand Down Expand Up @@ -103,8 +103,8 @@ function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function
return (resid, v, n, iparam, ipntr, workd, workl, lworkl, rwork, TOL)
end

function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ASCIIString,
nev::Integer, which::ASCIIString, ritzvec::Bool,
function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ByteString,
nev::Integer, which::ByteString, ritzvec::Bool,
TOL::Array, resid, ncv::Integer, v, ldv, sigma, iparam, ipntr,
workd, workl, lworkl, rwork)

Expand Down
1 change: 1 addition & 0 deletions base/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,6 @@ function hex2bytes(s::ASCIIString)
end
return arr
end
hex2bytes(s::AbstractString) = hex2bytes(ascii(s))

bytes2hex{T<:UInt8}(arr::Vector{T}) = join([hex(i,2) for i in arr])
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ end

# issue #4518
f4518(x, y::Union{Int32,Int64}) = 0
f4518(x::ASCIIString, y::Union{Int32,Int64}) = 1
f4518(x::ByteString, y::Union{Int32,Int64}) = 1
@test f4518("",1) == 1

# issue #4581
Expand Down
2 changes: 1 addition & 1 deletion test/unicode/utf32.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ end
@test reverse(utf32("abcd \uff\u7ff\u7fff\U7ffff")) == utf32("\U7ffff\u7fff\u7ff\uff dcba")

# Test pointer() functions
let str = "this "
let str = ascii("this ")

This comment has been minimized.

Copy link
@ScottPJones

ScottPJones Aug 21, 2015

Contributor

Isn't this a no-op?

This comment has been minimized.

Copy link
@StefanKarpinski

StefanKarpinski Aug 22, 2015

Author Member

currently, yes

u8 = utf8(str)
u16 = utf16(str)
u32 = utf32(str)
Expand Down
2 changes: 1 addition & 1 deletion test/unicode/utf8.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let str = UTF8String(b"this is a test\xed\x80")
@test_throws BoundsError getindex(str, 2:17)
@test_throws UnicodeError getindex(str, 16:17)
@test string(Char(0x110000)) == "\ufffd"
sa = SubString{ASCIIString}("This is a silly test", 1, 14)
sa = SubString{ASCIIString}(ascii("This is a silly test"), 1, 14)

This comment has been minimized.

Copy link
@ScottPJones

ScottPJones Aug 21, 2015

Contributor

same here, the type is already ASCIIString, so doesn't the ascii() do nothing at all?

This comment has been minimized.

Copy link
@vtjnash

vtjnash Aug 22, 2015

Member

i suspect Stefan has some other changes up his sleeve

This comment has been minimized.

Copy link
@ScottPJones

ScottPJones Aug 22, 2015

Contributor

If so, shouldn't these changes be part of that PR?
Where was the PR for this change also?

This comment has been minimized.

Copy link
@StefanKarpinski

StefanKarpinski Aug 22, 2015

Author Member

I didn't make one

s8 = convert(SubString{UTF8String}, sa)
@test typeof(s8) == SubString{UTF8String}
@test s8 == "This is a sill"
Expand Down
2 changes: 1 addition & 1 deletion test/unicode/utf8proc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ end
@test !isspace('\U10ffff')

# Get full coverage of grapheme iterator functions
let str = "This is a test"
let str = ascii("This is a test")
g = graphemes(str)
h = hash(str)
@test hash(g) == h
Expand Down

0 comments on commit 37b9a10

Please sign in to comment.