Skip to content

Commit d74cbe7

Browse files
replace ASCIIString & UTF8String with String
1 parent fca9277 commit d74cbe7

File tree

142 files changed

+752
-994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+752
-994
lines changed

base/LineEdit.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type MIState
2323
current_mode
2424
aborted::Bool
2525
mode_state
26-
kill_buffer::ByteString
26+
kill_buffer::String
2727
previous_key::Array{Char,1}
2828
key_repeats::Int
2929
end
@@ -624,7 +624,7 @@ function write_prompt(terminal, p::Prompt)
624624
write(terminal, Base.text_colors[:normal])
625625
write(terminal, suffix)
626626
end
627-
write_prompt(terminal, s::ByteString) = write(terminal, s)
627+
write_prompt(terminal, s::String) = write(terminal, s)
628628

629629
### Keymap Support
630630

@@ -703,11 +703,11 @@ end
703703
# This is different from the default eager redirect, which only looks at the current and lower
704704
# layers of the stack.
705705
immutable KeyAlias
706-
seq::ASCIIString
706+
seq::String
707707
KeyAlias(seq) = new(normalize_key(seq))
708708
end
709709

710-
match_input(k::Function, s, term, cs, keymap) = (update_key_repeats(s, cs); return keymap_fcn(k, ByteString(cs)))
710+
match_input(k::Function, s, term, cs, keymap) = (update_key_repeats(s, cs); return keymap_fcn(k, String(cs)))
711711
match_input(k::Void, s, term, cs, keymap) = (s,p) -> return :ok
712712
match_input(k::KeyAlias, s, term, cs, keymap) = match_input(keymap, s, IOBuffer(k.seq), Char[], keymap)
713713
function match_input(k::Dict, s, term=terminal(s), cs=Char[], keymap = k)
@@ -1013,7 +1013,7 @@ init_state(terminal, p::HistoryPrompt) = SearchState(terminal, p, true, IOBuffer
10131013
type PrefixSearchState <: ModeState
10141014
terminal
10151015
histprompt
1016-
prefix::ByteString
1016+
prefix::String
10171017
response_buffer::IOBuffer
10181018
ias::InputAreaState
10191019
indent::Int

base/REPL.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ function hist_from_file(hp, file)
356356
error(munged_history_message, countlines)
357357
line[1] != '\t' &&
358358
error(invalid_history_message, repr(line[1]), " at line ", countlines)
359-
lines = UTF8String[]
359+
lines = String[]
360360
while !isempty(line)
361361
push!(lines, chomp(line[2:end]))
362362
eof(file) && break

base/REPLCompletions.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ end
1313
function filtered_mod_names(ffunc::Function, mod::Module, name::AbstractString, all::Bool=false, imported::Bool=false)
1414
ssyms = names(mod, all, imported)
1515
filter!(ffunc, ssyms)
16-
syms = UTF8String[string(s) for s in ssyms]
16+
syms = String[string(s) for s in ssyms]
1717
filter!(x->completes_global(x, name), syms)
1818
end
1919

@@ -47,12 +47,12 @@ function complete_symbol(sym, ffunc)
4747
lookup_module = false
4848
t, found = get_type(ex, context_module)
4949
end
50-
found || return UTF8String[]
50+
found || return String[]
5151
# Ensure REPLCompletion do not crash when asked to complete a tuple, #15329
52-
!lookup_module && t <: Tuple && return UTF8String[]
52+
!lookup_module && t <: Tuple && return String[]
5353
end
5454

55-
suggestions = UTF8String[]
55+
suggestions = String[]
5656
if lookup_module
5757
# We will exclude the results that the user does not want, as well
5858
# as excluding Main.Main.Main, etc., because that's most likely not what
@@ -82,7 +82,7 @@ function complete_symbol(sym, ffunc)
8282
suggestions
8383
end
8484

85-
function complete_keyword(s::ByteString)
85+
function complete_keyword(s::String)
8686
const sorted_keywords = [
8787
"abstract", "baremodule", "begin", "bitstype", "break", "catch", "ccall",
8888
"const", "continue", "do", "else", "elseif", "end", "export", "false",
@@ -117,13 +117,13 @@ function complete_path(path::AbstractString, pos; use_envpath=false)
117117
elseif isdir(dir)
118118
files = readdir(dir)
119119
else
120-
return UTF8String[], 0:-1, false
120+
return String[], 0:-1, false
121121
end
122122
catch
123-
return UTF8String[], 0:-1, false
123+
return String[], 0:-1, false
124124
end
125125

126-
matches = Set{UTF8String}()
126+
matches = Set{String}()
127127
for file in files
128128
if startswith(file, prefix)
129129
id = try isdir(joinpath(dir, file)) catch; false end
@@ -174,7 +174,7 @@ function complete_path(path::AbstractString, pos; use_envpath=false)
174174
end
175175
end
176176

177-
matchList = UTF8String[replace(s, r"\s", "\\ ") for s in matches]
177+
matchList = String[replace(s, r"\s", "\\ ") for s in matches]
178178
startpos = pos - endof(prefix) + 1 - length(matchall(r" ", prefix))
179179
# The pos - endof(prefix) + 1 is correct due to `endof(prefix)-endof(prefix)==0`,
180180
# hence we need to add one to get the first index. This is also correct when considering
@@ -289,7 +289,7 @@ function get_type_call(expr::Expr)
289289
(tree, return_type) = Core.Inference.typeinf(linfo, m[1], m[2])
290290
return return_type, true
291291
end
292-
# Returns the return type. example: get_type(:(Base.strip("",' ')),Main) returns (ASCIIString,true)
292+
# Returns the return type. example: get_type(:(Base.strip("",' ')),Main) returns (String,true)
293293
function get_type(sym::Expr, fn)
294294
sym=expand(sym)
295295
val, found = get_value(sym, fn)
@@ -313,12 +313,12 @@ end
313313
function complete_methods(ex_org::Expr)
314314
args_ex = DataType[]
315315
func, found = get_value(ex_org.args[1], Main)
316-
!found && return UTF8String[]
316+
!found && return String[]
317317
for ex in ex_org.args[2:end]
318318
val, found = get_type(ex, Main)
319319
push!(args_ex, val)
320320
end
321-
out = UTF8String[]
321+
out = String[]
322322
t_in = Tuple{Core.Typeof(func), args_ex...} # Input types
323323
na = length(args_ex)+1
324324
Base.visit(methods(func)) do method
@@ -341,7 +341,7 @@ const bslash_separators = [whitespace_chars..., "\"'`"...]
341341

342342
# Aux function to detect whether we're right after a
343343
# using or import keyword
344-
function afterusing(string::ByteString, startpos::Int)
344+
function afterusing(string::String, startpos::Int)
345345
(isempty(string) || startpos == 0) && return false
346346
str = string[1:prevind(string,startpos)]
347347
isempty(str) && return false
@@ -376,7 +376,7 @@ function bslash_completions(string, pos)
376376
return (true, (sort!(collect(latex_names)), slashpos:pos, true))
377377
end
378378
end
379-
return (false, (UTF8String[], 0:-1, false))
379+
return (false, (String[], 0:-1, false))
380380
end
381381

382382
function completions(string, pos)
@@ -404,7 +404,7 @@ function completions(string, pos)
404404
ok && return ret
405405

406406
# Make sure that only bslash_completions is working on strings
407-
inc_tag==:string && return UTF8String[], 0:-1, false
407+
inc_tag==:string && return String[], 0:-1, false
408408

409409
if inc_tag == :other && should_method_complete(partial)
410410
frange, method_name_end = find_start_brace(partial)
@@ -415,14 +415,14 @@ function completions(string, pos)
415415
return complete_methods(ex), start(frange):method_name_end, false
416416
end
417417
elseif inc_tag == :comment
418-
return UTF8String[], 0:-1, false
418+
return String[], 0:-1, false
419419
end
420420

421421
dotpos = rsearch(string, '.', pos)
422422
startpos = nextind(string, rsearch(string, non_identifier_chars, pos))
423423

424424
ffunc = (mod,x)->true
425-
suggestions = UTF8String[]
425+
suggestions = String[]
426426
comp_keywords = true
427427
if afterusing(string, startpos)
428428
# We're right after using or import. Let's look only for packages
@@ -500,10 +500,10 @@ function shell_completions(string, pos)
500500
try
501501
args, last_parse = Base.shell_parse(scs, true)
502502
catch
503-
return UTF8String[], 0:-1, false
503+
return String[], 0:-1, false
504504
end
505505
# Now look at the last thing we parsed
506-
isempty(args.args[end].args) && return UTF8String[], 0:-1, false
506+
isempty(args.args[end].args) && return String[], 0:-1, false
507507
arg = args.args[end].args[end]
508508
if all(s -> isa(s, AbstractString), args.args[end].args)
509509
# Treat this as a path
@@ -525,7 +525,7 @@ function shell_completions(string, pos)
525525
range += first(r) - 1
526526
return ret, range, true
527527
end
528-
return UTF8String[], 0:-1, false
528+
return String[], 0:-1, false
529529
end
530530

531531
end # module

base/Terminals.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type TerminalBuffer <: UnixTerminal
100100
end
101101

102102
type TTYTerminal <: UnixTerminal
103-
term_type::ASCIIString
103+
term_type::String
104104
in_stream::Base.TTY
105105
out_stream::Base.TTY
106106
err_stream::Base.TTY

base/ascii.jl

Lines changed: 5 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,7 @@
11
# This file is a part of Julia. License is MIT: http://julialang.org/license
22

3-
## from base/boot.jl:
4-
#
5-
# immutable ASCIIString <: DirectIndexString
6-
# data::Array{UInt8,1}
7-
# end
8-
#
9-
10-
## required core functionality ##
11-
12-
endof(s::ASCIIString) = length(s.data)
13-
getindex(s::ASCIIString, i::Int) = (x=s.data[i]; ifelse(x < 0x80, Char(x), '\ufffd'))
14-
15-
## overload methods for efficiency ##
16-
17-
sizeof(s::ASCIIString) = sizeof(s.data)
18-
19-
getindex(s::ASCIIString, r::Vector) = ASCIIString(getindex(s.data,r))
20-
getindex(s::ASCIIString, r::UnitRange{Int}) = ASCIIString(getindex(s.data,r))
21-
getindex(s::ASCIIString, indx::AbstractVector{Int}) = ASCIIString(s.data[indx])
22-
function search(s::ASCIIString, c::Char, i::Integer)
23-
i == sizeof(s) + 1 && return 0
24-
(i < 1 || i > sizeof(s)) && throw(BoundsError(s, i))
25-
return c < Char(0x80) ? search(s.data,c%UInt8,i) : 0
26-
end
27-
rsearch(s::ASCIIString, c::Char, i::Integer) = c < Char(0x80) ? rsearch(s.data,c%UInt8,i) : 0
28-
29-
function string(c::ASCIIString...)
30-
if length(c) == 1
31-
return c[1]
32-
end
33-
n = 0
34-
for s in c
35-
n += length(s.data)
36-
end
37-
v = Array(UInt8,n)
38-
o = 1
39-
for s in c
40-
ls = length(s.data)
41-
unsafe_copy!(v, o, s.data, 1, ls)
42-
o += ls
43-
end
44-
ASCIIString(v)
45-
end
46-
47-
function ucfirst(s::ASCIIString)
48-
if !isempty(s) && 'a' <= s[1] <= 'z'
49-
t = ASCIIString(copy(s.data))
50-
t.data[1] -= 32
51-
return t
52-
end
53-
return s
54-
end
55-
function lcfirst(s::ASCIIString)
56-
if !isempty(s) && 'A' <= s[1] <= 'Z'
57-
t = ASCIIString(copy(s.data))
58-
t.data[1] += 32
59-
return t
60-
end
61-
return s
62-
end
63-
64-
function uppercase(s::ASCIIString)
65-
d = s.data
66-
for i = 1:length(d)
67-
if 'a' <= Char(d[i]) <= 'z'
68-
td = copy(d)
69-
for j = i:length(td)
70-
if 'a' <= Char(td[j]) <= 'z'
71-
td[j] -= 32
72-
end
73-
end
74-
return ASCIIString(td)
75-
end
76-
end
77-
return s
78-
end
79-
function lowercase(s::ASCIIString)
80-
d = s.data
81-
for i = 1:length(d)
82-
if 'A' <= Char(d[i]) <= 'Z'
83-
td = copy(d)
84-
for j = i:length(td)
85-
if 'A' <= Char(td[j]) <= 'Z'
86-
td[j] += 32
87-
end
88-
end
89-
return ASCIIString(td)
90-
end
91-
end
92-
return s
93-
end
94-
95-
reverse(s::ASCIIString) = ASCIIString(reverse(s.data))
96-
97-
## outputing ASCII strings ##
98-
99-
write(io::IO, s::ASCIIString) = write(io, s.data)
100-
101-
## transcoding to ASCII ##
102-
103-
ascii(x) = convert(ASCIIString, x)
104-
convert(::Type{ASCIIString}, s::ASCIIString) = s
105-
convert(::Type{ASCIIString}, s::UTF8String) = ascii(s.data)
106-
convert(::Type{ASCIIString}, a::Vector{UInt8}) = begin
107-
isvalid(ASCIIString,a) || throw(ArgumentError("invalid ASCII sequence"))
108-
return ASCIIString(a)
109-
end
110-
111-
ascii(p::Ptr{UInt8}) =
112-
ascii(p, p == C_NULL ? Csize_t(0) : ccall(:strlen, Csize_t, (Ptr{UInt8},), p))
113-
function ascii(p::Ptr{UInt8}, len::Integer)
114-
p == C_NULL && throw(ArgumentError("cannot convert NULL to string"))
115-
ary = ccall(:jl_pchar_to_array, Vector{UInt8},
116-
(Ptr{UInt8}, Csize_t), p, len)
117-
isvalid(ASCIIString, ary) || throw(ArgumentError("invalid ASCII sequence"))
118-
ASCIIString(ary)
119-
end
120-
121-
function convert(::Type{ASCIIString}, a::Array{UInt8,1}, invalids_as::ASCIIString)
122-
l = length(a)
123-
idx = 1
124-
iscopy = false
125-
while idx <= l
126-
(a[idx] < 0x80) && (idx +=1; continue)
127-
!iscopy && (a = copy(a); iscopy = true)
128-
endn = idx
129-
while endn <= l
130-
(a[endn] < 0x80) && break
131-
endn += 1
132-
end
133-
(endn > idx) && (endn -= 1)
134-
splice!(a, idx:endn, invalids_as.data)
135-
l = length(a)
136-
end
137-
convert(ASCIIString, a)
138-
end
139-
convert(::Type{ASCIIString}, a::Array{UInt8,1}, invalids_as::AbstractString) =
140-
convert(ASCIIString, a, ascii(invalids_as))
141-
convert(::Type{ASCIIString}, s::AbstractString) = ascii(bytestring(s))
3+
ascii(x) = ascii(convert(String, x))
4+
ascii(p::Ptr{UInt8}) = ascii(bytestring(p))
5+
ascii(p::Ptr{UInt8}, len::Integer) = ascii(bytestring(p, len))
6+
ascii(s::String) = byte_string_classify(s.data) == 1 ? s :
7+
throw(ArgumentError("invalid ASCII sequence"))

base/atomics.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function atomic_min! end
183183
unsafe_convert{T}(::Type{Ptr{T}}, x::Atomic{T}) = convert(Ptr{T}, pointer_from_objref(x))
184184
setindex!{T}(x::Atomic{T}, v) = setindex!(x, convert(T, v))
185185

186-
const llvmtypes = Dict{Type, ASCIIString}(
186+
const llvmtypes = Dict(
187187
Bool => "i1",
188188
Int8 => "i8", UInt8 => "i8",
189189
Int16 => "i16", UInt16 => "i16",
@@ -192,7 +192,8 @@ const llvmtypes = Dict{Type, ASCIIString}(
192192
Int128 => "i128", UInt128 => "i128",
193193
Float16 => "i16", # half
194194
Float32 => "float",
195-
Float64 => "double")
195+
Float64 => "double",
196+
)
196197
inttype{T<:Integer}(::Type{T}) = T
197198
inttype(::Type{Float16}) = Int16
198199
inttype(::Type{Float32}) = Int32

base/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ finalize(o::ANY) = ccall(:jl_finalize, Void, (Any,), o)
8282
gc(full::Bool=true) = ccall(:jl_gc_collect, Void, (Cint,), full)
8383
gc_enable(on::Bool) = ccall(:jl_gc_enable, Cint, (Cint,), on)!=0
8484

85-
bytestring(str::ByteString) = str
85+
bytestring(str::String) = str
8686

8787
# used by { } syntax
8888
function cell_1d(xs::ANY...)

0 commit comments

Comments
 (0)