Skip to content

Commit 9debcf0

Browse files
committed
Rename strings/types.jl to strings/substring.jl
Move the non-substring related functionality to strings/basic.jl.
1 parent b91ed5d commit 9debcf0

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

base/strings/strings.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

33
include("strings/errors.jl")
4-
include("strings/types.jl")
4+
include("strings/substring.jl")
55
include("strings/basic.jl")
66
include("strings/search.jl")
77
include("strings/util.jl")

base/strings/types.jl renamed to base/strings/substring.jl

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -97,57 +97,9 @@ function unsafe_convert(::Type{Ptr{R}}, s::SubString{String}) where R<:Union{Int
9797
convert(Ptr{R}, pointer(s.string)) + s.offset
9898
end
9999

100-
## reverse an index i so that reverse(s)[i] == s[reverseind(s,i)]
101-
102-
"""
103-
reverseind(v, i)
104-
105-
Given an index `i` in [`reverse(v)`](@ref), return the corresponding index in `v` so that
106-
`v[reverseind(v,i)] == reverse(v)[i]`. (This can be nontrivial in cases where `v` contains
107-
non-ASCII characters.)
108-
109-
# Examples
110-
```jldoctest
111-
julia> r = reverse("Julia")
112-
"ailuJ"
113-
114-
julia> for i in 1:length(r)
115-
print(r[reverseind("Julia", i)])
116-
end
117-
Julia
118-
```
119-
"""
120-
reverseind(s::AbstractString, i) = chr2ind(s, length(s) + 1 - ind2chr(reverse(s), i))
121100
reverseind(s::Union{DirectIndexString,SubString{DirectIndexString}}, i::Integer) = length(s) + 1 - i
122101
reverseind(s::SubString{String}, i::Integer) =
123102
reverseind(s.string, nextind(s.string, endof(s.string))-s.offset-s.endof+i-1) - s.offset
124103

125-
"""
126-
repeat(s::AbstractString, r::Integer)
127-
128-
Repeat a string `r` times. This can equivalently be accomplished by calling [`s^r`](@ref ^).
129-
130-
# Examples
131-
```jldoctest
132-
julia> repeat("ha", 3)
133-
"hahaha"
134-
```
135-
"""
136-
repeat(s::AbstractString, r::Integer) = repeat(convert(String, s), r)
137-
138-
"""
139-
^(s::Union{AbstractString,Char}, n::Integer)
140-
141-
Repeat a string or character `n` times.
142-
The [`repeat`](@ref) function is an alias to this operator.
143-
144-
# Examples
145-
```jldoctest
146-
julia> "Test "^3
147-
"Test Test Test "
148-
```
149-
"""
150-
(^)(s::Union{AbstractString,Char}, r::Integer) = repeat(s,r)
151-
152104
pointer(x::SubString{String}) = pointer(x.string) + x.offset
153105
pointer(x::SubString{String}, i::Integer) = pointer(x.string) + x.offset + (i-1)

0 commit comments

Comments
 (0)