Skip to content

Commit 41c5598

Browse files
authored
Merge pull request #19 from JuliaString/spj/fixwchr
Fix bug with concatenating LatinStr
2 parents d461708 + 03d6123 commit 41c5598

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ authors = ["ScottPJones <scottjones@alum.mit.edu>"]
44
keywords = ["Strings"]
55
license = "MIT"
66
uuid = "e79e7a6a-7bb1-5a4d-9d64-da657b06f53a"
7-
version = "1.1.1"
7+
version = "1.1.2"
88

99
[deps]
1010
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

src/latin.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function string(collection::MS_ASCIILatin...)
2222
@inbounds for str in collection
2323
len += ncodeunits(str)
2424
end
25-
buf, pnt = _allocate(len)
25+
buf, pnt = _allocate(UInt8, len)
2626
@inbounds for str in collection
2727
len = ncodeunits(str)
2828
_memcpy(pnt, pointer(str), len)

src/support.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,14 +726,14 @@ _fwd_memchr(ptr::Ptr{T}, byt::T, len::Integer) where {T<:UInt8} =
726726
ccall(:memchr, Ptr{T}, (Ptr{T}, Int32, Csize_t), ptr, byt, len)
727727

728728
_fwd_memchr(beg::Ptr{T}, wchr::T, len::Integer) where {T<:OthChr} =
729-
_fwd_memchr(beg, ch, bytoff(beg, len))
729+
_fwd_memchr(beg, wchr, bytoff(beg, len))
730730

731731
_fwd_memchr(ptr::Ptr{T}, byt::T, fin::Ptr{T}) where {T<:UInt8} =
732732
ptr < fin ? _fwd_memchr(ptr, byt, fin - ptr) : C_NULL
733733

734734
function _fwd_memchr(pnt::Ptr{T}, wchr::T, fin::Ptr{T}) where {T<:OthChr}
735735
while pnt < fin
736-
get_codeunit(pnt) == ch && return pnt
736+
get_codeunit(pnt) == wchr && return pnt
737737
pnt += sizeof(T)
738738
end
739739
C_NULL

test/basic.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ for T in AllCharTypes
3030
test_strings_base[T] = [String(rand(T, len)) for len in test_string_length]
3131
end
3232

33+
@testset "string" begin
34+
a = ASCIIStr("ascii")
35+
b = LatinStr("latin")
36+
@test typeof(a * a) === ASCIIStr
37+
@test typeof(b * b) === LatinStr
38+
@test typeof(a * b) === LatinStr
39+
end
40+
3341
@testset "constructors" begin
3442
for (ST, type_list) in compat_types, CT in type_list, str in test_strings_base[CT]
3543
@eval @test convert($ST, $str) == $str

0 commit comments

Comments
 (0)