Skip to content

Commit

Permalink
fix #8523, regression in Char ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Sep 30, 2014
1 parent a34b9f0 commit 275564e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base/char.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ promote_rule(::Type{Char}, ::Type{Uint128}) = Uint128
+(x::Char , y::Char ) = int(x)+int(y)

# ordinal operations
+(x::Char , y::Integer) = char(int(x)+int(y))
+(x::Char , y::Integer) = reinterpret(Char, int32(x)+int32(y))
+(x::Integer, y::Char ) = y+x
-(x::Char , y::Char ) = int(x)-int(y)
-(x::Char , y::Integer) = char(int(x)-int(y))
-(x::Char , y::Integer) = reinterpret(Char, int32(x)-int32(y))

# bitwise operations
(~)(x::Char) = char(~uint32(x))
Expand Down
2 changes: 1 addition & 1 deletion base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ immutable UnitRange{T<:Real} <: OrdinalRange{T,Int}
start::T
stop::T

UnitRange(start, stop) = new(start, ifelse(stop >= start, stop, start-1))
UnitRange(start, stop) = new(start, ifelse(stop >= start, stop, start-one(stop-start)))
end
UnitRange{T<:Real}(start::T, stop::T) = UnitRange{T}(start, stop)

Expand Down
4 changes: 4 additions & 0 deletions test/strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1241,3 +1241,7 @@ end
@test isalpha("23435")==false
@test iscntrl( string(char(0x0080))) == true
@test ispunct( "‡؟჻") ==true

# This caused JuliaLang/JSON.jl#82
@test first('\x00':'\x7f') === '\x00'
@test last('\x00':'\x7f') === '\x7f'

0 comments on commit 275564e

Please sign in to comment.