Skip to content

replace ASCIIString & UTF8String with String #16058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type MIState
current_mode
aborted::Bool
mode_state
kill_buffer::ByteString
kill_buffer::String
previous_key::Array{Char,1}
key_repeats::Int
end
Expand Down Expand Up @@ -624,7 +624,7 @@ function write_prompt(terminal, p::Prompt)
write(terminal, Base.text_colors[:normal])
write(terminal, suffix)
end
write_prompt(terminal, s::ByteString) = write(terminal, s)
write_prompt(terminal, s::String) = write(terminal, s)

### Keymap Support

Expand Down Expand Up @@ -703,11 +703,11 @@ end
# This is different from the default eager redirect, which only looks at the current and lower
# layers of the stack.
immutable KeyAlias
seq::ASCIIString
seq::String
KeyAlias(seq) = new(normalize_key(seq))
end

match_input(k::Function, s, term, cs, keymap) = (update_key_repeats(s, cs); return keymap_fcn(k, ByteString(cs)))
match_input(k::Function, s, term, cs, keymap) = (update_key_repeats(s, cs); return keymap_fcn(k, String(cs)))
match_input(k::Void, s, term, cs, keymap) = (s,p) -> return :ok
match_input(k::KeyAlias, s, term, cs, keymap) = match_input(keymap, s, IOBuffer(k.seq), Char[], keymap)
function match_input(k::Dict, s, term=terminal(s), cs=Char[], keymap = k)
Expand Down Expand Up @@ -1013,7 +1013,7 @@ init_state(terminal, p::HistoryPrompt) = SearchState(terminal, p, true, IOBuffer
type PrefixSearchState <: ModeState
terminal
histprompt
prefix::ByteString
prefix::String
response_buffer::IOBuffer
ias::InputAreaState
indent::Int
Expand Down
22 changes: 11 additions & 11 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ end
type LineEditREPL <: AbstractREPL
t::TextTerminal
hascolor::Bool
prompt_color::AbstractString
input_color::AbstractString
answer_color::AbstractString
shell_color::AbstractString
help_color::AbstractString
prompt_color::String
input_color::String
answer_color::String
shell_color::String
help_color::String
history_file::Bool
in_shell::Bool
in_help::Bool
Expand Down Expand Up @@ -297,7 +297,7 @@ end


type REPLHistoryProvider <: HistoryProvider
history::Array{AbstractString,1}
history::Array{String,1}
history_file
start_idx::Int
cur_idx::Int
Expand All @@ -308,7 +308,7 @@ type REPLHistoryProvider <: HistoryProvider
modes::Array{Symbol,1}
end
REPLHistoryProvider(mode_mapping) =
REPLHistoryProvider(AbstractString[], nothing, 0, 0, -1, IOBuffer(),
REPLHistoryProvider(String[], nothing, 0, 0, -1, IOBuffer(),
nothing, mode_mapping, UInt8[])

const invalid_history_message = """
Expand Down Expand Up @@ -356,7 +356,7 @@ function hist_from_file(hp, file)
error(munged_history_message, countlines)
line[1] != '\t' &&
error(invalid_history_message, repr(line[1]), " at line ", countlines)
lines = UTF8String[]
lines = String[]
while !isempty(line)
push!(lines, chomp(line[2:end]))
eof(file) && break
Expand Down Expand Up @@ -893,9 +893,9 @@ end

type StreamREPL <: AbstractREPL
stream::IO
prompt_color::AbstractString
input_color::AbstractString
answer_color::AbstractString
prompt_color::String
input_color::String
answer_color::String
waserror::Bool
StreamREPL(stream,pc,ic,ac) = new(stream,pc,ic,ac,false)
end
Expand Down
40 changes: 20 additions & 20 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
function filtered_mod_names(ffunc::Function, mod::Module, name::AbstractString, all::Bool=false, imported::Bool=false)
ssyms = names(mod, all, imported)
filter!(ffunc, ssyms)
syms = UTF8String[string(s) for s in ssyms]
syms = String[string(s) for s in ssyms]
filter!(x->completes_global(x, name), syms)
end

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

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

function complete_keyword(s::ByteString)
function complete_keyword(s::String)
const sorted_keywords = [
"abstract", "baremodule", "begin", "bitstype", "break", "catch", "ccall",
"const", "continue", "do", "else", "elseif", "end", "export", "false",
Expand Down Expand Up @@ -117,13 +117,13 @@ function complete_path(path::AbstractString, pos; use_envpath=false)
elseif isdir(dir)
files = readdir(dir)
else
return UTF8String[], 0:-1, false
return String[], 0:-1, false
end
catch
return UTF8String[], 0:-1, false
return String[], 0:-1, false
end

matches = Set{UTF8String}()
matches = Set{String}()
for file in files
if startswith(file, prefix)
id = try isdir(joinpath(dir, file)) catch; false end
Expand Down Expand Up @@ -174,7 +174,7 @@ function complete_path(path::AbstractString, pos; use_envpath=false)
end
end

matchList = UTF8String[replace(s, r"\s", "\\ ") for s in matches]
matchList = String[replace(s, r"\s", "\\ ") for s in matches]
startpos = pos - endof(prefix) + 1 - length(matchall(r" ", prefix))
# The pos - endof(prefix) + 1 is correct due to `endof(prefix)-endof(prefix)==0`,
# hence we need to add one to get the first index. This is also correct when considering
Expand Down Expand Up @@ -289,7 +289,7 @@ function get_type_call(expr::Expr)
(tree, return_type) = Core.Inference.typeinf(linfo, m[1], m[2])
return return_type, true
end
# Returns the return type. example: get_type(:(Base.strip("",' ')),Main) returns (ASCIIString,true)
# Returns the return type. example: get_type(:(Base.strip("",' ')),Main) returns (String,true)
function get_type(sym::Expr, fn)
sym=expand(sym)
val, found = get_value(sym, fn)
Expand All @@ -313,12 +313,12 @@ end
function complete_methods(ex_org::Expr)
args_ex = DataType[]
func, found = get_value(ex_org.args[1], Main)
!found && return UTF8String[]
!found && return String[]
for ex in ex_org.args[2:end]
val, found = get_type(ex, Main)
push!(args_ex, val)
end
out = UTF8String[]
out = String[]
t_in = Tuple{Core.Typeof(func), args_ex...} # Input types
na = length(args_ex)+1
for method in methods(func)
Expand All @@ -341,7 +341,7 @@ const bslash_separators = [whitespace_chars..., "\"'`"...]

# Aux function to detect whether we're right after a
# using or import keyword
function afterusing(string::ByteString, startpos::Int)
function afterusing(string::String, startpos::Int)
(isempty(string) || startpos == 0) && return false
str = string[1:prevind(string,startpos)]
isempty(str) && return false
Expand Down Expand Up @@ -376,7 +376,7 @@ function bslash_completions(string, pos)
return (true, (sort!(collect(latex_names)), slashpos:pos, true))
end
end
return (false, (UTF8String[], 0:-1, false))
return (false, (String[], 0:-1, false))
end

function completions(string, pos)
Expand Down Expand Up @@ -404,7 +404,7 @@ function completions(string, pos)
ok && return ret

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

if inc_tag == :other && should_method_complete(partial)
frange, method_name_end = find_start_brace(partial)
Expand All @@ -415,14 +415,14 @@ function completions(string, pos)
return complete_methods(ex), start(frange):method_name_end, false
end
elseif inc_tag == :comment
return UTF8String[], 0:-1, false
return String[], 0:-1, false
end

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

ffunc = (mod,x)->true
suggestions = UTF8String[]
suggestions = String[]
comp_keywords = true
if afterusing(string, startpos)
# We're right after using or import. Let's look only for packages
Expand Down Expand Up @@ -500,10 +500,10 @@ function shell_completions(string, pos)
try
args, last_parse = Base.shell_parse(scs, true)
catch
return UTF8String[], 0:-1, false
return String[], 0:-1, false
end
# Now look at the last thing we parsed
isempty(args.args[end].args) && return UTF8String[], 0:-1, false
isempty(args.args[end].args) && return String[], 0:-1, false
arg = args.args[end].args[end]
if all(s -> isa(s, AbstractString), args.args[end].args)
# Treat this as a path
Expand All @@ -525,7 +525,7 @@ function shell_completions(string, pos)
range += first(r) - 1
return ret, range, true
end
return UTF8String[], 0:-1, false
return String[], 0:-1, false
end

end # module
2 changes: 1 addition & 1 deletion base/Terminals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type TerminalBuffer <: UnixTerminal
end

type TTYTerminal <: UnixTerminal
term_type::ASCIIString
term_type::String
in_stream::Base.TTY
out_stream::Base.TTY
err_stream::Base.TTY
Expand Down
Loading