From 9e1b5ddaf5d7f0212e17a113c67bfbb8174ce15c Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Tue, 26 Apr 2016 16:37:49 -0400 Subject: [PATCH 1/5] replace ASCIIString & UTF8String with String --- base/LineEdit.jl | 10 +- base/REPL.jl | 2 +- base/REPLCompletions.jl | 40 ++-- base/Terminals.jl | 2 +- base/ascii.jl | 144 +------------- base/atomics.jl | 5 +- base/base.jl | 2 +- base/boot.jl | 15 +- base/c.jl | 4 +- base/client.jl | 4 +- base/coreimg.jl | 3 +- base/datafmt.jl | 58 +++--- base/dates/io.jl | 8 +- base/dates/query.jl | 8 +- base/deprecated.jl | 12 +- base/docs/helpdb/Base.jl | 24 +-- base/env.jl | 14 +- base/expr.jl | 5 +- base/fft/FFTW.jl | 2 +- base/file.jl | 6 +- base/gmp.jl | 2 +- base/hashing2.jl | 2 +- base/i18n.jl | 2 +- base/initdefs.jl | 8 +- base/interactiveutil.jl | 6 +- base/intfuncs.jl | 10 +- base/io.jl | 11 +- base/iobuffer.jl | 8 +- base/iostream.jl | 2 +- base/latex_symbols.jl | 2 +- base/libc.jl | 2 +- base/libdl.jl | 6 +- base/libgit2/callbacks.jl | 2 +- base/linalg/arpack.jl | 8 +- base/linalg/exceptions.jl | 2 +- base/loading.jl | 22 +-- base/markdown/Common/block.jl | 4 +- base/markdown/Common/inline.jl | 8 +- base/markdown/IPython/IPython.jl | 2 +- base/methodshow.jl | 4 +- base/parse.jl | 10 +- base/path.jl | 6 +- base/pcre.jl | 2 +- base/pkg.jl | 4 +- base/pkg/entry.jl | 4 +- base/pkg/git.jl | 6 +- base/pkg/query.jl | 64 +++--- base/pkg/read.jl | 10 +- base/pkg/resolve.jl | 16 +- base/pkg/resolve/interface.jl | 18 +- base/pkg/resolve/versionweight.jl | 4 +- base/pkg/types.jl | 4 +- base/pointer.jl | 8 +- base/poll.jl | 4 +- base/precompile.jl | 231 ++++++++++------------ base/printf.jl | 54 ++--- base/process.jl | 28 +-- base/profile.jl | 14 +- base/random.jl | 4 +- base/reflection.jl | 4 +- base/regex.jl | 27 ++- base/require.jl | 6 +- base/rounding.jl | 2 +- base/serialize.jl | 2 +- base/sharedarray.jl | 2 +- base/show.jl | 16 +- base/simdloop.jl | 2 +- base/socket.jl | 7 +- base/sparse/cholmod.jl | 6 +- base/stream.jl | 2 +- base/strings/basic.jl | 25 +-- base/strings/io.jl | 16 +- base/strings/search.jl | 6 +- base/strings/types.jl | 21 +- base/strings/util.jl | 10 +- base/sysimg.jl | 4 +- base/sysinfo.jl | 6 +- base/unicode/types.jl | 4 +- base/unicode/utf16.jl | 11 +- base/unicode/utf32.jl | 25 +-- base/unicode/utf8.jl | 70 ++++--- base/unicode/utf8proc.jl | 7 +- base/version.jl | 22 +-- contrib/Julia_Notepad++.xml | 2 +- contrib/add_license_to_files.jl | 5 +- contrib/julia.hrc | 2 +- contrib/julia.xml | 3 - doc/devdocs/init.rst | 10 +- doc/genstdlib.jl | 6 +- doc/manual/calling-c-and-fortran-code.rst | 6 +- doc/manual/conversion-and-promotion.rst | 2 +- doc/manual/dates.rst | 4 +- doc/manual/interacting-with-julia.rst | 2 +- doc/manual/metaprogramming.rst | 10 +- doc/manual/methods.rst | 10 +- doc/manual/networking-and-streams.rst | 4 +- doc/manual/packages.rst | 2 +- doc/manual/running-external-programs.rst | 8 +- doc/manual/strings.rst | 6 +- doc/manual/types.rst | 4 +- doc/stdlib/base.rst | 2 +- doc/stdlib/collections.rst | 16 +- doc/stdlib/file.rst | 2 +- doc/stdlib/io-network.rst | 4 +- doc/stdlib/numbers.rst | 4 +- doc/stdlib/pkg.rst | 4 +- doc/tabcomplete.jl | 2 +- examples/lru_test.jl | 4 +- src/alloc.c | 3 +- src/array.c | 4 +- src/builtins.c | 2 +- src/init.c | 3 +- src/jlapi.c | 2 +- src/julia.h | 8 +- src/sys.c | 2 +- src/toplevel.c | 2 +- test/cmdlineargs.jl | 10 +- test/core.jl | 10 +- test/dict.jl | 46 ++--- test/docs.jl | 4 +- test/operators.jl | 2 +- test/path.jl | 4 +- test/perf/kernel/actor_centrality.jl | 6 +- test/read.jl | 8 +- test/regex.jl | 2 +- test/remote.jl | 4 +- test/repl.jl | 2 +- test/replcompletions.jl | 10 +- test/replutil.jl | 6 +- test/resolve.jl | 8 +- test/sets.jl | 6 +- test/show.jl | 4 +- test/socket.jl | 22 +-- test/string.jl | 9 +- test/strings/basic.jl | 80 ++++---- test/strings/io.jl | 2 +- test/strings/types.jl | 9 +- test/strings/util.jl | 2 +- test/test_sourcepath.jl | 2 +- test/unicode/utf32.jl | 27 +-- test/unicode/utf8.jl | 24 +-- test/unicode/utf8proc.jl | 4 +- test/version.jl | 8 +- ui/repl.c | 2 +- 144 files changed, 753 insertions(+), 995 deletions(-) diff --git a/base/LineEdit.jl b/base/LineEdit.jl index 6e7b23c211b6d..4106d354da24a 100644 --- a/base/LineEdit.jl +++ b/base/LineEdit.jl @@ -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 @@ -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 @@ -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) @@ -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 diff --git a/base/REPL.jl b/base/REPL.jl index 6ce6fece64d32..e6a6623e36e4d 100644 --- a/base/REPL.jl +++ b/base/REPL.jl @@ -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 diff --git a/base/REPLCompletions.jl b/base/REPLCompletions.jl index 117f1156a4a64..4709cb07ffd4b 100644 --- a/base/REPLCompletions.jl +++ b/base/REPLCompletions.jl @@ -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 @@ -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 @@ -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", @@ -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 @@ -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 @@ -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) @@ -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) @@ -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 @@ -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) @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/base/Terminals.jl b/base/Terminals.jl index 433a0933304b0..5e1483a5f5c1b 100644 --- a/base/Terminals.jl +++ b/base/Terminals.jl @@ -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 diff --git a/base/ascii.jl b/base/ascii.jl index 21c3e2a337c7d..bb5dd899d52a1 100644 --- a/base/ascii.jl +++ b/base/ascii.jl @@ -1,141 +1,7 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license -## from base/boot.jl: -# -# immutable ASCIIString <: DirectIndexString -# data::Array{UInt8,1} -# end -# - -## required core functionality ## - -endof(s::ASCIIString) = length(s.data) -getindex(s::ASCIIString, i::Int) = (x=s.data[i]; ifelse(x < 0x80, Char(x), '\ufffd')) - -## overload methods for efficiency ## - -sizeof(s::ASCIIString) = sizeof(s.data) - -getindex(s::ASCIIString, r::Vector) = ASCIIString(getindex(s.data,r)) -getindex(s::ASCIIString, r::UnitRange{Int}) = ASCIIString(getindex(s.data,r)) -getindex(s::ASCIIString, indx::AbstractVector{Int}) = ASCIIString(s.data[indx]) -function search(s::ASCIIString, c::Char, i::Integer) - i == sizeof(s) + 1 && return 0 - (i < 1 || i > sizeof(s)) && throw(BoundsError(s, i)) - return c < Char(0x80) ? search(s.data,c%UInt8,i) : 0 -end -rsearch(s::ASCIIString, c::Char, i::Integer) = c < Char(0x80) ? rsearch(s.data,c%UInt8,i) : 0 - -function string(c::ASCIIString...) - if length(c) == 1 - return c[1] - end - n = 0 - for s in c - n += length(s.data) - end - v = Array(UInt8,n) - o = 1 - for s in c - ls = length(s.data) - unsafe_copy!(v, o, s.data, 1, ls) - o += ls - end - ASCIIString(v) -end - -function ucfirst(s::ASCIIString) - if !isempty(s) && 'a' <= s[1] <= 'z' - t = ASCIIString(copy(s.data)) - t.data[1] -= 32 - return t - end - return s -end -function lcfirst(s::ASCIIString) - if !isempty(s) && 'A' <= s[1] <= 'Z' - t = ASCIIString(copy(s.data)) - t.data[1] += 32 - return t - end - return s -end - -function uppercase(s::ASCIIString) - d = s.data - for i = 1:length(d) - if 'a' <= Char(d[i]) <= 'z' - td = copy(d) - for j = i:length(td) - if 'a' <= Char(td[j]) <= 'z' - td[j] -= 32 - end - end - return ASCIIString(td) - end - end - return s -end -function lowercase(s::ASCIIString) - d = s.data - for i = 1:length(d) - if 'A' <= Char(d[i]) <= 'Z' - td = copy(d) - for j = i:length(td) - if 'A' <= Char(td[j]) <= 'Z' - td[j] += 32 - end - end - return ASCIIString(td) - end - end - return s -end - -reverse(s::ASCIIString) = ASCIIString(reverse(s.data)) - -## outputing ASCII strings ## - -write(io::IO, s::ASCIIString) = write(io, s.data) - -## transcoding to ASCII ## - -ascii(x) = convert(ASCIIString, x) -convert(::Type{ASCIIString}, s::ASCIIString) = s -convert(::Type{ASCIIString}, s::UTF8String) = ascii(s.data) -convert(::Type{ASCIIString}, a::Vector{UInt8}) = begin - isvalid(ASCIIString,a) || throw(ArgumentError("invalid ASCII sequence")) - return ASCIIString(a) -end - -ascii(p::Ptr{UInt8}) = - ascii(p, p == C_NULL ? Csize_t(0) : ccall(:strlen, Csize_t, (Ptr{UInt8},), p)) -function ascii(p::Ptr{UInt8}, len::Integer) - p == C_NULL && throw(ArgumentError("cannot convert NULL to string")) - ary = ccall(:jl_pchar_to_array, Vector{UInt8}, - (Ptr{UInt8}, Csize_t), p, len) - isvalid(ASCIIString, ary) || throw(ArgumentError("invalid ASCII sequence")) - ASCIIString(ary) -end - -function convert(::Type{ASCIIString}, a::Array{UInt8,1}, invalids_as::ASCIIString) - l = length(a) - idx = 1 - iscopy = false - while idx <= l - (a[idx] < 0x80) && (idx +=1; continue) - !iscopy && (a = copy(a); iscopy = true) - endn = idx - while endn <= l - (a[endn] < 0x80) && break - endn += 1 - end - (endn > idx) && (endn -= 1) - splice!(a, idx:endn, invalids_as.data) - l = length(a) - end - convert(ASCIIString, a) -end -convert(::Type{ASCIIString}, a::Array{UInt8,1}, invalids_as::AbstractString) = - convert(ASCIIString, a, ascii(invalids_as)) -convert(::Type{ASCIIString}, s::AbstractString) = ascii(bytestring(s)) +ascii(x) = ascii(convert(String, x)) +ascii(p::Ptr{UInt8}) = ascii(bytestring(p)) +ascii(p::Ptr{UInt8}, len::Integer) = ascii(bytestring(p, len)) +ascii(s::String) = byte_string_classify(s.data) == 1 ? s : + throw(ArgumentError("invalid ASCII sequence")) diff --git a/base/atomics.jl b/base/atomics.jl index bed8e112aafb9..7cfc6efe7e957 100644 --- a/base/atomics.jl +++ b/base/atomics.jl @@ -185,7 +185,7 @@ function atomic_min! end unsafe_convert{T}(::Type{Ptr{T}}, x::Atomic{T}) = convert(Ptr{T}, pointer_from_objref(x)) setindex!{T}(x::Atomic{T}, v) = setindex!(x, convert(T, v)) -const llvmtypes = Dict{Type, ASCIIString}( +const llvmtypes = Dict( Bool => "i1", Int8 => "i8", UInt8 => "i8", Int16 => "i16", UInt16 => "i16", @@ -194,7 +194,8 @@ const llvmtypes = Dict{Type, ASCIIString}( Int128 => "i128", UInt128 => "i128", Float16 => "i16", # half Float32 => "float", - Float64 => "double") + Float64 => "double", +) inttype{T<:Integer}(::Type{T}) = T inttype(::Type{Float16}) = Int16 inttype(::Type{Float32}) = Int32 diff --git a/base/base.jl b/base/base.jl index b847a426d21d2..3fac9efceb6a4 100644 --- a/base/base.jl +++ b/base/base.jl @@ -82,7 +82,7 @@ finalize(o::ANY) = ccall(:jl_finalize, Void, (Any,), o) gc(full::Bool=true) = ccall(:jl_gc_collect, Void, (Cint,), full) gc_enable(on::Bool) = ccall(:jl_gc_enable, Cint, (Cint,), on)!=0 -bytestring(str::ByteString) = str +bytestring(str::String) = str # used by { } syntax function cell_1d(xs::ANY...) diff --git a/base/boot.jl b/base/boot.jl index 0d07ca8ae7c67..db55a2aecc3e6 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -132,7 +132,7 @@ export Signed, Int, Int8, Int16, Int32, Int64, Int128, Unsigned, UInt, UInt8, UInt16, UInt32, UInt64, UInt128, # string types - Char, ASCIIString, ByteString, DirectIndexString, AbstractString, UTF8String, + Char, DirectIndexString, AbstractString, String, # errors BoundsError, DivideError, DomainError, Exception, InexactError, InterruptException, OutOfMemoryError, ReadOnlyMemoryError, OverflowError, @@ -218,19 +218,12 @@ end abstract DirectIndexString <: AbstractString -immutable ASCIIString <: DirectIndexString +immutable String <: AbstractString data::Array{UInt8,1} - ASCIIString(d::Array{UInt8,1}) = new(d) + String(d::Array{UInt8,1}) = new(d) end -immutable UTF8String <: AbstractString - data::Array{UInt8,1} - UTF8String(d::Array{UInt8,1}) = new(d) -end - -typealias ByteString Union{ASCIIString,UTF8String} - -include(fname::ByteString) = ccall(:jl_load_, Any, (Any,), fname) +include(fname::String) = ccall(:jl_load_, Any, (Any,), fname) eval(e::ANY) = eval(Main, e) eval(m::Module, e::ANY) = ccall(:jl_toplevel_eval_in, Any, (Any, Any), m, e) diff --git a/base/c.jl b/base/c.jl index 8a30c5ab9635a..3b32f683d4965 100644 --- a/base/c.jl +++ b/base/c.jl @@ -76,12 +76,12 @@ pointer(p::Cwstring) = convert(Ptr{Cwchar_t}, p) # here, not in pointer.jl, to avoid bootstrapping problems in coreimg.jl pointer_to_string(p::Cstring, own::Bool=false) = pointer_to_string(convert(Ptr{UInt8}, p), own) -# convert strings to ByteString etc. to pass as pointers +# convert strings to String etc. to pass as pointers cconvert(::Type{Cstring}, s::AbstractString) = bytestring(s) cconvert(::Type{Cwstring}, s::AbstractString) = wstring(s) containsnul(p::Ptr, len) = C_NULL != ccall(:memchr, Ptr{Cchar}, (Ptr{Cchar}, Cint, Csize_t), p, 0, len) -function unsafe_convert(::Type{Cstring}, s::ByteString) +function unsafe_convert(::Type{Cstring}, s::String) p = unsafe_convert(Ptr{Cchar}, s) if containsnul(p, sizeof(s)) throw(ArgumentError("embedded NULs are not allowed in C strings: $(repr(s))")) diff --git a/base/client.jl b/base/client.jl index 1b5f65d4fc793..55aee8879274f 100644 --- a/base/client.jl +++ b/base/client.jl @@ -153,7 +153,7 @@ function syntax_deprecation_warnings(f::Function, warn::Bool) end end -function parse_input_line(s::ByteString; filename::ByteString="none") +function parse_input_line(s::String; filename::String="none") # (expr, pos) = parse(s, 1) # (ex, pos) = ccall(:jl_parse_string, Any, # (Ptr{UInt8},Csize_t,Int32,Int32), @@ -256,7 +256,7 @@ function process_options(opts::JLOptions) # program repl = false # remove filename from ARGS - global PROGRAM_FILE = UTF8String(shift!(ARGS)) + global PROGRAM_FILE = String(shift!(ARGS)) if !is_interactive ccall(:jl_exit_on_sigint, Void, (Cint,), 1) end diff --git a/base/coreimg.jl b/base/coreimg.jl index 0ca2e883ad116..7b5340ce7af0d 100644 --- a/base/coreimg.jl +++ b/base/coreimg.jl @@ -45,8 +45,7 @@ if !isdefined(Main, :Base) end # Symbol constructors -Symbol(s::ASCIIString) = Symbol(s.data) -Symbol(s::UTF8String) = Symbol(s.data) +Symbol(s::String) = Symbol(s.data) Symbol(a::Array{UInt8,1}) = ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Int32), a, length(a)) diff --git a/base/datafmt.jl b/base/datafmt.jl index e25dcf29bf6d7..f9b3cb1e9ce72 100644 --- a/base/datafmt.jl +++ b/base/datafmt.jl @@ -63,10 +63,6 @@ function as_mmap(fname::AbstractString, fsz::Int64) end end -function ascii_if_possible(sbuff::AbstractString) - isascii(sbuff) ? convert(ASCIIString, sbuff) : sbuff -end - # # Handlers act on events generated by the parser. # Parser calls store_cell on the handler to pass events. @@ -81,7 +77,7 @@ type DLMOffsets <: DLMHandler thresh::Int bufflen::Int - function DLMOffsets(sbuff::ByteString) + function DLMOffsets(sbuff::String) offsets = Array(Array{Int,1}, 1) offsets[1] = Array(Int, offs_chunk_size) thresh = ceil(min(typemax(UInt), Base.Sys.total_memory()) / sizeof(Int) / 5) @@ -126,7 +122,7 @@ function result(dlmoffsets::DLMOffsets) dlmoffsets.oarr end -type DLMStore{T,S<:ByteString} <: DLMHandler +type DLMStore{T} <: DLMHandler hdr::Array{AbstractString, 2} data::Array{T, 2} @@ -135,26 +131,26 @@ type DLMStore{T,S<:ByteString} <: DLMHandler lastrow::Int lastcol::Int hdr_offset::Int - sbuff::S + sbuff::String auto::Bool eol::Char end -function DLMStore{T,S<:ByteString}(::Type{T}, dims::NTuple{2,Integer}, - has_header::Bool, sbuff::S, auto::Bool, eol::Char) +function DLMStore{T}(::Type{T}, dims::NTuple{2,Integer}, + has_header::Bool, sbuff::String, auto::Bool, eol::Char) (nrows,ncols) = dims nrows <= 0 && throw(ArgumentError("number of rows in dims must be > 0, got $nrows")) ncols <= 0 && throw(ArgumentError("number of columns in dims must be > 0, got $ncols")) hdr_offset = has_header ? 1 : 0 - DLMStore{T,S}(fill(SubString(sbuff,1,0), 1, ncols), Array(T, nrows-hdr_offset, ncols), + DLMStore{T}(fill(SubString(sbuff,1,0), 1, ncols), Array(T, nrows-hdr_offset, ncols), nrows, ncols, 0, 0, hdr_offset, sbuff, auto, eol) end -_chrinstr(sbuff::ByteString, chr::UInt8, startpos::Int, endpos::Int) = +_chrinstr(sbuff::String, chr::UInt8, startpos::Int, endpos::Int) = (endpos >= startpos) && (C_NULL != ccall(:memchr, Ptr{UInt8}, (Ptr{UInt8}, Int32, Csize_t), pointer(sbuff.data)+startpos-1, chr, endpos-startpos+1)) -function store_cell{T,S<:ByteString}(dlmstore::DLMStore{T,S}, row::Int, col::Int, +function store_cell{T}(dlmstore::DLMStore{T}, row::Int, col::Int, quoted::Bool, startpos::Int, endpos::Int) drow = row - dlmstore.hdr_offset @@ -162,7 +158,7 @@ function store_cell{T,S<:ByteString}(dlmstore::DLMStore{T,S}, row::Int, col::Int lastcol = dlmstore.lastcol lastrow = dlmstore.lastrow cells::Array{T,2} = dlmstore.data - sbuff::S = dlmstore.sbuff + sbuff = dlmstore.sbuff endpos = prevind(sbuff, nextind(sbuff,endpos)) if (endpos > 0) && ('\n' == dlmstore.eol) && ('\r' == Char(sbuff[endpos])) @@ -253,7 +249,7 @@ function result{T}(dlmstore::DLMStore{T}) end -function readdlm_string(sbuff::ByteString, dlm::Char, T::Type, eol::Char, auto::Bool, optsd::Dict) +function readdlm_string(sbuff::String, dlm::Char, T::Type, eol::Char, auto::Bool, optsd::Dict) ign_empty = (dlm == invalid_dlm(Char)) quotes = get(optsd, :quotes, true) comments = get(optsd, :comments, true) @@ -277,8 +273,6 @@ function readdlm_string(sbuff::ByteString, dlm::Char, T::Type, eol::Char, auto:: catch ex if isa(ex, TypeError) && (ex.func == :store_cell) T = ex.expected - elseif get(optsd, :ignore_invalid_chars, false) - sbuff = ascii_if_possible(convert(typeof(sbuff), sbuff.data, "")) else rethrow(ex) end @@ -295,8 +289,8 @@ function readdlm_string(sbuff::ByteString, dlm::Char, T::Type, eol::Char, auto:: return readdlm_string(sbuff, dlm, T, eol, auto, optsd) end -const valid_opts = [:header, :has_header, :ignore_invalid_chars, :use_mmap, :quotes, :comments, :dims, :comment_char, :skipstart, :skipblanks] -const valid_opt_types = [Bool, Bool, Bool, Bool, Bool, Bool, NTuple{2,Integer}, Char, Integer, Bool] +const valid_opts = [:header, :has_header, :use_mmap, :quotes, :comments, :dims, :comment_char, :skipstart, :skipblanks] +const valid_opt_types = [Bool, Bool, Bool, Bool, Bool, NTuple{2,Integer}, Char, Integer, Bool] const deprecated_opts = Dict(:has_header => :header) function val_opts(opts) d = Dict{Symbol,Union{Bool,NTuple{2,Integer},Char,Integer}}() @@ -310,7 +304,7 @@ function val_opts(opts) d end -function dlm_fill(T::DataType, offarr::Vector{Vector{Int}}, dims::NTuple{2,Integer}, has_header::Bool, sbuff::ByteString, auto::Bool, eol::Char) +function dlm_fill(T::DataType, offarr::Vector{Vector{Int}}, dims::NTuple{2,Integer}, has_header::Bool, sbuff::String, auto::Bool, eol::Char) idx = 1 offidx = 1 offsets = offarr[1] @@ -336,31 +330,31 @@ function dlm_fill(T::DataType, offarr::Vector{Vector{Int}}, dims::NTuple{2,Integ end end -function colval{S<:ByteString}(sbuff::S, startpos::Int, endpos::Int, cells::Array{Bool,2}, row::Int, col::Int) +function colval(sbuff::String, startpos::Int, endpos::Int, cells::Array{Bool,2}, row::Int, col::Int) n = tryparse_internal(Bool, sbuff, startpos, endpos, false) isnull(n) || (cells[row, col] = get(n)) isnull(n) end -function colval{T<:Integer, S<:ByteString}(sbuff::S, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int) +function colval{T<:Integer}(sbuff::String, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int) n = tryparse_internal(T, sbuff, startpos, endpos, 0, false) isnull(n) || (cells[row, col] = get(n)) isnull(n) end -function colval(sbuff::ByteString, startpos::Int, endpos::Int, cells::Array{Float64,2}, row::Int, col::Int) +function colval(sbuff::String, startpos::Int, endpos::Int, cells::Array{Float64,2}, row::Int, col::Int) n = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), sbuff, startpos-1, endpos-startpos+1) isnull(n) || (cells[row, col] = get(n)) isnull(n) end -function colval(sbuff::ByteString, startpos::Int, endpos::Int, cells::Array{Float32,2}, row::Int, col::Int) +function colval(sbuff::String, startpos::Int, endpos::Int, cells::Array{Float32,2}, row::Int, col::Int) n = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8}, Csize_t, Csize_t), sbuff, startpos-1, endpos-startpos+1) isnull(n) || (cells[row, col] = get(n)) isnull(n) end -function colval{T<:AbstractString, S<:ByteString}(sbuff::S, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int) +function colval{T<:AbstractString}(sbuff::String, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int) cells[row, col] = SubString(sbuff, startpos, endpos) return false end -function colval{S<:ByteString}(sbuff::S, startpos::Int, endpos::Int, cells::Array{Any,2}, row::Int, col::Int) +function colval(sbuff::String, startpos::Int, endpos::Int, cells::Array{Any,2}, row::Int, col::Int) # if array is of Any type, attempt parsing only the most common types: Int, Bool, Float64 and fallback to SubString len = endpos-startpos+1 if len > 0 @@ -379,7 +373,7 @@ function colval{S<:ByteString}(sbuff::S, startpos::Int, endpos::Int, cells::Arra cells[row, col] = SubString(sbuff, startpos, endpos) false end -function colval{T<:Char, S<:ByteString}(sbuff::S, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int) +function colval{T<:Char}(sbuff::String, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int) if startpos == endpos cells[row, col] = next(sbuff, startpos)[1] return false @@ -387,15 +381,7 @@ function colval{T<:Char, S<:ByteString}(sbuff::S, startpos::Int, endpos::Int, ce return true end end -colval{S<:ByteString}(sbuff::S, startpos::Int, endpos::Int, cells::Array, row::Int, col::Int) = true - -function dlm_parse(s::ASCIIString, eol::Char, dlm::Char, qchar::Char, cchar::Char, - ign_adj_dlm::Bool, allow_quote::Bool, allow_comments::Bool, - skipstart::Int, skipblanks::Bool, dh::DLMHandler) - dlm_parse(s.data, reinterpret(UInt32, eol) % UInt8, reinterpret(UInt32, dlm) % UInt8, - reinterpret(UInt32, qchar) % UInt8, reinterpret(UInt32, cchar) % UInt8, - ign_adj_dlm, allow_quote, allow_comments, skipstart, skipblanks, dh) -end +colval(sbuff::String, startpos::Int, endpos::Int, cells::Array, row::Int, col::Int) = true function dlm_parse{T,D}(dbuff::T, eol::D, dlm::D, qchar::D, cchar::D, ign_adj_dlm::Bool, allow_quote::Bool, allow_comments::Bool, @@ -404,7 +390,7 @@ function dlm_parse{T,D}(dbuff::T, eol::D, dlm::D, qchar::D, cchar::D, isascii(dlm) && (!allow_quote || isascii(qchar)) && (!allow_comments || isascii(cchar))) - if (T <: UTF8String) && all_ascii + if T === String && all_ascii return dlm_parse(dbuff.data, eol % UInt8, dlm % UInt8, qchar % UInt8, cchar % UInt8, ign_adj_dlm, allow_quote, allow_comments, skipstart, skipblanks, dh) end diff --git a/base/dates/io.jl b/base/dates/io.jl index 0291b811f27ef..0daa133d96463 100644 --- a/base/dates/io.jl +++ b/base/dates/io.jl @@ -24,14 +24,14 @@ end Base.show(io::IO,x::Date) = print(io,string(x)) ### Parsing -const english = Dict{UTF8String,Int}("january"=>1,"february"=>2,"march"=>3,"april"=>4, +const english = Dict{String,Int}("january"=>1,"february"=>2,"march"=>3,"april"=>4, "may"=>5,"june"=>6,"july"=>7,"august"=>8,"september"=>9, "october"=>10,"november"=>11,"december"=>12) -const abbrenglish = Dict{UTF8String,Int}("jan"=>1,"feb"=>2,"mar"=>3,"apr"=>4, +const abbrenglish = Dict{String,Int}("jan"=>1,"feb"=>2,"mar"=>3,"apr"=>4, "may"=>5,"jun"=>6,"jul"=>7,"aug"=>8,"sep"=>9, "oct"=>10,"nov"=>11,"dec"=>12) -const MONTHTOVALUE = Dict{UTF8String,Dict{UTF8String,Int}}("english"=>english) -const MONTHTOVALUEABBR = Dict{UTF8String,Dict{UTF8String,Int}}("english"=>abbrenglish) +const MONTHTOVALUE = Dict{String,Dict{String,Int}}("english"=>english) +const MONTHTOVALUEABBR = Dict{String,Dict{String,Int}}("english"=>abbrenglish) # Date/DateTime Parsing abstract Slot{T<:Any} diff --git a/base/dates/query.jl b/base/dates/query.jl index 297cba19a690f..999b49bced45c 100644 --- a/base/dates/query.jl +++ b/base/dates/query.jl @@ -31,10 +31,10 @@ const Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday = 1,2,3,4,5,6,7 const Mon,Tue,Wed,Thu,Fri,Sat,Sun = 1,2,3,4,5,6,7 const english_daysofweek = Dict(1=>"Monday",2=>"Tuesday",3=>"Wednesday", 4=>"Thursday",5=>"Friday",6=>"Saturday",7=>"Sunday") -const VALUETODAYOFWEEK = Dict{UTF8String,Dict{Int,UTF8String}}("english"=>english_daysofweek) +const VALUETODAYOFWEEK = Dict{String,Dict{Int,String}}("english"=>english_daysofweek) const english_daysofweekabbr = Dict(1=>"Mon",2=>"Tue",3=>"Wed", 4=>"Thu",5=>"Fri",6=>"Sat",7=>"Sun") -const VALUETODAYOFWEEKABBR = Dict{UTF8String,Dict{Int,UTF8String}}("english"=>english_daysofweekabbr) +const VALUETODAYOFWEEKABBR = Dict{String,Dict{Int,String}}("english"=>english_daysofweekabbr) dayname(dt::Integer;locale::AbstractString="english") = VALUETODAYOFWEEK[locale][dt] """ @@ -110,11 +110,11 @@ const Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec = 1,2,3,4,5,6,7,8,9,10,11, const english_months = Dict(1=>"January",2=>"February",3=>"March",4=>"April", 5=>"May",6=>"June",7=>"July",8=>"August",9=>"September", 10=>"October",11=>"November",12=>"December") -const VALUETOMONTH = Dict{UTF8String,Dict{Int,UTF8String}}("english"=>english_months) +const VALUETOMONTH = Dict{String,Dict{Int,String}}("english"=>english_months) const englishabbr_months = Dict(1=>"Jan",2=>"Feb",3=>"Mar",4=>"Apr", 5=>"May",6=>"Jun",7=>"Jul",8=>"Aug",9=>"Sep", 10=>"Oct",11=>"Nov",12=>"Dec") -const VALUETOMONTHABBR = Dict{UTF8String,Dict{Int,UTF8String}}("english"=>englishabbr_months) +const VALUETOMONTHABBR = Dict{String,Dict{Int,String}}("english"=>englishabbr_months) monthname(dt::Integer;locale::AbstractString="english") = VALUETOMONTH[locale][dt] monthabbr(dt::Integer;locale::AbstractString="english") = VALUETOMONTHABBR[locale][dt] diff --git a/base/deprecated.jl b/base/deprecated.jl index 6d482de97338f..e166784739771 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -148,8 +148,6 @@ end @deprecate inf{T<:AbstractFloat}(::Type{T}) convert(T,Inf) @deprecate nan{T<:AbstractFloat}(::Type{T}) convert(T,NaN) -@deprecate_binding String AbstractString - # 13221 - when removing Uint deprecation, remove hack in jl_binding_deprecation_warning @deprecate_binding Uint UInt @deprecate_binding Uint8 UInt8 @@ -488,13 +486,11 @@ export float32_isvalid, float64_isvalid # 11241 @deprecate is_valid_char(ch::Char) isvalid(ch) -@deprecate is_valid_ascii(str::ASCIIString) isvalid(str) -@deprecate is_valid_utf8(str::UTF8String) isvalid(str) +@deprecate is_valid_utf8(str::String) isvalid(str) @deprecate is_valid_utf16(str::UTF16String) isvalid(str) @deprecate is_valid_utf32(str::UTF32String) isvalid(str) @deprecate is_valid_char(ch) isvalid(Char, ch) -@deprecate is_valid_ascii(str) isvalid(ASCIIString, str) -@deprecate is_valid_utf8(str) isvalid(UTF8String, str) +@deprecate is_valid_utf8(str) isvalid(String, str) @deprecate is_valid_utf16(str) isvalid(UTF16String, str) @deprecate is_valid_utf32(str) isvalid(UTF32String, str) @@ -1111,6 +1107,10 @@ macro ccallable(def) error("expected method definition in @ccallable") end +@deprecate_binding ASCIIString String +@deprecate_binding UTF8String String +@deprecate_binding ByteString String + # During the 0.5 development cycle, do not add any deprecations below this line # To be deprecated in 0.6 diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index cf719dabb9e1c..2d9a23f9f3121 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -1858,23 +1858,23 @@ value for that key will be the value it has in the last collection listed. ```jldoctest julia> a = Dict("foo" => 0.0, "bar" => 42.0) -Dict{ASCIIString,Float64} with 2 entries: +Dict{String,Float64} with 2 entries: "bar" => 42.0 "foo" => 0.0 julia> b = Dict(utf8("baz") => 17, utf8("bar") => 4711) -Dict{UTF8String,Int64} with 2 entries: +Dict{String,Int64} with 2 entries: "bar" => 4711 "baz" => 17 julia> merge(a, b) -Dict{UTF8String,Float64} with 3 entries: +Dict{String,Float64} with 3 entries: "bar" => 4711.0 "baz" => 17.0 "foo" => 0.0 julia> merge(b, a) -Dict{UTF8String,Float64} with 3 entries: +Dict{String,Float64} with 3 entries: "bar" => 42.0 "baz" => 17.0 "foo" => 0.0 @@ -3487,7 +3487,7 @@ digits bytes2hex(bin_arr::Array{UInt8, 1}) Convert an array of bytes to its hexadecimal representation. All characters are in -lower-case. Returns an `ASCIIString`. +lower-case. Returns an `String`. """ bytes2hex @@ -3647,7 +3647,7 @@ multiple of four, this is equivalent to a `copy`. rotr90(A, k) """ - readdir([dir]) -> Vector{ByteString} + readdir([dir]) -> Vector{String} Returns the files and directories in the directory `dir` (or the current working directory if not given). """ @@ -3728,7 +3728,7 @@ second variant. popdisplay """ - readdlm(source, delim::Char, T::Type, eol::Char; header=false, skipstart=0, skipblanks=true, use_mmap, ignore_invalid_chars=false, quotes=true, dims, comments=true, comment_char='#') + readdlm(source, delim::Char, T::Type, eol::Char; header=false, skipstart=0, skipblanks=true, use_mmap, quotes=true, dims, comments=true, comment_char='#') Read a matrix from the source where each line (separated by `eol`) gives one row, with elements separated by the given delimiter. The source can be a text file, stream or byte @@ -3737,7 +3737,7 @@ mapped segment as source. If `T` is a numeric type, the result is an array of that type, with any non-numeric elements as `NaN` for floating-point types, or zero. Other useful values of `T` include -`ASCIIString`, `AbstractString`, and `Any`. +`String`, `AbstractString`, and `Any`. If `header` is `true`, the first row of data will be read as header and the tuple `(data_cells, header_cells)` is returned instead of only `data_cells`. @@ -4568,7 +4568,7 @@ Determines whether a path is absolute (begins at the root directory). isabspath """ - hex2bytes(s::ASCIIString) + hex2bytes(s::AbstractString) Convert an arbitrarily long hexadecimal string to its binary representation. Returns an `Array{UInt8,1}`, i.e. an array of bytes. @@ -5283,7 +5283,7 @@ Compute sine of `x`, where `x` is in radians. sin """ - Base.compilecache(module::ByteString) + Base.compilecache(module::String) Creates a precompiled cache file for module (see help for `require`) and all of its dependencies. This can be used to reduce package load times. Cache files are stored in @@ -6106,7 +6106,7 @@ are taken from 2-tuples `(key,value)` generated by the argument. ```jldoctest julia> Dict([("A", 1), ("B", 2)]) -Dict{ASCIIString,Int64} with 2 entries: +Dict{String,Int64} with 2 entries: "B" => 2 "A" => 1 ``` @@ -6115,7 +6115,7 @@ Alternatively, a sequence of pair arguments may be passed. ```jldoctest julia> Dict("A"=>1, "B"=>2) -Dict{ASCIIString,Int64} with 2 entries: +Dict{String,Int64} with 2 entries: "B" => 2 "A" => 1 ``` diff --git a/base/env.jl b/base/env.jl index 876e32b807b41..571a67835c757 100644 --- a/base/env.jl +++ b/base/env.jl @@ -42,7 +42,7 @@ function access_env(onError::Function, str::AbstractString) error(string("getenv: ", str, ' ', len, "-1 != ", ret, ": ", Libc.FormatMessage())) end pop!(val) # NUL - return UTF8String(utf16to8(val)) + return String(utf16to8(val)) end function _setenv(svar::AbstractString, sval::AbstractString, overwrite::Bool=true) @@ -64,10 +64,10 @@ end # @windows_only ## ENV: hash interface ## -type EnvHash <: Associative{ByteString,ByteString}; end +type EnvHash <: Associative{String,String}; end const ENV = EnvHash() -similar(::EnvHash) = Dict{ByteString,ByteString}() +similar(::EnvHash) = Dict{String,String}() getindex(::EnvHash, k::AbstractString) = access_env(k->throw(KeyError(k)), k) get(::EnvHash, k::AbstractString, def) = access_env(k->def, k) @@ -88,12 +88,12 @@ function next(::EnvHash, i) if env === nothing throw(BoundsError()) end - env::ByteString + env::String m = match(r"^(.*?)=(.*)$"s, env) if m === nothing error("malformed environment entry: $env") end - (Pair{ByteString,ByteString}(m.captures[1], m.captures[2]), i+1) + (Pair{String,String}(m.captures[1], m.captures[2]), i+1) end end @@ -112,12 +112,12 @@ function next(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}}) len = ccall(:wcslen, UInt, (Ptr{UInt16},), pos) buf = Array(UInt16, len) unsafe_copy!(pointer(buf), pos, len) - env = UTF8String(utf16to8(buf)) + env = String(utf16to8(buf)) m = match(r"^(=?[^=]+)=(.*)$"s, env) if m === nothing error("malformed environment entry: $env") end - (Pair{ByteString,ByteString}(m.captures[1], m.captures[2]), (pos+len*2, blk)) + (Pair{String,String}(m.captures[1], m.captures[2]), (pos+len*2, blk)) end end diff --git a/base/expr.jl b/base/expr.jl index f52a84fba6df5..12ca0dae3b134 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -4,11 +4,10 @@ gensym() = ccall(:jl_gensym, Ref{Symbol}, ()) -gensym(s::ASCIIString) = gensym(s.data) -gensym(s::UTF8String) = gensym(s.data) +gensym(s::String) = gensym(s.data) gensym(a::Array{UInt8,1}) = ccall(:jl_tagged_gensym, Ref{Symbol}, (Ptr{UInt8}, Int32), a, length(a)) -gensym(ss::Union{ASCIIString, UTF8String}...) = map(gensym, ss) +gensym(ss::String...) = map(gensym, ss) gensym(s::Symbol) = ccall(:jl_tagged_gensym, Ref{Symbol}, (Ptr{UInt8}, Int32), s, ccall(:strlen, Csize_t, (Ptr{UInt8},), s)) diff --git a/base/fft/FFTW.jl b/base/fft/FFTW.jl index b4a8cec56ee01..3cf93af66a241 100644 --- a/base/fft/FFTW.jl +++ b/base/fft/FFTW.jl @@ -54,7 +54,7 @@ const RODFT01 = 8 const RODFT10 = 9 const RODFT11 = 10 -let k2s = Dict{Int,ASCIIString}(R2HC => "R2HC", HC2R => "HC2R", DHT => "DHT", REDFT00 => "REDFT00", REDFT01 => "REDFT01", REDFT10 => "REDFT10", REDFT11 => "REDFT11", RODFT00 => "RODFT00", RODFT01 => "RODFT01", RODFT10 => "RODFT10", RODFT11 => "RODFT11") +let k2s = Dict(R2HC => "R2HC", HC2R => "HC2R", DHT => "DHT", REDFT00 => "REDFT00", REDFT01 => "REDFT01", REDFT10 => "REDFT10", REDFT11 => "REDFT11", RODFT00 => "RODFT00", RODFT01 => "RODFT01", RODFT10 => "RODFT10", RODFT11 => "RODFT11") global kind2string kind2string(k::Integer) = k2s[Int(k)] end diff --git a/base/file.jl b/base/file.jl index 5663477661612..10573dba7aa45 100644 --- a/base/file.jl +++ b/base/file.jl @@ -220,7 +220,7 @@ function tempdir() error("GetTempPath failed: $(Libc.FormatMessage())") end resize!(temppath,lentemppath) - return UTF8String(utf16to8(temppath)) + return String(utf16to8(temppath)) end tempname(uunique::UInt32=UInt32(0)) = tempname(tempdir(), uunique) const temp_prefix = cwstring("jl_") @@ -233,7 +233,7 @@ function tempname(temppath::AbstractString,uunique::UInt32) error("GetTempFileName failed: $(Libc.FormatMessage())") end resize!(tname,lentname) - return UTF8String(utf16to8(tname)) + return String(utf16to8(tname)) end function mktemp(parent=tempdir()) filename = tempname(parent, UInt32(0)) @@ -287,7 +287,7 @@ function readdir(path::AbstractString) # The list of dir entries is returned as a contiguous sequence of null-terminated # strings, the first of which is pointed to by ptr in uv_readdir_req. # The following lines extracts those strings into dirent - entries = ByteString[] + entries = String[] offset = 0 for i = 1:file_count diff --git a/base/gmp.jl b/base/gmp.jl index 749c8adb387f2..a786d622d27aa 100644 --- a/base/gmp.jl +++ b/base/gmp.jl @@ -515,7 +515,7 @@ function base(b::Integer, n::BigInt) 2 <= b <= 62 || throw(ArgumentError("base must be 2 ≤ base ≤ 62, got $b")) p = ccall((:__gmpz_get_str,:libgmp), Ptr{UInt8}, (Ptr{UInt8}, Cint, Ptr{BigInt}), C_NULL, b, &n) len = Int(ccall(:strlen, Csize_t, (Cstring,), p)) - ASCIIString(pointer_to_array(p,len,true)) + String(pointer_to_array(p,len,true)) end function ndigits0z(x::BigInt, b::Integer=10) diff --git a/base/hashing2.jl b/base/hashing2.jl index 4bb4112b42fd1..10ee4a9073877 100644 --- a/base/hashing2.jl +++ b/base/hashing2.jl @@ -173,7 +173,7 @@ hash(x::Float16, h::UInt) = hash(Float64(x), h) const memhash = UInt === UInt64 ? :memhash_seed : :memhash32_seed const memhash_seed = UInt === UInt64 ? 0x71e729fd56419c81 : 0x56419c81 -function hash{T<:ByteString}(s::Union{T,SubString{T}}, h::UInt) +function hash(s::Union{String,SubString{String}}, h::UInt) h += memhash_seed # note: use pointer(s) here (see #6058). ccall(memhash, UInt, (Ptr{UInt8}, Csize_t, UInt32), pointer(s), sizeof(s), h % UInt32) + h diff --git a/base/i18n.jl b/base/i18n.jl index 05a8ea5439464..66f650b90d808 100644 --- a/base/i18n.jl +++ b/base/i18n.jl @@ -15,7 +15,7 @@ function locale() LOCALE end -function locale(s::ByteString) +function locale(s::String) global LOCALE = s # XXX:TBD call setlocale for cb in CALLBACKS diff --git a/base/initdefs.jl b/base/initdefs.jl index 9c0e093fe9e2b..a64e134e0f852 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -2,8 +2,8 @@ ## initdefs.jl - initialization and runtime management definitions -PROGRAM_FILE = UTF8String("") -const ARGS = UTF8String[] +PROGRAM_FILE = "" +const ARGS = String[] exit(n) = ccall(:jl_exit, Void, (Int32,), n) exit() = exit(0) @@ -14,8 +14,8 @@ const roottask = current_task() is_interactive = false isinteractive() = (is_interactive::Bool) -const LOAD_PATH = ByteString[] -const LOAD_CACHE_PATH = ByteString[] +const LOAD_PATH = String[] +const LOAD_CACHE_PATH = String[] function init_load_path() vers = "v$(VERSION.major).$(VERSION.minor)" if haskey(ENV,"JULIA_LOAD_PATH") diff --git a/base/interactiveutil.jl b/base/interactiveutil.jl index fbddbef170538..e7638186c6cc6 100644 --- a/base/interactiveutil.jl +++ b/base/interactiveutil.jl @@ -138,7 +138,7 @@ end systemerror(:SetClipboardData, pdata!=p) ccall((:CloseClipboard, "user32"), stdcall, Void, ()) end - clipboard(x) = clipboard(sprint(io->print(io,x))::ByteString) + clipboard(x) = clipboard(sprint(io->print(io,x))::String) function clipboard() systemerror(:OpenClipboard, 0==ccall((:OpenClipboard, "user32"), stdcall, Cint, (Ptr{Void},), C_NULL)) @@ -150,8 +150,8 @@ end # find NUL terminator (0x0000 16-bit code unit) len = 0 while unsafe_load(plock, len+1) != 0; len += 1; end - # get Vector{UInt16}, transcode data to UTF-8, make a ByteString of it - s = bytestring(utf16to8(pointer_to_array(plock, len))) + # get Vector{UInt16}, transcode data to UTF-8, make a String of it + s = String(utf16to8(pointer_to_array(plock, len))) systemerror(:GlobalUnlock, 0==ccall((:GlobalUnlock, "kernel32"), stdcall, Cint, (Ptr{UInt16},), plock)) return s end diff --git a/base/intfuncs.jl b/base/intfuncs.jl index 8d220dae10305..3ba2f6093c0b0 100644 --- a/base/intfuncs.jl +++ b/base/intfuncs.jl @@ -239,7 +239,7 @@ function bin(x::Unsigned, pad::Int, neg::Bool) i -= 1 end if neg; a[1]='-'; end - ASCIIString(a) + String(a) end function oct(x::Unsigned, pad::Int, neg::Bool) @@ -251,7 +251,7 @@ function oct(x::Unsigned, pad::Int, neg::Bool) i -= 1 end if neg; a[1]='-'; end - ASCIIString(a) + String(a) end function dec(x::Unsigned, pad::Int, neg::Bool) @@ -263,7 +263,7 @@ function dec(x::Unsigned, pad::Int, neg::Bool) i -= 1 end if neg; a[1]='-'; end - ASCIIString(a) + String(a) end function hex(x::Unsigned, pad::Int, neg::Bool) @@ -276,7 +276,7 @@ function hex(x::Unsigned, pad::Int, neg::Bool) i -= 1 end if neg; a[1]='-'; end - ASCIIString(a) + String(a) end num2hex(n::Integer) = hex(n, sizeof(n)*2) @@ -295,7 +295,7 @@ function base(b::Int, x::Unsigned, pad::Int, neg::Bool) i -= 1 end if neg; a[1]='-'; end - ASCIIString(a) + String(a) end base(b::Integer, n::Integer, pad::Integer=1) = base(Int(b), unsigned(abs(n)), pad, n<0) diff --git a/base/io.jl b/base/io.jl index 4019df0c4a514..3938e3cb61b8b 100644 --- a/base/io.jl +++ b/base/io.jl @@ -254,9 +254,7 @@ end function readuntil(s::IO, delim::Char) if delim < Char(0x80) - data = readuntil(s, delim%UInt8) - enc = byte_string_classify(data) - return (enc==1) ? ASCIIString(data) : UTF8String(data) + return String(readuntil(s, delim % UInt8)) end out = IOBuffer() while !eof(s) @@ -346,10 +344,7 @@ function read(s::IO, nb=typemax(Int)) return resize!(b, nr) end -function readstring(s::IO) - b = read(s) - return isvalid(ASCIIString, b) ? ASCIIString(b) : UTF8String(b) -end +readstring(s::IO) = String(read(s)) ## high-level iterator interfaces ## @@ -374,7 +369,7 @@ function done(itr::EachLine, nada) true end next(itr::EachLine, nada) = (readline(itr.stream), nothing) -eltype(::Type{EachLine}) = ByteString +eltype(::Type{EachLine}) = String readlines(s=STDIN) = collect(eachline(s)) diff --git a/base/iobuffer.jl b/base/iobuffer.jl index 9395e0bd0ff83..a1609ca96c4a1 100644 --- a/base/iobuffer.jl +++ b/base/iobuffer.jl @@ -219,8 +219,7 @@ isopen(io::AbstractIOBuffer) = io.readable || io.writable || io.seekable || nb_a function bytestring(io::AbstractIOBuffer) io.readable || throw(ArgumentError("bytestring read failed, IOBuffer is not readable")) io.seekable || throw(ArgumentError("bytestring read failed, IOBuffer is not seekable")) - b = copy!(Array(UInt8, io.size), 1, io.data, 1, io.size) - return isvalid(ASCIIString, b) ? ASCIIString(b) : UTF8String(b) + return String(copy!(Array(UInt8, io.size), 1, io.data, 1, io.size)) end function takebuf_array(io::AbstractIOBuffer) @@ -260,10 +259,7 @@ function takebuf_array(io::IOBuffer) end return data end -function takebuf_string(io::AbstractIOBuffer) - b = takebuf_array(io) - return isvalid(ASCIIString, b) ? ASCIIString(b) : UTF8String(b) -end +takebuf_string(io::AbstractIOBuffer) = String(takebuf_array(io)) function write(to::AbstractIOBuffer, from::AbstractIOBuffer) if to === from diff --git a/base/iostream.jl b/base/iostream.jl index 0896de8207291..6d97a1d44c396 100644 --- a/base/iostream.jl +++ b/base/iostream.jl @@ -181,7 +181,7 @@ end read(s::IOStream, ::Type{Char}) = Char(ccall(:jl_getutf8, UInt32, (Ptr{Void},), s.ios)) takebuf_string(s::IOStream) = - ccall(:jl_takebuf_string, Ref{ByteString}, (Ptr{Void},), s.ios) + ccall(:jl_takebuf_string, Ref{String}, (Ptr{Void},), s.ios) takebuf_array(s::IOStream) = ccall(:jl_takebuf_array, Vector{UInt8}, (Ptr{Void},), s.ios) diff --git a/base/latex_symbols.jl b/base/latex_symbols.jl index 94dd84a2d62a3..86e88a950b4b2 100644 --- a/base/latex_symbols.jl +++ b/base/latex_symbols.jl @@ -24,7 +24,7 @@ for c in child_nodes(root(xdoc)) id = attribute(ce, "id") U = string(map(s -> Char(parse(Int, s, 16)), split(id[2:end], "-"))...) - if ismatch(r"^\\[A-Za-z]+$",L) && !isa(U,ASCIIString) + if ismatch(r"^\\[A-Za-z]+$",L) && !isa(U,String) if L in Ls println("# duplicated symbol $L ($id)") else diff --git a/base/libc.jl b/base/libc.jl index 02be937269c80..c061d8f52aba6 100644 --- a/base/libc.jl +++ b/base/libc.jl @@ -263,7 +263,7 @@ function FormatMessage end buf = Array(UInt16, len) unsafe_copy!(pointer(buf), p, len) ccall(:LocalFree,stdcall,Ptr{Void},(Ptr{Void},),p) - return UTF8String(utf16to8(buf)) + return String(utf16to8(buf)) end end diff --git a/base/libdl.jl b/base/libdl.jl index f0cadcfb6442f..5bb0ddeee270d 100644 --- a/base/libdl.jl +++ b/base/libdl.jl @@ -6,7 +6,7 @@ export DL_LOAD_PATH, RTLD_DEEPBIND, RTLD_FIRST, RTLD_GLOBAL, RTLD_LAZY, RTLD_LOC RTLD_NODELETE, RTLD_NOLOAD, RTLD_NOW, dlclose, dlopen, dlopen_e, dlsym, dlsym_e, dlpath, find_library, dlext, dllist -const DL_LOAD_PATH = ByteString[] +const DL_LOAD_PATH = String[] @osx_only push!(DL_LOAD_PATH, "@loader_path/julia") @osx_only push!(DL_LOAD_PATH, "@loader_path") @@ -97,7 +97,7 @@ On success, the return value will be one of the names (potentially prefixed by o paths in locations). This string can be assigned to a `global const` and used as the library name in future `ccall`'s. On failure, it returns the empty string. """ -function find_library(libnames, extrapaths=ASCIIString[]) +function find_library(libnames, extrapaths=String[]) for lib in libnames for path in extrapaths l = joinpath(path, lib) @@ -115,7 +115,7 @@ function find_library(libnames, extrapaths=ASCIIString[]) end return "" end -find_library(libname::Union{Symbol,AbstractString}, extrapaths=ASCIIString[]) = +find_library(libname::Union{Symbol,AbstractString}, extrapaths=String[]) = find_library([string(libname)], extrapaths) function dlpath(handle::Ptr{Void}) diff --git a/base/libgit2/callbacks.jl b/base/libgit2/callbacks.jl index b44f51530917c..f4dcb7ab2fbe5 100644 --- a/base/libgit2/callbacks.jl +++ b/base/libgit2/callbacks.jl @@ -114,4 +114,4 @@ mirror_cb() = cfunction(mirror_callback, Cint, (Ptr{Ptr{Void}}, Ptr{Void}, Cstri "C function pointer for `credentials_callback`" credentials_cb() = cfunction(credentials_callback, Cint, (Ptr{Ptr{Void}}, Cstring, Cstring, Cuint, Ptr{Void})) "C function pointer for `fetchhead_foreach_callback`" -fetchhead_foreach_cb() = cfunction(fetchhead_foreach_callback, Cint, (Cstring, Cstring, Ptr{Oid}, Cuint, Ptr{Void})) \ No newline at end of file +fetchhead_foreach_cb() = cfunction(fetchhead_foreach_callback, Cint, (Cstring, Cstring, Ptr{Oid}, Cuint, Ptr{Void})) diff --git a/base/linalg/arpack.jl b/base/linalg/arpack.jl index 9a2f56f3fcf8c..b396db9c6d761 100644 --- a/base/linalg/arpack.jl +++ b/base/linalg/arpack.jl @@ -7,8 +7,8 @@ import ..LinAlg: BlasInt, ARPACKException ## aupd and eupd wrappers function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function, n::Integer, - sym::Bool, cmplx::Bool, bmat::ByteString, - nev::Integer, ncv::Integer, which::ByteString, + sym::Bool, cmplx::Bool, bmat::String, + nev::Integer, ncv::Integer, which::String, tol::Real, maxiter::Integer, mode::Integer, v0::Vector) lworkl = cmplx ? ncv * (3*ncv + 5) : (sym ? ncv * (ncv + 8) : ncv * (3*ncv + 6) ) @@ -106,8 +106,8 @@ function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function return (resid, v, n, iparam, ipntr, workd, workl, lworkl, rwork, TOL) end -function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ByteString, - nev::Integer, which::ByteString, ritzvec::Bool, +function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::String, + nev::Integer, which::String, ritzvec::Bool, TOL::Array, resid, ncv::Integer, v, ldv, sigma, iparam, ipntr, workd, workl, lworkl, rwork) diff --git a/base/linalg/exceptions.jl b/base/linalg/exceptions.jl index c8975e45d53fc..89dfee2e657ed 100644 --- a/base/linalg/exceptions.jl +++ b/base/linalg/exceptions.jl @@ -11,7 +11,7 @@ type LAPACKException <: Exception end type ARPACKException <: Exception - info::ByteString + info::String end function ARPACKException(i::Integer) diff --git a/base/loading.jl b/base/loading.jl index b241871a9fd89..315f9cac5c69e 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -80,7 +80,7 @@ else end end -function try_path(prefix::ByteString, base::ByteString, name::ByteString) +function try_path(prefix::String, base::String, name::String) path = joinpath(prefix, name) isfile_casesensitive(path) && return abspath(path) path = joinpath(prefix, base, "src", name) @@ -92,7 +92,7 @@ end # `wd` is a working directory to search. defaults to current working directory. # if `wd === nothing`, no extra path is searched. -function find_in_path(name::ByteString, wd) +function find_in_path(name::String, wd) isabspath(name) && return name base = name if endswith(name,".jl") @@ -113,7 +113,7 @@ function find_in_path(name::ByteString, wd) end find_in_path(name::AbstractString, wd = pwd()) = find_in_path(bytestring(name), wd) -function find_in_node_path(name::ByteString, srcpath, node::Int=1) +function find_in_node_path(name::String, srcpath, node::Int=1) if myid() == node find_in_path(name, srcpath) else @@ -121,7 +121,7 @@ function find_in_node_path(name::ByteString, srcpath, node::Int=1) end end -function find_source_file(file::ByteString) +function find_source_file(file::String) (isabspath(file) || isfile(file)) && return file file2 = find_in_path(file) file2 !== nothing && return file2 @@ -146,7 +146,7 @@ function _include_from_serialized(content::Vector{UInt8}) end # returns an array of modules loaded, or nothing if failed -function _require_from_serialized(node::Int, mod::Symbol, path_to_try::ByteString, toplevel_load::Bool) +function _require_from_serialized(node::Int, mod::Symbol, path_to_try::String, toplevel_load::Bool) if JLOptions().use_compilecache == 0 return nothing end @@ -213,7 +213,7 @@ end const package_locks = Dict{Symbol,Condition}() # used to optionally track dependencies when requiring a module: -const _require_dependencies = Tuple{ByteString,Float64}[] +const _require_dependencies = Tuple{String,Float64}[] const _track_dependencies = [false] function _include_dependency(_path::AbstractString) prev = source_path(nothing) @@ -377,7 +377,7 @@ end # remote/parallel load -include_string(txt::ByteString, fname::ByteString) = +include_string(txt::String, fname::String) = ccall(:jl_load_file_string, Any, (Ptr{UInt8},Csize_t,Ptr{UInt8},Csize_t), txt, sizeof(txt), fname, sizeof(fname)) @@ -438,7 +438,7 @@ function include_from_node1(_path::AbstractString) result end -function evalfile(path::AbstractString, args::Vector{UTF8String}=UTF8String[]) +function evalfile(path::AbstractString, args::Vector{String}=String[]) return eval(Module(:__anon__), Expr(:toplevel, :(const ARGS = $args), @@ -446,7 +446,7 @@ function evalfile(path::AbstractString, args::Vector{UTF8String}=UTF8String[]) :(eval(m,x) = Main.Core.eval(m,x)), :(Main.Base.include($path)))) end -evalfile(path::AbstractString, args::Vector) = evalfile(path, UTF8String[args...]) +evalfile(path::AbstractString, args::Vector) = evalfile(path, String[args...]) function create_expr_cache(input::AbstractString, output::AbstractString) rm(output, force=true) # Remove file if it exists @@ -492,7 +492,7 @@ function create_expr_cache(input::AbstractString, output::AbstractString) end compilecache(mod::Symbol) = compilecache(string(mod)) -function compilecache(name::ByteString) +function compilecache(name::String) myid() == 1 || error("can only precompile from node 1") path = find_in_path(name, nothing) path === nothing && throw(ArgumentError("$name not found in path")) @@ -513,7 +513,7 @@ isvalid_cache_header(f::IOStream) = 0 != ccall(:jl_deserialize_verify_header, Ci function cache_dependencies(f::IO) modules = Tuple{Symbol,UInt64}[] - files = Tuple{ByteString,Float64}[] + files = Tuple{String,Float64}[] while true n = ntoh(read(f, Int32)) n == 0 && break diff --git a/base/markdown/Common/block.jl b/base/markdown/Common/block.jl index b5d715991e23c..432e0a239e8ba 100644 --- a/base/markdown/Common/block.jl +++ b/base/markdown/Common/block.jl @@ -97,8 +97,8 @@ end # –––– type Code - language::UTF8String - code::UTF8String + language::String + code::String end Code(code) = Code("", code) diff --git a/base/markdown/Common/inline.jl b/base/markdown/Common/inline.jl index 9838342516086..d993dc1016a5a 100644 --- a/base/markdown/Common/inline.jl +++ b/base/markdown/Common/inline.jl @@ -45,8 +45,8 @@ end # –––––––––––––– type Image - url::UTF8String - alt::UTF8String + url::String + alt::String end @trigger '!' -> @@ -65,7 +65,7 @@ end type Link text - url::UTF8String + url::String end @trigger '[' -> @@ -83,7 +83,7 @@ function link(stream::IO, md::MD) end type Footnote - id::UTF8String + id::String text end diff --git a/base/markdown/IPython/IPython.jl b/base/markdown/IPython/IPython.jl index a64a350fea641..0cc81ff227682 100644 --- a/base/markdown/IPython/IPython.jl +++ b/base/markdown/IPython/IPython.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license type LaTeX - formula::UTF8String + formula::String end @trigger '$' -> diff --git a/base/methodshow.jl b/base/methodshow.jl index 719415e0b4544..a209eb5bc8f2e 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -20,8 +20,8 @@ function argtype_decl(env, n, t) # -> (argname, argtype) else return s, string_with_env(env, t.parameters[1]) * "..." end - elseif t == ByteString - return s, "ByteString" + elseif t == String + return s, "String" end return s, string_with_env(env, t) end diff --git a/base/parse.jl b/base/parse.jl index 90497a3d95d83..bebff90d82fac 100644 --- a/base/parse.jl +++ b/base/parse.jl @@ -54,7 +54,7 @@ function parseint_preamble(signed::Bool, base::Int, s::AbstractString, startpos: return sgn, base, j end -function tryparse_internal{S<:ByteString}(::Type{Bool}, sbuff::S, startpos::Int, endpos::Int, raise::Bool) +function tryparse_internal(::Type{Bool}, sbuff::String, startpos::Int, endpos::Int, raise::Bool) len = endpos-startpos+1 p = pointer(sbuff)+startpos-1 (len == 4) && (0 == ccall(:memcmp, Int32, (Ptr{UInt8}, Ptr{UInt8}, UInt), p, "true", 4)) && (return Nullable(true)) @@ -147,11 +147,11 @@ parse{T<:Integer}(::Type{T}, s::AbstractString) = get(tryparse_internal(T, s, 0, ## string to float functions ## -tryparse(::Type{Float64}, s::ByteString) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s)) -tryparse{T<:ByteString}(::Type{Float64}, s::SubString{T}) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof) +tryparse(::Type{Float64}, s::String) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s)) +tryparse(::Type{Float64}, s::SubString{String}) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof) -tryparse(::Type{Float32}, s::ByteString) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s)) -tryparse{T<:ByteString}(::Type{Float32}, s::SubString{T}) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof) +tryparse(::Type{Float32}, s::String) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s)) +tryparse(::Type{Float32}, s::SubString{String}) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof) tryparse{T<:Union{Float32,Float64}}(::Type{T}, s::AbstractString) = tryparse(T, bytestring(s)) diff --git a/base/path.jl b/base/path.jl index 181da47731bfc..4d54561f6a842 100644 --- a/base/path.jl +++ b/base/path.jl @@ -45,7 +45,7 @@ end isabspath(path::AbstractString) = ismatch(path_absolute_re, path) isdirpath(path::AbstractString) = ismatch(path_directory_re, splitdrive(path)[2]) -function splitdir(path::ByteString) +function splitdir(path::String) a, b = splitdrive(path) m = match(path_dir_splitter,b) m === nothing && return (a,b) @@ -134,7 +134,7 @@ abspath(a::AbstractString, b::AbstractString...) = abspath(joinpath(a,b...)) systemerror(:realpath, n == 0) x = n < length(buf) # is the buffer big enough? resize!(buf, n) # shrink if x, grow if !x - x && return UTF8String(utf16to8(buf)) + x && return String(utf16to8(buf)) end end @@ -148,7 +148,7 @@ end systemerror(:longpath, n == 0) x = n < length(buf) # is the buffer big enough? resize!(buf, n) # shrink if x, grow if !x - x && return UTF8String(utf16to8(buf)) + x && return String(utf16to8(buf)) end end diff --git a/base/pcre.jl b/base/pcre.jl index ea0e279da0bb2..1ee3904119f04 100644 --- a/base/pcre.jl +++ b/base/pcre.jl @@ -166,7 +166,7 @@ function capture_names(re) name_count = info(re, INFO_NAMECOUNT, UInt32) name_entry_size = info(re, INFO_NAMEENTRYSIZE, UInt32) nametable_ptr = info(re, INFO_NAMETABLE, Ptr{UInt8}) - names = Dict{Int, ASCIIString}() + names = Dict{Int, String}() for i=1:name_count offset = (i-1)*name_entry_size + 1 # The capture group index corresponding to name 'i' is stored as a diff --git a/base/pkg.jl b/base/pkg.jl index e0b185c9f95eb..25a1a3dac8eab 100644 --- a/base/pkg.jl +++ b/base/pkg.jl @@ -83,7 +83,7 @@ intervals for `pkg`. add(pkg::AbstractString, vers::VersionNumber...) = cd(Entry.add,pkg,vers...) """ - available() -> Vector{ASCIIString} + available() -> Vector{String} Returns the names of available packages. """ @@ -97,7 +97,7 @@ Returns the version numbers available for package `pkg`. available(pkg::AbstractString) = cd(Entry.available,pkg) """ - installed() -> Dict{ASCIIString,VersionNumber} + installed() -> Dict{String,VersionNumber} Returns a dictionary mapping installed package names to the installed version number of each package. diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl index e6d2948b56857..914e6136ad110 100644 --- a/base/pkg/entry.jl +++ b/base/pkg/entry.jl @@ -102,7 +102,7 @@ function available(pkg::AbstractString) end function installed() - pkgs = Dict{ASCIIString,VersionNumber}() + pkgs = Dict{String,VersionNumber}() for (pkg,(ver,fix)) in Read.installed() pkgs[pkg] = ver end @@ -445,7 +445,7 @@ function resolve( # prefetch phase isolates network activity, nothing to roll back missing = [] for (pkg,(ver1,ver2)) in changes - vers = ASCIIString[] + vers = String[] ver1 !== nothing && push!(vers,LibGit2.head(pkg)) ver2 !== nothing && push!(vers,Read.sha1(pkg,ver2)) append!(missing, diff --git a/base/pkg/git.jl b/base/pkg/git.jl index 56252125ce7bc..3a34fb2aa3f29 100644 --- a/base/pkg/git.jl +++ b/base/pkg/git.jl @@ -63,9 +63,9 @@ function iscommit(sha1s::Vector; dir="") end immutable State - head::ASCIIString - index::ASCIIString - work::ASCIIString + head::String + index::String + work::String end function snapshot(; dir="") diff --git a/base/pkg/query.jl b/base/pkg/query.jl index 2e441c681fac7..e529e3425bc4f 100644 --- a/base/pkg/query.jl +++ b/base/pkg/query.jl @@ -27,16 +27,16 @@ function requirements(reqs::Dict, fix::Dict, avail::Dict) reqs end -function dependencies(avail::Dict, fix::Dict = Dict{ByteString,Fixed}("julia"=>Fixed(VERSION))) +function dependencies(avail::Dict, fix::Dict = Dict{String,Fixed}("julia"=>Fixed(VERSION))) avail = deepcopy(avail) - conflicts = Dict{ByteString,Set{ByteString}}() + conflicts = Dict{String,Set{String}}() for (fp,fx) in fix delete!(avail, fp) for (ap,av) in avail, (v,a) in copy(av) if satisfies(fp, fx.version, a.requires) delete!(a.requires, fp) else - haskey(conflicts, ap) || (conflicts[ap] = Set{ByteString}()) + haskey(conflicts, ap) || (conflicts[ap] = Set{String}()) push!(conflicts[ap], fp) delete!(av, v) end @@ -45,7 +45,7 @@ function dependencies(avail::Dict, fix::Dict = Dict{ByteString,Fixed}("julia"=>F again = true while again again = false - deleted_pkgs = ByteString[] + deleted_pkgs = String[] for (ap,av) in avail if isempty(av) delete!(avail, ap) @@ -56,7 +56,7 @@ function dependencies(avail::Dict, fix::Dict = Dict{ByteString,Fixed}("julia"=>F for dp in deleted_pkgs for (ap,av) in avail, (v,a) in copy(av) if haskey(a.requires, dp) - haskey(conflicts, ap) || (conflicts[ap] = Set{ByteString}()) + haskey(conflicts, ap) || (conflicts[ap] = Set{String}()) union!(conflicts[ap], conflicts[dp]) delete!(av, v) end @@ -69,8 +69,8 @@ end typealias PackageState Union{Void,VersionNumber} function diff(have::Dict, want::Dict, avail::Dict, fixed::Dict) - change = Array(Tuple{ByteString,Tuple{PackageState,PackageState}},0) - remove = Array(Tuple{ByteString,Tuple{PackageState,PackageState}},0) + change = Array(Tuple{String,Tuple{PackageState,PackageState}},0) + remove = Array(Tuple{String,Tuple{PackageState,PackageState}},0) for pkg in collect(union(keys(have),keys(want))) h, w = haskey(have,pkg), haskey(want,pkg) @@ -87,7 +87,7 @@ function diff(have::Dict, want::Dict, avail::Dict, fixed::Dict) append!(sort!(change), sort!(remove)) end -function check_requirements(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber,Available}}, fix::Dict) +function check_requirements(reqs::Requires, deps::Dict{String,Dict{VersionNumber,Available}}, fix::Dict) for (p,vs) in reqs if !any(vn->(vn in vs), keys(deps[p])) remaining_vs = VersionSet() @@ -116,14 +116,14 @@ end # If there are explicitly required packages, dicards all versions outside # the allowed range (checking for impossible ranges while at it). # This is a pre-pruning step, so it also creates some structures which are later used by pruning -function filter_versions(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber,Available}}) +function filter_versions(reqs::Requires, deps::Dict{String,Dict{VersionNumber,Available}}) # To each version in each package, we associate a BitVector. # It is going to hold a pattern such that all versions with # the same pattern are equivalent. - vmask = Dict{ByteString,Dict{VersionNumber, BitVector}}() + vmask = Dict{String,Dict{VersionNumber, BitVector}}() # Parse requirements and store allowed versions. - allowed = Dict{ByteString,Dict{VersionNumber, Bool}}() + allowed = Dict{String,Dict{VersionNumber, Bool}}() for (p,vs) in reqs @assert !haskey(allowed, p) allowed[p] = Dict{VersionNumber,Bool}() @@ -135,7 +135,7 @@ function filter_versions(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumbe @assert any(values(allowedp)) end - filtered_deps = Dict{ByteString,Dict{VersionNumber,Available}}() + filtered_deps = Dict{String,Dict{VersionNumber,Available}}() for (p,depsp) in deps filtered_deps[p] = Dict{VersionNumber,Available}() allowedp = get(allowed, p, Dict{VersionNumber,Bool}()) @@ -158,13 +158,13 @@ end # dependency relation, they are both required or both not required) # 2) They have the same dependencies # Preliminarily calls filter_versions. -function prune_versions(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber,Available}}) +function prune_versions(reqs::Requires, deps::Dict{String,Dict{VersionNumber,Available}}) filtered_deps, allowed, vmask = filter_versions(reqs, deps) # For each package, we examine the dependencies of its versions # and put together those which are equal. # While we're at it, we also collect all dependencies into alldeps - alldeps = Dict{ByteString,Set{VersionSet}}() + alldeps = Dict{String,Set{VersionSet}}() for (p, fdepsp) in filtered_deps # Extract unique dependencies lists (aka classes), thereby @@ -217,8 +217,8 @@ function prune_versions(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber # At this point, the vmask patterns are computed. We divide them into # classes so that we can keep just one version for each class. - pruned_vers = Dict{ByteString,Vector{VersionNumber}}() - eq_classes = Dict{ByteString,Dict{VersionNumber,Vector{VersionNumber}}}() + pruned_vers = Dict{String,Vector{VersionNumber}}() + eq_classes = Dict{String,Dict{VersionNumber,Vector{VersionNumber}}}() for (p, vmaskp) in vmask vmask0_uniq = unique(values(vmaskp)) nc = length(vmask0_uniq) @@ -265,7 +265,7 @@ function prune_versions(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber # Recompute deps. We could simplify them, but it's not worth it - new_deps = Dict{ByteString,Dict{VersionNumber,Available}}() + new_deps = Dict{String,Dict{VersionNumber,Available}}() for (p,depsp) in deps @assert !haskey(new_deps, p) @@ -304,12 +304,12 @@ function prune_versions(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber return new_deps, eq_classes end -prune_versions(deps::Dict{ByteString,Dict{VersionNumber,Available}}) = - prune_versions(Dict{ByteString,VersionSet}(), deps) +prune_versions(deps::Dict{String,Dict{VersionNumber,Available}}) = + prune_versions(Dict{String,VersionSet}(), deps) # Build a graph restricted to a subset of the packages -function subdeps(deps::Dict{ByteString,Dict{VersionNumber,Available}}, pkgs::Set{ByteString}) - sub_deps = Dict{ByteString,Dict{VersionNumber,Available}}() +function subdeps(deps::Dict{String,Dict{VersionNumber,Available}}, pkgs::Set{String}) + sub_deps = Dict{String,Dict{VersionNumber,Available}}() for p in pkgs haskey(sub_deps, p) || (sub_deps[p] = Dict{VersionNumber,Available}()) sub_depsp = sub_deps[p] @@ -323,11 +323,11 @@ end # Build a subgraph incuding only the (direct and indirect) dependencies # of a given package set -function dependencies_subset(deps::Dict{ByteString,Dict{VersionNumber,Available}}, pkgs::Set{ByteString}) +function dependencies_subset(deps::Dict{String,Dict{VersionNumber,Available}}, pkgs::Set{String}) staged = pkgs allpkgs = copy(pkgs) while !isempty(staged) - staged_next = Set{ByteString}() + staged_next = Set{String}() for p in staged, a in values(deps[p]), rp in keys(a.requires) if !(rp in allpkgs) push!(staged_next, rp) @@ -342,14 +342,14 @@ end # Build a subgraph incuding only the (direct and indirect) dependencies and dependants # of a given package set -function undirected_dependencies_subset(deps::Dict{ByteString,Dict{VersionNumber,Available}}, pkgs::Set{ByteString}) - graph = Dict{ByteString, Set{ByteString}}() +function undirected_dependencies_subset(deps::Dict{String,Dict{VersionNumber,Available}}, pkgs::Set{String}) + graph = Dict{String, Set{String}}() for (p,d) in deps - haskey(graph, p) || (graph[p] = Set{ByteString}()) + haskey(graph, p) || (graph[p] = Set{String}()) for a in values(d), rp in keys(a.requires) push!(graph[p], rp) - haskey(graph, rp) || (graph[rp] = Set{ByteString}()) + haskey(graph, rp) || (graph[rp] = Set{String}()) push!(graph[rp], p) end end @@ -357,7 +357,7 @@ function undirected_dependencies_subset(deps::Dict{ByteString,Dict{VersionNumber staged = pkgs allpkgs = copy(pkgs) while !isempty(staged) - staged_next = Set{ByteString}() + staged_next = Set{String}() for p in staged, rp in graph[p] if !(rp in allpkgs) push!(staged_next, rp) @@ -370,15 +370,15 @@ function undirected_dependencies_subset(deps::Dict{ByteString,Dict{VersionNumber return subdeps(deps, allpkgs) end -function filter_dependencies(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber,Available}}) - deps = dependencies_subset(deps, Set{ByteString}(keys(reqs))) +function filter_dependencies(reqs::Requires, deps::Dict{String,Dict{VersionNumber,Available}}) + deps = dependencies_subset(deps, Set{String}(keys(reqs))) deps, _, _ = filter_versions(reqs, deps) return deps end -function prune_dependencies(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber,Available}}) - deps = dependencies_subset(deps, Set{ByteString}(keys(reqs))) +function prune_dependencies(reqs::Requires, deps::Dict{String,Dict{VersionNumber,Available}}) + deps = dependencies_subset(deps, Set{String}(keys(reqs))) deps, _ = prune_versions(reqs, deps) return deps diff --git a/base/pkg/read.jl b/base/pkg/read.jl index 1e3d46420c379..c675dc82689dc 100644 --- a/base/pkg/read.jl +++ b/base/pkg/read.jl @@ -11,7 +11,7 @@ url(pkg::AbstractString) = readstrip(Dir.path("METADATA"), pkg, "url") sha1(pkg::AbstractString, ver::VersionNumber) = readstrip(Dir.path("METADATA"), pkg, "versions", string(ver), "sha1") function available(names=readdir("METADATA")) - pkgs = Dict{ByteString,Dict{VersionNumber,Available}}() + pkgs = Dict{String,Dict{VersionNumber,Available}}() for pkg in names isfile("METADATA", pkg, "url") || continue versdir = joinpath("METADATA", pkg, "versions") @@ -31,7 +31,7 @@ end available(pkg::AbstractString) = get(available([pkg]),pkg,Dict{VersionNumber,Available}()) function latest(names=readdir("METADATA")) - pkgs = Dict{ByteString,Available}() + pkgs = Dict{String,Available}() for pkg in names isfile("METADATA", pkg, "url") || continue versdir = joinpath("METADATA", pkg, "versions") @@ -185,7 +185,7 @@ requires_dict(pkg::AbstractString, avail::Dict=available(pkg)) = Reqs.parse(requires_path(pkg,avail)) function installed(avail::Dict=available()) - pkgs = Dict{ByteString,Tuple{VersionNumber,Bool}}() + pkgs = Dict{String,Tuple{VersionNumber,Bool}}() for pkg in readdir() isinstalled(pkg) || continue ap = get(avail,pkg,Dict{VersionNumber,Available}()) @@ -204,7 +204,7 @@ end function fixed(avail::Dict=available(), inst::Dict=installed(avail), julia_version::VersionNumber=VERSION) - pkgs = Dict{ByteString,Fixed}() + pkgs = Dict{String,Fixed}() for (pkg,(ver,fix)) in inst fix || continue ap = get(avail,pkg,Dict{VersionNumber,Available}()) @@ -215,7 +215,7 @@ function fixed(avail::Dict=available(), inst::Dict=installed(avail), end function free(inst::Dict=installed()) - pkgs = Dict{ByteString,VersionNumber}() + pkgs = Dict{String,VersionNumber}() for (pkg,(ver,fix)) in inst fix && continue pkgs[pkg] = ver diff --git a/base/pkg/resolve.jl b/base/pkg/resolve.jl index 0988caa5fc45a..4c681445d3d2f 100644 --- a/base/pkg/resolve.jl +++ b/base/pkg/resolve.jl @@ -12,7 +12,7 @@ import ...Pkg.PkgError export resolve, sanity_check # Use the max-sum algorithm to resolve packages dependencies -function resolve(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber,Available}}) +function resolve(reqs::Requires, deps::Dict{String,Dict{VersionNumber,Available}}) # init interface structures interface = Interface(reqs, deps) @@ -49,14 +49,14 @@ function resolve(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber,Availa end # Scan dependencies for (explicit or implicit) contradictions -function sanity_check(deps::Dict{ByteString,Dict{VersionNumber,Available}}, - pkgs::Set{ByteString} = Set{ByteString}()) +function sanity_check(deps::Dict{String,Dict{VersionNumber,Available}}, + pkgs::Set{String} = Set{String}()) isempty(pkgs) || (deps = Query.undirected_dependencies_subset(deps, pkgs)) deps, eq_classes = Query.prune_versions(deps) - ndeps = Dict{ByteString,Dict{VersionNumber,Int}}() + ndeps = Dict{String,Dict{VersionNumber,Int}}() for (p,depsp) in deps ndeps[p] = ndepsp = Dict{VersionNumber,Int}() @@ -65,7 +65,7 @@ function sanity_check(deps::Dict{ByteString,Dict{VersionNumber,Available}}, end end - vers = Array(Tuple{ByteString,VersionNumber,VersionNumber}, 0) + vers = Array(Tuple{String,VersionNumber,VersionNumber}, 0) for (p,d) in deps, vn in keys(d) lvns = VersionNumber[filter(vn2->(vn2>vn), keys(d))...] nvn = isempty(lvns) ? typemax(VersionNumber) : minimum(lvns) @@ -75,11 +75,11 @@ function sanity_check(deps::Dict{ByteString,Dict{VersionNumber,Available}}, nv = length(vers) - svdict = (Tuple{ByteString,VersionNumber}=>Int)[ vers[i][1:2]=>i for i = 1:nv ] + svdict = (Tuple{String,VersionNumber}=>Int)[ vers[i][1:2]=>i for i = 1:nv ] checked = falses(nv) - problematic = Array(Tuple{ByteString,VersionNumber,ByteString},0) + problematic = Array(Tuple{String,VersionNumber,String},0) i = 1 psl = 0 for (p,vn,nvn) in vers @@ -91,7 +91,7 @@ function sanity_check(deps::Dict{ByteString,Dict{VersionNumber,Available}}, continue end - sub_reqs = Dict{ByteString,VersionSet}(p=>VersionSet([vn, nvn])) + sub_reqs = Dict{String,VersionSet}(p=>VersionSet([vn, nvn])) sub_deps = Query.filter_dependencies(sub_reqs, deps) interface = Interface(sub_reqs, sub_deps) diff --git a/base/pkg/resolve/interface.jl b/base/pkg/resolve/interface.jl index 73bc94647ab7c..e17698725c6c0 100644 --- a/base/pkg/resolve/interface.jl +++ b/base/pkg/resolve/interface.jl @@ -12,10 +12,10 @@ export Interface, compute_output_dict, greedysolver, type Interface # requirements and dependencies, in external representation reqs::Requires - deps::Dict{ByteString,Dict{VersionNumber,Available}} + deps::Dict{String,Dict{VersionNumber,Available}} # packages list - pkgs::Vector{ByteString} + pkgs::Vector{String} # number of packages np::Int @@ -24,7 +24,7 @@ type Interface spp::Vector{Int} # pakage dict: associates an index to each package name - pdict::Dict{ByteString,Int} + pdict::Dict{String,Int} # package versions: for each package, keep the list of the # possible version numbers; this defines a @@ -42,14 +42,14 @@ type Interface # higher the weight, the more favored the version) vweight::Vector{Vector{VersionWeight}} - function Interface(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber,Available}}) + function Interface(reqs::Requires, deps::Dict{String,Dict{VersionNumber,Available}}) # generate pkgs - pkgs = sort!(ByteString[Set{ByteString}(keys(deps))...]) + pkgs = sort!(String[Set{String}(keys(deps))...]) np = length(pkgs) # generate pdict - pdict = (ByteString=>Int)[ pkgs[i] => i for i = 1:np ] + pdict = (String=>Int)[ pkgs[i] => i for i = 1:np ] # generate spp and pvers spp = Array(Int, np) @@ -104,7 +104,7 @@ function compute_output_dict(sol::Vector{Int}, interface::Interface) pvers = interface.pvers spp = interface.spp - want = Dict{ByteString,VersionNumber}() + want = Dict{String,VersionNumber}() for p0 = 1:np p = pkgs[p0] s = sol[p0] @@ -146,11 +146,11 @@ function greedysolver(interface::Interface) # we start from required packages and explore the graph # following dependencies - staged = Set{ByteString}(keys(reqs)) + staged = Set{String}(keys(reqs)) seen = copy(staged) while !isempty(staged) - staged_next = Set{ByteString}() + staged_next = Set{String}() for p in staged p0 = pdict[p] @assert sol[p0] < spp[p0] diff --git a/base/pkg/resolve/versionweight.jl b/base/pkg/resolve/versionweight.jl index a87e0b689846f..ff62fc5774c83 100644 --- a/base/pkg/resolve/versionweight.jl +++ b/base/pkg/resolve/versionweight.jl @@ -75,7 +75,7 @@ immutable VWPreBuildItem end VWPreBuildItem() = VWPreBuildItem(0, HierarchicalValue(Int), 0) VWPreBuildItem(i::Int) = VWPreBuildItem(1, HierarchicalValue(Int), i) -VWPreBuildItem(s::ASCIIString) = VWPreBuildItem(1, HierarchicalValue(Int[s...]), 0) +VWPreBuildItem(s::String) = VWPreBuildItem(1, HierarchicalValue(Int[s...]), 0) Base.zero(::Type{VWPreBuildItem}) = VWPreBuildItem() @@ -103,7 +103,7 @@ end const _vwprebuild_zero = VWPreBuild(0, HierarchicalValue(VWPreBuildItem)) -function VWPreBuild(ispre::Bool, desc::Tuple{Vararg{Union{Int,ASCIIString}}}) +function VWPreBuild(ispre::Bool, desc::Tuple{Vararg{Union{Int,String}}}) isempty(desc) && return _vwprebuild_zero desc == ("",) && return VWPreBuild(ispre ? -1 : 1, HierarchicalValue(VWPreBuildItem[])) nonempty = ispre ? -1 : 0 diff --git a/base/pkg/types.jl b/base/pkg/types.jl index 8bfd7854cfa47..afd6e02929148 100644 --- a/base/pkg/types.jl +++ b/base/pkg/types.jl @@ -50,7 +50,7 @@ end hash(s::VersionSet, h::UInt) = hash(s.intervals, h + (0x2fd2ca6efa023f44 % UInt)) deepcopy_internal(vs::VersionSet, ::ObjectIdDict) = VersionSet(copy(vs.intervals)) -typealias Requires Dict{ByteString,VersionSet} +typealias Requires Dict{String,VersionSet} function merge_requires!(A::Requires, B::Requires) for (pkg,vers) in B @@ -63,7 +63,7 @@ satisfies(pkg::AbstractString, ver::VersionNumber, reqs::Requires) = !haskey(reqs, pkg) || in(ver, reqs[pkg]) immutable Available - sha1::ASCIIString + sha1::String requires::Requires end diff --git a/base/pointer.jl b/base/pointer.jl index 74fa0b4daa7b6..f5d5b972eb8a2 100644 --- a/base/pointer.jl +++ b/base/pointer.jl @@ -19,9 +19,9 @@ convert{T}(::Type{Ptr{T}}, p::Ptr) = box(Ptr{T}, unbox(Ptr{Void},p)) # object to pointer (when used with ccall) unsafe_convert(::Type{Ptr{UInt8}}, x::Symbol) = ccall(:jl_symbol_name, Ptr{UInt8}, (Any,), x) unsafe_convert(::Type{Ptr{Int8}}, x::Symbol) = ccall(:jl_symbol_name, Ptr{Int8}, (Any,), x) -unsafe_convert(::Type{Ptr{UInt8}}, s::ByteString) = unsafe_convert(Ptr{UInt8}, s.data) -unsafe_convert(::Type{Ptr{Int8}}, s::ByteString) = convert(Ptr{Int8}, unsafe_convert(Ptr{UInt8}, s.data)) -# convert strings to ByteString etc. to pass as pointers +unsafe_convert(::Type{Ptr{UInt8}}, s::String) = unsafe_convert(Ptr{UInt8}, s.data) +unsafe_convert(::Type{Ptr{Int8}}, s::String) = convert(Ptr{Int8}, unsafe_convert(Ptr{UInt8}, s.data)) +# convert strings to String etc. to pass as pointers cconvert(::Type{Ptr{UInt8}}, s::AbstractString) = bytestring(s) cconvert(::Type{Ptr{Int8}}, s::AbstractString) = bytestring(s) @@ -58,7 +58,7 @@ unsafe_store!{T}(p::Ptr{T}, x) = pointerset(p, convert(T,x), 1) function pointer_to_string(p::Ptr{UInt8}, len::Integer, own::Bool=false) a = ccall(:jl_ptr_to_array_1d, Vector{UInt8}, (Any, Ptr{UInt8}, Csize_t, Cint), Vector{UInt8}, p, len, own) - ccall(:jl_array_to_string, Ref{ByteString}, (Any,), a) + ccall(:jl_array_to_string, Ref{String}, (Any,), a) end pointer_to_string(p::Ptr{UInt8}, own::Bool=false) = pointer_to_string(p, ccall(:strlen, Csize_t, (Cstring,), p), own) diff --git a/base/poll.jl b/base/poll.jl index 1c21bee8b2285..1914d32a872e4 100644 --- a/base/poll.jl +++ b/base/poll.jl @@ -49,7 +49,7 @@ fdtimeout() = FDEvent(false, false, true) type FileMonitor handle::Ptr{Void} - file::ByteString + file::String notify::Condition active::Bool function FileMonitor(file::AbstractString) @@ -68,7 +68,7 @@ end type PollingFileWatcher handle::Ptr{Void} - file::ByteString + file::String interval::UInt32 notify::Condition active::Bool diff --git a/base/precompile.jl b/base/precompile.jl index 52cf9c5d897b9..6ff332beba9fa 100644 --- a/base/precompile.jl +++ b/base/precompile.jl @@ -2,12 +2,12 @@ # prime method cache with some things we know we'll need right after startup precompile(!=, (Bool, Bool)) -precompile(!=, (SubString{ASCIIString}, ASCIIString)) -precompile(*, (ASCIIString, ASCIIString, ASCIIString)) +precompile(!=, (SubString{String}, String)) +precompile(*, (String, String, String)) precompile(-, (Int,)) -precompile(==, (ASCIIString, ASCIIString)) -precompile(==, (ASCIIString, Char)) -precompile(==, (ASCIIString, Int)) +precompile(==, (String, String)) +precompile(==, (String, Char)) +precompile(==, (String, Int)) precompile(==, (Array{Char, 1}, Array{Char, 1})) precompile(==, (Array{Char,1}, Array{Char,1})) precompile(==, (Base.LineEdit.HistoryPrompt{Base.REPL.REPLHistoryProvider}, Base.LineEdit.Prompt)) @@ -19,32 +19,29 @@ precompile(==, (Int32, Int64)) precompile(==, (Int64, Int32)) precompile(==, (Int64, Int64)) precompile(==, (Bool,Bool)) -precompile(==, (Char, ASCIIString)) +precompile(==, (Char, String)) precompile(==, (IOStream,Void)) -precompile(==, (Type{ASCIIString}, Type{Any})) +precompile(==, (Type{String}, Type{Any})) precompile(==, (Type{Base.LineEdit.Prompt}, Type{Base.LineEdit.Prompt})) precompile(==, (Type{Function}, Int)) -precompile(==, (Type{Function}, Type{ASCIIString})) +precompile(==, (Type{Function}, Type{String})) precompile(Base._atreplinit, (Base.REPL.LineEditREPL,)) precompile(Base.BitArray, (Int,)) precompile(Base.Dict, ()) precompile(Base.Dict{Any,Any}, (Int,)) -precompile(Base.IOStream, (ASCIIString, Array{UInt8,1})) +precompile(Base.IOStream, (String, Array{UInt8,1})) precompile(Base.KeyError, (Int,)) -precompile(Base.LineEdit.Prompt, (ASCIIString, ASCIIString, ASCIIString, Function, Function, Base.REPL.LineEditREPL, Base.REPL.REPLCompletionProvider, Function, Function, Base.LineEdit.EmptyHistoryProvider, Bool)) -precompile(Base.LineEdit.Prompt, (ASCIIString, ASCIIString, ASCIIString, Function, Function, Base.REPL.LineEditREPL, Base.REPL.ShellCompletionProvider, Function, Function, Base.LineEdit.EmptyHistoryProvider, Bool)) -precompile(Base.LineEdit.Prompt, (ASCIIString, ASCIIString, Function, Function, Base.REPL.LineEditREPL, Base.REPL.REPLCompletionProvider, Function, Function, Base.LineEdit.EmptyHistoryProvider, Bool, ASCIIString)) -precompile(Base.LineEdit.Prompt, (ASCIIString, ASCIIString, Function, Function, Base.REPL.LineEditREPL, Base.REPL.ShellCompletionProvider, Function, Function, Base.LineEdit.EmptyHistoryProvider, Bool, ASCIIString)) +precompile(Base.LineEdit.Prompt, (String, String, String, Function, Function, Base.REPL.LineEditREPL, Base.REPL.REPLCompletionProvider, Function, Function, Base.LineEdit.EmptyHistoryProvider, Bool)) +precompile(Base.LineEdit.Prompt, (String, String, String, Function, Function, Base.REPL.LineEditREPL, Base.REPL.ShellCompletionProvider, Function, Function, Base.LineEdit.EmptyHistoryProvider, Bool)) +precompile(Base.LineEdit.Prompt, (String, String, Function, Function, Base.REPL.LineEditREPL, Base.REPL.REPLCompletionProvider, Function, Function, Base.LineEdit.EmptyHistoryProvider, Bool, String)) +precompile(Base.LineEdit.Prompt, (String, String, Function, Function, Base.REPL.LineEditREPL, Base.REPL.ShellCompletionProvider, Function, Function, Base.LineEdit.EmptyHistoryProvider, Bool, String)) precompile(Base.LineEdit.PromptState, (Base.Terminals.TTYTerminal, Base.LineEdit.Prompt, IOBuffer, Base.LineEdit.InputAreaState, Int)) precompile(Base.LineEdit.activate, (Base.LineEdit.Prompt, Base.LineEdit.MIState, Base.Terminals.TTYTerminal)) -precompile(Base.LineEdit.activate, (Base.LineEdit.Prompt, Base.LineEdit.MIState, Base.Terminals.TTYTerminal)) -precompile(Base.LineEdit.activate, (Base.LineEdit.Prompt, Base.LineEdit.PromptState, Base.Terminals.TTYTerminal)) precompile(Base.LineEdit.activate, (Base.LineEdit.Prompt, Base.LineEdit.PromptState, Base.Terminals.TTYTerminal)) precompile(Base.LineEdit.activate, (Base.LineEdit.Prompt, Base.LineEdit.PromptState, Base.Terminals.TerminalBuffer)) precompile(Base.LineEdit.add_history, (Base.LineEdit.PromptState,)) precompile(Base.LineEdit.buffer, (Base.LineEdit.MIState,)) precompile(Base.LineEdit.buffer, (Base.LineEdit.PromptState,)) -precompile(Base.LineEdit.buffer, (Base.LineEdit.PromptState,)) precompile(Base.LineEdit.char_move_left, (IOBuffer,)) precompile(Base.LineEdit.clear_input_area, (Base.Terminals.TTYTerminal, Base.LineEdit.InputAreaState)) precompile(Base.LineEdit.commit_line, (Base.LineEdit.MIState,)) @@ -57,7 +54,7 @@ precompile(Base.LineEdit.edit_delete, (Base.LineEdit.MIState,)) precompile(Base.LineEdit.edit_delete, (IOBuffer,)) precompile(Base.LineEdit.edit_insert, (Base.LineEdit.MIState, Char)) precompile(Base.LineEdit.edit_insert, (Base.LineEdit.PromptState, Char)) -precompile(Base.LineEdit.edit_insert, (IOBuffer, ASCIIString)) +precompile(Base.LineEdit.edit_insert, (IOBuffer, String)) precompile(Base.LineEdit.edit_move_down, (Base.LineEdit.MIState,)) precompile(Base.LineEdit.edit_move_left, (Base.LineEdit.MIState,)) precompile(Base.LineEdit.edit_move_left, (Base.LineEdit.PromptState,)) @@ -75,9 +72,7 @@ precompile(Base.LineEdit.init_state, (Base.Terminals.TTYTerminal, Base.LineEdit. precompile(Base.LineEdit.input_string, (Base.LineEdit.PromptState,)) precompile(Base.LineEdit.keymap, (Base.LineEdit.PromptState, Base.LineEdit.Prompt)) precompile(Base.LineEdit.keymap_data, (Base.LineEdit.PromptState, Base.LineEdit.Prompt)) -precompile(Base.LineEdit.keymap_fcn, (Function, ByteString)) -precompile(Base.LineEdit.keymap_fcn, (Function, ByteString)) -precompile(Base.LineEdit.keymap_fcn, (Function, ASCIIString)) +precompile(Base.LineEdit.keymap_fcn, (Function, String)) precompile(Base.LineEdit.match_input, (Dict{Char,Any},Base.LineEdit.MIState)) precompile(Base.LineEdit.match_input, (Dict{Char, Any}, Base.LineEdit.MIState, Base.Terminals.TTYTerminal)) precompile(Base.LineEdit.match_input, (Function, Base.LineEdit.MIState, Base.Terminals.TTYTerminal, Array{Char,1})) @@ -92,7 +87,7 @@ precompile(Base.LineEdit.refresh_multi_line, (Base.LineEdit.PromptState,)) precompile(Base.LineEdit.refresh_multi_line, (Base.Terminals.TTYTerminal, Base.LineEdit.PromptState)) precompile(Base.LineEdit.refresh_multi_line, (Base.Terminals.TerminalBuffer, Base.LineEdit.SearchState)) precompile(Base.LineEdit.refresh_multi_line, (Base.Terminals.TerminalBuffer, Base.Terminals.TTYTerminal, Base.LineEdit.PromptState)) -precompile(Base.LineEdit.replace_line, (Base.LineEdit.PromptState, ASCIIString)) +precompile(Base.LineEdit.replace_line, (Base.LineEdit.PromptState, String)) precompile(Base.LineEdit.replace_line, (Base.LineEdit.PromptState, Base.IOBuffer)) precompile(Base.LineEdit.reset_key_repeats, (Function, Base.LineEdit.MIState,)) precompile(Base.LineEdit.reset_state, (Base.LineEdit.MIState,)) @@ -100,7 +95,7 @@ precompile(Base.LineEdit.reset_state, (Base.LineEdit.PromptState,)) precompile(Base.LineEdit.reset_state, (Base.LineEdit.SearchState,)) precompile(Base.LineEdit.run_interface, (Base.Terminals.TTYTerminal, Base.LineEdit.ModalInterface)) precompile(Base.LineEdit.setup_search_keymap, (Base.REPL.REPLHistoryProvider,)) -precompile(Base.LineEdit.splice_buffer!, (IOBuffer, UnitRange{Int}, ASCIIString)) +precompile(Base.LineEdit.splice_buffer!, (IOBuffer, UnitRange{Int}, String)) precompile(Base.LineEdit.state, (Base.LineEdit.MIState, Base.LineEdit.Prompt)) precompile(Base.LineEdit.terminal, (Base.LineEdit.MIState,)) precompile(Base.LineEdit.terminal, (Base.LineEdit.PromptState,)) @@ -114,7 +109,7 @@ precompile(Base.Multimedia.TextDisplay, (Base.TTY,)) precompile(Base.Multimedia.display, (Int,)) precompile(Base.ProcessGroup, (Int, Array{Any,1}, Array{Any,1})) precompile(Base.REPL.(:(==)), (Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL})) -precompile(Base.REPL.LineEditREPL, (Base.Terminals.TTYTerminal, Bool, ASCIIString, ASCIIString, ASCIIString, ASCIIString, ASCIIString, Bool, Bool, Bool, Bool)) +precompile(Base.REPL.LineEditREPL, (Base.Terminals.TTYTerminal, Bool, String, String, String, String, String, Bool, Bool, Bool, Bool)) precompile(Base.REPL.LineEditREPL, (Base.Terminals.TTYTerminal,)) precompile(Base.REPL.REPLBackendRef, (Channel{Any}, Channel{Any})) precompile(Base.REPL.REPLDisplay, (Base.REPL.BasicREPL,)) @@ -123,7 +118,7 @@ precompile(Base.REPL.add_history, (Base.REPL.REPLHistoryProvider, Base.LineEdit. precompile(Base.REPL.backend, (Base.REPL.LineEditREPL,)) precompile(Base.REPL.display, (Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, Base.Multimedia.MIME{Symbol("text/plain")}, Int)) precompile(Base.REPL.display, (Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, Int)) -precompile(Base.REPL.ends_with_semicolon, (ASCIIString,)) +precompile(Base.REPL.ends_with_semicolon, (String,)) precompile(Base.REPL.find_hist_file, ()) precompile(Base.REPL.hist_from_file, (Base.REPL.REPLHistoryProvider, IOStream)) precompile(Base.REPL.history_next, (Base.LineEdit.MIState, Base.REPL.REPLHistoryProvider, Int)) @@ -139,24 +134,24 @@ precompile(Base.REPL.send_to_backend, (Expr, Base.REPL.REPLBackendRef)) precompile(Base.REPL.send_to_backend, (Expr, Channel{Any}, Channel{Any})) precompile(Base.REPL.send_to_backend, (Symbol, Base.REPL.REPLBackendRef)) precompile(Base.REPL.start_repl_backend, (Channel{Any}, Channel{Any})) -precompile(Base.REPLCompletions.complete_methods, (ASCIIString,)) -precompile(Base.REPLCompletions.complete_symbol, (ASCIIString, Function)) -precompile(Base.REPLCompletions.completions, (ASCIIString, Int)) +precompile(Base.REPLCompletions.complete_methods, (String,)) +precompile(Base.REPLCompletions.complete_symbol, (String, Function)) +precompile(Base.REPLCompletions.completions, (String, Int)) precompile(Base.Random.srand, ()) -precompile(Base.Random.srand, (ASCIIString, Int)) +precompile(Base.Random.srand, (String, Int)) precompile(Base.Random.srand, (UInt,)) precompile(Base.RemoteChannel, (Int, Int, Int)) precompile(Base.RemoteValue, ()) precompile(Base.Set, ()) -precompile(Base.SystemError, (ASCIIString,)) +precompile(Base.SystemError, (String,)) precompile(Base.TCPSocket, (Ptr{Void},)) precompile(Base.TTY, (Ptr{Void},)) -precompile(Base.Terminals.TTYTerminal, (ASCIIString, Base.TTY, Base.TTY, Base.TTY)) +precompile(Base.Terminals.TTYTerminal, (String, Base.TTY, Base.TTY, Base.TTY)) precompile(Base.Terminals.beep, (Base.Terminals.TTYTerminal,)) precompile(Base.Terminals.raw!, (Base.Terminals.TTYTerminal, Bool)) precompile(Base.Terminals.write, (Base.Terminals.TTYTerminal, Array{UInt8, 1})) precompile(Libc.TmStruct, (Float64,)) -precompile(Base.VersionNumber, (Int, Int, Int, Tuple{}, Tuple{ASCIIString})) +precompile(Base.VersionNumber, (Int, Int, Int, Tuple{}, Tuple{String})) precompile(Base._atexit, ()) precompile(Base._deleteat!, (Array{UInt8, 1}, Int, Int)) precompile(Base._deleteat_beg!, (Array{UInt8, 1}, Int, Int)) @@ -169,20 +164,18 @@ precompile(Base._setindex!, (Dict{Any, Any}, Bool, WeakRef, Int)) precompile(Base._setindex!, (Dict{UInt8, Any}, Base.LineEdit.Prompt, UInt8, Int)) precompile(Base._start, ()) precompile(Base.abs, (Char,)) -precompile(Base.abspath, (UTF8String, UTF8String)) -precompile(Base.abspath, (UTF8String,)) -precompile(Base.abspath, (ASCIIString, ASCIIString)) -precompile(Base.abspath, (ASCIIString,)) +precompile(Base.abspath, (String, String)) +precompile(Base.abspath, (String,)) precompile(Base.alignment, (Base.IOContext, Float64,)) precompile(Base.any, (Function, Array{Any,1})) -precompile(Base.arg_gen, (ASCIIString,)) +precompile(Base.arg_gen, (String,)) precompile(Base.associate_julia_struct, (Ptr{Void}, Base.TTY)) precompile(Base.async_run_thunk, (Function,)) precompile(Base.atexit, (Function,)) precompile(Base.banner, (Base.Terminals.TTYTerminal,)) -precompile(Base.startswith, (ASCIIString, ASCIIString)) -precompile(Base.bytestring, (ASCIIString,)) -precompile(Base.chop, (ASCIIString,)) +precompile(Base.startswith, (String, String)) +precompile(Base.bytestring, (String,)) +precompile(Base.chop, (String,)) precompile(Base.close, (Base.TTY,)) precompile(Base.close, (IOStream,)) precompile(Base.cmp, (Int32, Int32)) @@ -201,7 +194,7 @@ precompile(Base.convert, (Type{Char}, Char)) precompile(Base.convert, (Type{Function}, Function)) precompile(Base.convert, (Type{IOBuffer}, IOBuffer)) precompile(Base.convert, (Type{Module}, Module)) -precompile(Base.convert, (Type{AbstractString}, ASCIIString)) +precompile(Base.convert, (Type{AbstractString}, String)) precompile(Base.copy!, (Array{Dict{Any, Any}, 1}, Int, Array{Dict{Any, Any}, 1}, Int, Int)) precompile(Base.copy, (Bool,)) precompile(Base.deleteat!, (Array{UInt8, 1}, Base.UnitRange{Int})) @@ -219,9 +212,9 @@ precompile(Base.first, (UnitRange{Int},)) precompile(Base.flush, (IOStream,)) precompile(Base.flush_gc_msgs, ()) precompile(Base.flush_gc_msgs, (Base.Worker,)) -precompile(Base.get, (Base.EnvHash, ASCIIString, ASCIIString)) +precompile(Base.get, (Base.EnvHash, String, String)) precompile(Base.get, (Dict{Any, Any}, Tuple{Int, Int}, Bool)) -precompile(Base.get, (Dict{Any,Any}, Symbol, ASCIIString)) +precompile(Base.get, (Dict{Any,Any}, Symbol, String)) precompile(Base.get_chunks_id, (Int,)) precompile(Base.getindex, (Array{Base.LineEdit.TextInterface, 1}, Int)) precompile(Base.getindex, (BitArray{1}, Int,)) @@ -229,13 +222,13 @@ precompile(Base.getindex, (Dict{Any, Any}, Base.LineEdit.Prompt)) precompile(Base.getindex, (Dict{Any,Any}, Int32)) precompile(Base.getindex, (Dict{Symbol,Any},Symbol)) precompile(Base.getindex, (Type{AbstractString},)) -precompile(Base.getindex, (Type{ByteString}, ASCIIString, ASCIIString)) +precompile(Base.getindex, (Type{String}, String, String)) precompile(Base.getindex, (Type{Dict{Any, Any}}, Dict{Any, Any}, Dict{Any, Any}, Dict{Any, Any}, Dict{Any, Any}, Dict{Any, Any})) precompile(Base.getpid, ()) precompile(Base.hash, (Int,)) precompile(Base.hash, (RemoteChannel, UInt)) precompile(Base.hash, (RemoteChannel,)) -precompile(Base.haskey, (Base.EnvHash, ASCIIString)) +precompile(Base.haskey, (Base.EnvHash, String)) precompile(Base.haskey, (Dict{Symbol,Any}, Symbol)) precompile(Base.haskey, (ObjectIdDict, Symbol)) precompile(Base.hex, (Char, Int)) @@ -244,118 +237,112 @@ precompile(Base.ht_keyindex, (Dict{Any,Any}, Int32)) precompile(Base.ht_keyindex, (Dict{UInt8, Any}, UInt8)) precompile(Base.ht_keyindex2, (Dict{Any, Any}, Base.LineEdit.Prompt)) precompile(Base.ht_keyindex2, (Dict{UInt8, Any}, UInt8)) -precompile(Base.in, (Char, ASCIIString)) +precompile(Base.in, (Char, String)) precompile(Base.in, (Int, Base.UnitRange{Int})) precompile(Base.in, (UInt8, Base.KeyIterator{Dict{UInt8, Any}})) -precompile(Base.include_from_node1, (ASCIIString,)) -precompile(Base.include_from_node1, (UTF8String,)) +precompile(Base.include_from_node1, (String,)) precompile(Base.init_stdio, (Ptr{Void},)) precompile(Base.input_color, ()) precompile(Base.insert!, (Array{Any,1}, Int, Base.GlobalRef)) precompile(Base.Int, (Int,)) precompile(Base.Int, (UInt,)) -precompile(Base.isabspath, (ASCIIString,)) -precompile(Base.isempty, (ASCIIString,)) +precompile(Base.isabspath, (String,)) +precompile(Base.isempty, (String,)) precompile(Base.isempty, (Array{Any,1},)) precompile(Base.isempty, (Base.LineEdit.MIState,)) precompile(Base.isempty, (Base.LineEdit.PromptState,)) -precompile(Base.isempty, (SubString{ASCIIString},)) +precompile(Base.isempty, (SubString{String},)) precompile(Base.isequal, (Tuple{Int,Int},Tuple{Int,Int})) precompile(Base.isequal, (Base.LineEdit.Prompt, Base.LineEdit.Prompt)) precompile(Base.isequal, (Bool, Bool)) -precompile(Base.isequal, (Char, ASCIIString)) +precompile(Base.isequal, (Char, String)) precompile(Base.isequal, (Int,Int)) precompile(Base.isequal, (RemoteChannel, RemoteChannel)) precompile(Base.isequal, (RemoteChannel, WeakRef)) precompile(Base.isequal, (Symbol, Symbol)) precompile(Base.isequal, (VersionNumber, VersionNumber)) precompile(Base.isequal, (Void, Void)) -precompile(Base.isfile, (ASCIIString,)) -precompile(Base.ismatch, (Regex, ASCIIString)) +precompile(Base.isfile, (String,)) +precompile(Base.ismatch, (Regex, String)) precompile(Base.isslotempty, (Dict{Any,Any}, Int)) precompile(Base.istaskdone, (Task,)) -precompile(Base.joinpath, (ASCIIString, ASCIIString)) -precompile(Base.joinpath, (ASCIIString, ASCIIString, ASCIIString)) +precompile(Base.joinpath, (String, String)) +precompile(Base.joinpath, (String, String, String)) precompile(Base.keys, (Dict{UInt8, Any},)) precompile(Base.last, (UnitRange{Int},)) -precompile(Base.length, (ASCIIString,)) +precompile(Base.length, (String,)) precompile(Base.length, (Array{UInt8,1},)) precompile(Base.length, (UnitRange{Int},)) -precompile(Base.match, (Regex, ASCIIString)) -precompile(Base.match, (Regex, UTF8String)) -precompile(Base.match, (Regex, ASCIIString, Int)) -precompile(Base.match, (Regex, UTF8String, Int)) +precompile(Base.match, (Regex, String)) +precompile(Base.match, (Regex, String, Int)) precompile(Base.min, (Int32, Int32)) precompile(Base.next, (Array{Base.LineEdit.TextInterface, 1}, Int)) precompile(Base.next, (Dict{Any,Any}, Int)) precompile(Base.next, (Dict{Symbol,Any},Int)) precompile(Base.next, (IntSet, Int)) precompile(Base.next, (UnitRange{Int},Int)) -precompile(Base.nextind, (ASCIIString, Int)) -precompile(Base.normpath, (ASCIIString, ASCIIString)) -precompile(Base.normpath, (ASCIIString,)) -precompile(Base.normpath, (UTF8String, UTF8String)) -precompile(Base.normpath, (UTF8String,)) +precompile(Base.nextind, (String, Int)) +precompile(Base.normpath, (String, String)) +precompile(Base.normpath, (String,)) precompile(Base.notify, (Condition, Any)) -precompile(Base.open, (ASCIIString, ASCIIString)) -precompile(Base.parse_input_line, (ASCIIString,)) -precompile(Base.parse, (Type{Int}, ASCIIString, Int)) +precompile(Base.open, (String, String)) +precompile(Base.parse_input_line, (String,)) +precompile(Base.parse, (Type{Int}, String, Int)) precompile(Base.peek, (Base.IOBuffer,)) precompile(Base.pop!, (Array{Any,1},)) precompile(Base.position, (IOBuffer,)) precompile(Base.prepend!, (Array{Dict{Any, Any}, 1}, Array{Dict{Any, Any}, 1})) -precompile(Base.print, (ASCIIString,)) -precompile(Base.print, (Base.TTY, ASCIIString)) +precompile(Base.print, (String,)) +precompile(Base.print, (Base.TTY, String)) precompile(Base.print, (Base.TTY,Char)) -precompile(Base.print, (Base.Terminals.TTYTerminal, ASCIIString)) -precompile(Base.print, (Base.Terminals.TTYTerminal, ASCIIString, Char)) -precompile(Base.print, (Base.Terminals.TTYTerminal, ASCIIString, Char,)) +precompile(Base.print, (Base.Terminals.TTYTerminal, String)) +precompile(Base.print, (Base.Terminals.TTYTerminal, String, Char)) +precompile(Base.print, (Base.Terminals.TTYTerminal, String, Char,)) precompile(Base.print, (Float64,)) -precompile(Base.print, (IOBuffer, UTF8String)) +precompile(Base.print, (IOBuffer, String)) precompile(Base.print, (IOBuffer, VersionNumber)) precompile(Base.print, (IOStream, Int32)) -precompile(Base.print, (IOStream,ASCIIString)) -precompile(Base.print_joined, (IOBuffer, Tuple{ASCIIString}, Char)) +precompile(Base.print, (IOStream,String)) +precompile(Base.print_joined, (IOBuffer, Tuple{String}, Char)) precompile(Base.print_joined, (IOBuffer, Tuple{Int}, Char)) -precompile(Base.print_joined, (IOBuffer, Array{ASCIIString,1}, Char)) -precompile(Base.print_joined, (IOBuffer, Array{AbstractString,1}, ASCIIString)) -precompile(Base.print_joined, (IOBuffer, Array{SubString{ASCIIString}, 1}, ASCIIString)) -precompile(Base.print_joined, (IOBuffer, Array{UTF8String,1}, Char)) +precompile(Base.print_joined, (IOBuffer, Array{String,1}, Char)) +precompile(Base.print_joined, (IOBuffer, Array{AbstractString,1}, String)) +precompile(Base.print_joined, (IOBuffer, Array{SubString{String}, 1}, String)) precompile(Base.println, (Base.TTY,)) precompile(Base.println, (Base.Terminals.TTYTerminal,)) precompile(Base.promote_type, (Type{Base.LineEdit.Prompt}, Type{Base.LineEdit.HistoryPrompt{Base.REPL.REPLHistoryProvider}})) precompile(Base.promote_type, (Type{Base.LineEdit.Prompt}, Type{Base.LineEdit.Prompt})) precompile(Base.promote_type, (Type{Base.LineEdit.Prompt}, Type{Base.LineEdit.TextInterface})) precompile(Base.promote_type, (Type{Int}, Bool)) -precompile(Base.push!, (Array{AbstractString, 1}, ASCIIString)) -precompile(Base.push!, (Array{AbstractString,1}, UTF8String)) +precompile(Base.push!, (Array{AbstractString, 1}, String)) +precompile(Base.push!, (Array{AbstractString,1}, String)) precompile(Base.push!, (Array{Base.Multimedia.Display, 1}, Base.Multimedia.TextDisplay)) precompile(Base.push!, (Array{Char, 1}, Char)) -precompile(Base.push!, (Array{Union{ASCIIString, UTF8String}, 1}, ASCIIString)) +precompile(Base.push!, (Array{Union{String, String}, 1}, String)) precompile(Base.pushdisplay, (Base.Multimedia.TextDisplay,)) precompile(Base.pwd, ()) precompile(Base.read, (Base.Terminals.TTYTerminal, Type{Char})) precompile(Base.read, (IOBuffer, Type{Char})) precompile(Base.read, (IOBuffer, Type{UInt8})) precompile(Base.read, (IOStream, Array{UInt32,1})) -precompile(Base.readline, (ASCIIString,)) +precompile(Base.readline, (String,)) precompile(Base.readuntil, (IOBuffer, Char)) precompile(Base.readuntil, (IOBuffer, UInt8)) precompile(Base.rehash!, (Dict{Any,Any}, Int)) precompile(Base.rehash!, (Dict{UInt8, Any}, Int)) precompile(Base.reinit_stdio, ()) -precompile(Base.repeat, (ASCIIString, Int)) +precompile(Base.repeat, (String, Int)) precompile(Base.repl_cmd, (Cmd, Base.Terminals.TTYTerminal)) precompile(Base.require, (Symbol,)) precompile(Base.remoteref_id, (RemoteChannel,)) -precompile(Base.rsearch, (ASCIIString, Char)) -precompile(Base.rstrip, (ASCIIString,)) +precompile(Base.rsearch, (String, Char)) +precompile(Base.rstrip, (String,)) precompile(Base.run, (Cmd,)) -precompile(Base.search, (ASCIIString, Regex, Int)) +precompile(Base.search, (String, Regex, Int)) precompile(Base.search, (IOBuffer, UInt8)) precompile(Base.seek, (IOBuffer, Int)) precompile(Base.seekend, (IOStream,)) -precompile(Base.setindex!, (Array{AbstractString, 1}, ASCIIString, Int)) +precompile(Base.setindex!, (Array{AbstractString, 1}, String, Int)) precompile(Base.setindex!, (Array{Any, 1}, Array{UInt8, 1}, Int)) precompile(Base.setindex!, (Array{Any, 1}, Base.NewvarNode, Int)) precompile(Base.setindex!, (Array{Any, 1}, GlobalRef, Int)) @@ -371,7 +358,7 @@ precompile(Base.setindex!, (Dict{Any, Any}, Base.LineEdit.PromptState, Base.Line precompile(Base.setindex!, (Dict{Any,Any}, Base.LineEdit.SearchState, Base.LineEdit.HistoryPrompt{Base.REPL.REPLHistoryProvider})) precompile(Base.setindex!, (Dict{Any,Any}, Bool, Cmd)) precompile(Base.setindex!, (Dict{UInt8, Any}, Base.LineEdit.Prompt, UInt8)) -precompile(Base.setindex!, (Base.EnvHash, ASCIIString, ASCIIString)) +precompile(Base.setindex!, (Base.EnvHash, String, String)) precompile(Base.setindex!, (Vector{Any}, UInt8, Int)) precompile(Base.setindex!, (Vector{Any}, Vector{Any}, Int)) precompile(Base.show, (Base.Terminals.TTYTerminal, Int)) @@ -381,12 +368,12 @@ precompile(Base.showcompact, (Base.Terminals.TTYTerminal, Int)) precompile(Base.similar, (Array{Base.LineEdit.Prompt, 1}, Type{Base.LineEdit.TextInterface}, Tuple{Int})) precompile(Base.size, (Base.Terminals.TTYTerminal,)) precompile(Base.sizehint!, (Base.Dict{Symbol, Any}, Int)) -precompile(Base.sizeof, (ASCIIString,)) +precompile(Base.sizeof, (String,)) precompile(Base.source_path, (Void,)) precompile(Base.splice!, (Array{UInt8, 1}, Base.UnitRange{Int}, Array{UInt8, 1})) -precompile(Base.split, (ASCIIString, ASCIIString)) -precompile(Base.split, (ASCIIString, Regex)) -precompile(Base.split, (ASCIIString,)) +precompile(Base.split, (String, String)) +precompile(Base.split, (String, Regex)) +precompile(Base.split, (String,)) precompile(Base.srand, (Array{UInt32,1},)) precompile(Base.start, (Array{Base.LineEdit.TextInterface, 1},)) precompile(Base.start, (Dict{Any,Any},)) @@ -394,11 +381,11 @@ precompile(Base.start, (Dict{Symbol,Any},)) precompile(Base.start, (UnitRange{Int},)) precompile(Base.start_reading, (Base.TTY,)) precompile(Base.stop_reading, (Base.TTY,)) -precompile(Libc.strftime, (ASCIIString, Libc.TmStruct)) +precompile(Libc.strftime, (String, Libc.TmStruct)) precompile(Base.string, (Int,)) -precompile(Base.strip, (ASCIIString,)) -precompile(Base.strwidth, (ASCIIString,)) -precompile(Base.Symbol, (SubString{UTF8String},)) +precompile(Base.strip, (String,)) +precompile(Base.strwidth, (String,)) +precompile(Base.Symbol, (SubString{String},)) precompile(Base.sync_begin, ()) precompile(Base.sync_end, ()) precompile(Base.systemerror, (Symbol, Bool)) @@ -408,46 +395,45 @@ precompile(Base.take_ref, (Tuple{Int,Int},)) precompile(Base.takebuf_string, (IOBuffer,)) precompile(Base.task_local_storage, ()) precompile(Base.terminate_all_workers, ()) -precompile(Base.try_include, (ASCIIString,)) +precompile(Base.try_include, (String,)) precompile(Base.UInt, (UInt,)) precompile(Base.unsafe_copy!, (Array{Dict{Any, Any}, 1}, Int, Array{Dict{Any, Any}, 1}, Int, Int)) precompile(Base.unsafe_copy!, (Ptr{Dict{Any, Any}}, Ptr{Dict{Any, Any}}, Int)) precompile(Base.unshift!, (Array{Any,1}, Task)) -precompile(Base.utf8, (ASCIIString,)) -precompile(Base.utf8, (UTF8String,)) -precompile(Base.uv_error, (ASCIIString, Bool)) +precompile(Base.utf8, (String,)) +precompile(Base.uv_error, (String, Bool)) precompile(Base.uvfinalize, (Base.TTY,)) precompile(Base.vcat, (Base.LineEdit.Prompt,)) precompile(Base.wait, ()) precompile(Base.wait, (RemoteChannel,)) -precompile(Base.write, (Base.Terminals.TTYTerminal, ASCIIString)) -precompile(Base.write, (Base.Terminals.TerminalBuffer, ASCIIString)) +precompile(Base.write, (Base.Terminals.TTYTerminal, String)) +precompile(Base.write, (Base.Terminals.TerminalBuffer, String)) precompile(Base.write, (IOBuffer, Vector{UInt8})) precompile(Base.writemime, (Base.Terminals.TTYTerminal, Base.Multimedia.MIME{Symbol("text/plain")}, Int)) # The following are intended to help speed Pkg.update() -precompile(Base.Pkg.Entry.update, (ASCIIString,)) -precompile(Base.Pkg.Query.prune_dependencies, (Dict{ByteString, Base.Pkg.Types.VersionSet}, Dict{ByteString, Dict{VersionNumber, Base.Pkg.Types.Available}})) -precompile(Base.Pkg.Read.installed_version, (ASCIIString, Dict{VersionNumber, Base.Pkg.Types.Available})) -precompile(Base.Pkg.Resolve.resolve, (Dict{ByteString, Base.Pkg.Types.VersionSet}, Dict{ByteString, Dict{VersionNumber, Base.Pkg.Types.Available}})) +precompile(Base.Pkg.Entry.update, (String,)) +precompile(Base.Pkg.Query.prune_dependencies, (Dict{String, Base.Pkg.Types.VersionSet}, Dict{String, Dict{VersionNumber, Base.Pkg.Types.Available}})) +precompile(Base.Pkg.Read.installed_version, (String, Dict{VersionNumber, Base.Pkg.Types.Available})) +precompile(Base.Pkg.Resolve.resolve, (Dict{String, Base.Pkg.Types.VersionSet}, Dict{String, Dict{VersionNumber, Base.Pkg.Types.Available}})) precompile(Base.Pkg.update, ()) precompile(Base.Sort.sort!, (Array{Any, 1}, Base.Sort.MergeSortAlg, Base.Order.ForwardOrdering)) precompile(Base.Sort.sort!, (Array{Any, 1}, Int, Int, Base.Sort.InsertionSortAlg, Base.Order.ForwardOrdering)) precompile(Base.Sort.sort!, (Array{Any,1},)) precompile(Base.Sort.sort!, (Array{VersionNumber, 1}, Int, Int, Base.Sort.InsertionSortAlg, Base.Order.ForwardOrdering)) -precompile(Base.info, (ASCIIString,)) +precompile(Base.info, (String,)) precompile(Base.isempty, (Array{Void, 1},)) -precompile(Base.setindex!, (Dict{ByteString, VersionNumber}, VersionNumber, ASCIIString)) +precompile(Base.setindex!, (Dict{String, VersionNumber}, VersionNumber, String)) precompile(Base.spawn, (Cmd, Tuple{Base.TTY, Base.TTY, Base.TTY}, Bool, Bool)) precompile(Base.spawn, (Cmd,)) # For repl startup precompile(Base.yieldto, (Task, Int)) -precompile(Base.open, (UTF8String, Bool, Bool, Bool, Bool, Bool)) +precompile(Base.open, (String, Bool, Bool, Bool, Bool, Bool)) precompile(Base.setindex!, (Base.Dict{Any, Any}, Char, Char)) -precompile(Base.setindex!, (Base.Dict{Any, Any}, Char, UTF8String)) -precompile(Base.in, (UTF8String, Array{Any, 1})) -precompile(Base.getindex, (Base.Dict{Any, Any}, UTF8String)) +precompile(Base.setindex!, (Base.Dict{Any, Any}, Char, String)) +precompile(Base.in, (String, Array{Any, 1})) +precompile(Base.getindex, (Base.Dict{Any, Any}, String)) precompile(Base.LineEdit.setup_prefix_keymap, (Base.REPL.REPLHistoryProvider, Base.LineEdit.Prompt)) precompile(Base.convert, (Type{Any}, Base.Dict{Char, Any})) precompile(Base.REPL.mode_keymap, (Base.LineEdit.Prompt,)) @@ -462,18 +448,16 @@ precompile(Base.get, (Base.Dict{Any, Any}, Tuple{Int64, Int64}, Bool)) precompile(Base.LineEdit.refresh_multi_line, (Array{Any, 1}, Base.Terminals.TerminalBuffer, Base.Terminals.TTYTerminal, Base.IOBuffer, Base.LineEdit.InputAreaState, Base.LineEdit.PromptState)) precompile(Base.schedule, (Array{Any, 1}, Task, Void)) precompile(Base.LineEdit.match_input, (Function, Base.LineEdit.MIState, Base.Terminals.TTYTerminal, Array{Char, 1}, Base.Dict{Char, Any})) -precompile(Base.convert, (Type{Union{ASCIIString, UTF8String}}, ASCIIString)) precompile(Base.weak_key_delete!, (Base.Dict{Any, Any}, Base.RemoteChannel)) precompile(==, (Base.RemoteChannel, WeakRef)) precompile(==, (Base.RemoteChannel, Base.RemoteChannel)) precompile(Base.send_del_client, (Base.RemoteChannel,)) -precompile(!=, (Base.SubString{UTF8String}, ASCIIString)) -precompile(Base.print_joined, (Base.IOBuffer, Array{Base.SubString{UTF8String}, 1}, ASCIIString)) -precompile(Base.joinpath, (UTF8String, ASCIIString, ASCIIString, ASCIIString)) -precompile(Base.string, (ASCIIString, UTF8String, Char)) -precompile(Base.string, (ASCIIString, ASCIIString, Int)) -precompile(Base.vect, (Base.LineEdit.Prompt, ASCIIString)) - +precompile(!=, (Base.SubString{String}, String)) +precompile(Base.print_joined, (Base.IOBuffer, Array{Base.SubString{String}, 1}, String)) +precompile(Base.joinpath, (String, String, String, String)) +precompile(Base.string, (String, String, Char)) +precompile(Base.string, (String, String, Int)) +precompile(Base.vect, (Base.LineEdit.Prompt, String)) # Speeding up addprocs for LocalManager precompile(Base.start_worker, ()) @@ -485,7 +469,7 @@ precompile(Base.message_handler_loop, (Base.TCPSocket, Base.TCPSocket, Void)) precompile(Base.connect_to_peer, (Base.LocalManager, Int64, Base.WorkerConfig)) precompile(Base.connect, (Base.LocalManager, Int64, Base.WorkerConfig)) precompile(Base.connect_w2w, (Int64, Base.WorkerConfig)) -precompile(Base.connect_to_worker, (UTF8String, Int64)) +precompile(Base.connect_to_worker, (String, Int64)) precompile(Base.addprocs, (Base.LocalManager, )) precompile(Base.addprocs, (Int, )) precompile(Base.setup_launched_worker, (Base.LocalManager, Dict, Base.WorkerConfig, Array{Int,1})) @@ -493,7 +477,6 @@ precompile(Base.create_worker, (Base.LocalManager, Dict, Base.WorkerConfig)) precompile(Base.launch, (Base.LocalManager, Dict, Array{Base.WorkerConfig, 1}, Base.Condition)) precompile(Base.set_valid_processes, (Array{Int, 1}, )) - # Speed up repl help sprint(Markdown.term, @doc mean) sprint(Docs.repl_search, "mean") diff --git a/base/printf.jl b/base/printf.jl index 0546edf073cb0..96fbed7a62ef4 100644 --- a/base/printf.jl +++ b/base/printf.jl @@ -135,7 +135,7 @@ end ### printf formatter generation ### -function special_handler(flags::ASCIIString, width::Int) +function special_handler(flags::String, width::Int) @gensym x blk = Expr(:block) pad = '-' in flags ? rpad : lpad @@ -242,7 +242,7 @@ function print_exp_a(out, exp::Integer) end -function gen_d(flags::ASCIIString, width::Int, precision::Int, c::Char) +function gen_d(flags::String, width::Int, precision::Int, c::Char) # print integer: # [dDiu]: print decimal digits # [o]: print octal digits @@ -323,7 +323,7 @@ function gen_d(flags::ASCIIString, width::Int, precision::Int, c::Char) :(($x)::Real), ex end -function gen_f(flags::ASCIIString, width::Int, precision::Int, c::Char) +function gen_f(flags::String, width::Int, precision::Int, c::Char) # print to fixed trailing precision # [fF]: the only choice # @@ -385,7 +385,7 @@ function gen_f(flags::ASCIIString, width::Int, precision::Int, c::Char) :(($x)::Real), ex end -function gen_e(flags::ASCIIString, width::Int, precision::Int, c::Char, inside_g::Bool=false) +function gen_e(flags::String, width::Int, precision::Int, c::Char, inside_g::Bool=false) # print float in scientific form: # [e]: use 'e' to introduce exponent # [E]: use 'E' to introduce exponent @@ -497,7 +497,7 @@ function gen_e(flags::ASCIIString, width::Int, precision::Int, c::Char, inside_g :(($x)::Real), ex end -function gen_a(flags::ASCIIString, width::Int, precision::Int, c::Char) +function gen_a(flags::String, width::Int, precision::Int, c::Char) # print float in hexadecimal format # [a]: lowercase hex float, e.g. -0x1.cfp-2 # [A]: uppercase hex float, e.g. -0X1.CFP-2 @@ -605,7 +605,7 @@ function gen_a(flags::ASCIIString, width::Int, precision::Int, c::Char) :(($x)::Real), ex end -function gen_c(flags::ASCIIString, width::Int, precision::Int, c::Char) +function gen_c(flags::String, width::Int, precision::Int, c::Char) # print a character: # [cC]: both the same for us (Unicode) # @@ -626,7 +626,7 @@ function gen_c(flags::ASCIIString, width::Int, precision::Int, c::Char) :(($x)::Integer), blk end -function gen_s(flags::ASCIIString, width::Int, precision::Int, c::Char) +function gen_s(flags::String, width::Int, precision::Int, c::Char) # print a string: # [sS]: both the same for us (Unicode) # @@ -661,7 +661,7 @@ end # TODO: faster pointer printing. -function gen_p(flags::ASCIIString, width::Int, precision::Int, c::Char) +function gen_p(flags::String, width::Int, precision::Int, c::Char) # print pointer: # [p]: the only option # @@ -681,7 +681,7 @@ function gen_p(flags::ASCIIString, width::Int, precision::Int, c::Char) :(($x)::Ptr), blk end -function gen_g(flags::ASCIIString, width::Int, precision::Int, c::Char) +function gen_g(flags::String, width::Int, precision::Int, c::Char) # print to fixed trailing precision # [g]: lower case e on scientific # [G]: Upper case e on scientific @@ -776,17 +776,17 @@ macro handle_zero(ex) end end -decode_oct(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, decode_oct(d)) -decode_0ct(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, decode_0ct(d)) -decode_dec(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, decode_dec(d)) -decode_hex(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, decode_hex(d)) -decode_HEX(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, decode_HEX(d)) -fix_dec(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, fix_dec(d, precision)) -ini_dec(out, d, ndigits::Int, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, ini_dec(d, ndigits)) -ini_hex(out, d, ndigits::Int, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, ini_hex(d, ndigits)) -ini_HEX(out, d, ndigits::Int, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, ini_HEX(d, ndigits)) -ini_hex(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, ini_hex(d)) -ini_HEX(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) = (true, ini_HEX(d)) +decode_oct(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_oct(d)) +decode_0ct(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_0ct(d)) +decode_dec(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_dec(d)) +decode_hex(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_hex(d)) +decode_HEX(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_HEX(d)) +fix_dec(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, fix_dec(d, precision)) +ini_dec(out, d, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = (true, ini_dec(d, ndigits)) +ini_hex(out, d, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = (true, ini_hex(d, ndigits)) +ini_HEX(out, d, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = (true, ini_HEX(d, ndigits)) +ini_hex(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, ini_hex(d)) +ini_HEX(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, ini_HEX(d)) # fallbacks for Real types without explicit decode_* implementation @@ -1081,13 +1081,13 @@ end ini_hex(x::Integer,ndigits::Int) = throw(MethodError(ini_hex,(x,ndigits))) #BigFloat -fix_dec(out, d::BigFloat, flags::ASCIIString, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) -ini_dec(out, d::BigFloat, ndigits::Int, flags::ASCIIString, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) -ini_hex(out, d::BigFloat, ndigits::Int, flags::ASCIIString, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) -ini_HEX(out, d::BigFloat, ndigits::Int, flags::ASCIIString, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) -ini_hex(out, d::BigFloat, flags::ASCIIString, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) -ini_HEX(out, d::BigFloat, flags::ASCIIString, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) -function bigfloat_printf(out, d, flags::ASCIIString, width::Int, precision::Int, c::Char) +fix_dec(out, d::BigFloat, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) +ini_dec(out, d::BigFloat, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) +ini_hex(out, d::BigFloat, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) +ini_HEX(out, d::BigFloat, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) +ini_hex(out, d::BigFloat, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) +ini_HEX(out, d::BigFloat, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) +function bigfloat_printf(out, d, flags::String, width::Int, precision::Int, c::Char) fmt_len = sizeof(flags)+4 if width > 0 fmt_len += ndigits(width) diff --git a/base/process.jl b/base/process.jl index 7c1ac072f8bba..b5f97b1f65ba7 100644 --- a/base/process.jl +++ b/base/process.jl @@ -8,12 +8,12 @@ const UV_PROCESS_DETACHED = UInt8(1 << 3) const UV_PROCESS_WINDOWS_HIDE = UInt8(1 << 4) immutable Cmd <: AbstractCmd - exec::Vector{ByteString} + exec::Vector{String} ignorestatus::Bool flags::UInt32 # libuv process flags - env::Union{Array{ByteString},Void} - dir::UTF8String - Cmd(exec::Vector{ByteString}) = + env::Union{Array{String},Void} + dir::String + Cmd(exec::Vector{String}) = new(exec, false, 0x00, nothing, "") Cmd(cmd::Cmd, ignorestatus, flags, env, dir) = new(cmd.exec, ignorestatus, flags, env, @@ -220,12 +220,12 @@ end # convert various env representations into an array of "key=val" strings byteenv{S<:AbstractString}(env::AbstractArray{S}) = - ByteString[cstr(x) for x in env] + String[cstr(x) for x in env] byteenv(env::Associative) = - ByteString[cstr(string(k)*"="*string(v)) for (k,v) in env] + String[cstr(string(k)*"="*string(v)) for (k,v) in env] byteenv(env::Void) = nothing byteenv{T<:AbstractString}(env::Union{AbstractVector{Pair{T}}, Tuple{Vararg{Pair{T}}}}) = - ByteString[cstr(k*"="*string(v)) for (k,v) in env] + String[cstr(k*"="*string(v)) for (k,v) in env] setenv(cmd::Cmd, env; dir="") = Cmd(cmd; env=byteenv(env), dir=dir) setenv{T<:AbstractString}(cmd::Cmd, env::Pair{T}...; dir="") = @@ -510,7 +510,7 @@ end # | - An IO to be passed to the child # | - DevNull to pass /dev/null # | - An Filesystem.File object to redirect the output to -# \ - An ASCIIString specifying a filename to be opened +# \ - A string specifying a filename to be opened spawn_opts_swallow(stdios::StdIOSet, exitcb::Callback=false, closecb::Callback=false) = (stdios,exitcb,closecb) @@ -681,26 +681,26 @@ end ## implementation of `cmd` syntax ## -arg_gen() = ByteString[] -arg_gen(x::AbstractString) = ByteString[cstr(x)] +arg_gen() = String[] +arg_gen(x::AbstractString) = String[cstr(x)] arg_gen(cmd::Cmd) = cmd.exec function arg_gen(head) if applicable(start, head) - vals = ByteString[] + vals = String[] for x in head push!(vals, cstr(string(x))) end return vals else - return ByteString[cstr(string(head))] + return String[cstr(string(head))] end end function arg_gen(head, tail...) head = arg_gen(head) tail = arg_gen(tail...) - vals = ByteString[] + vals = String[] for h = head, t = tail push!(vals, cstr(bytestring(h, t))) end @@ -708,7 +708,7 @@ function arg_gen(head, tail...) end function cmd_gen(parsed) - args = ByteString[] + args = String[] for arg in parsed append!(args, arg_gen(arg...)) end diff --git a/base/profile.jl b/base/profile.jl index 4b7a4d39952cd..3865c60588955 100644 --- a/base/profile.jl +++ b/base/profile.jl @@ -132,7 +132,7 @@ profile buffer is used. """ function callers end -function callers(funcname::ByteString, bt::Vector{UInt}, lidict; filename = nothing, linerange = nothing) +function callers(funcname::String, bt::Vector{UInt}, lidict; filename = nothing, linerange = nothing) if filename === nothing && linerange === nothing return callersf(li -> li.func == funcname, bt, lidict) end @@ -144,7 +144,7 @@ function callers(funcname::ByteString, bt::Vector{UInt}, lidict; filename = noth end end -callers(funcname::ByteString; kwargs...) = callers(funcname, retrieve()...; kwargs...) +callers(funcname::String; kwargs...) = callers(funcname, retrieve()...; kwargs...) callers(func::Function, bt::Vector{UInt}, lidict; kwargs...) = callers(string(func), bt, lidict; kwargs...) callers(func::Function; kwargs...) = callers(string(func), retrieve()...; kwargs...) @@ -177,7 +177,7 @@ len_data() = convert(Int, ccall(:jl_profile_len_data, Csize_t, ())) maxlen_data() = convert(Int, ccall(:jl_profile_maxlen_data, Csize_t, ())) -error_codes = Dict{Int,ASCIIString}( +error_codes = Dict( -1=>"cannot specify signal action for profiling", -2=>"cannot create the timer for profiling", -3=>"cannot start the timer for profiling", @@ -348,7 +348,7 @@ function tree_format(lilist::Vector{StackFrame}, counts::Vector{Int}, level::Int ntext = cols-nindent-ndigcounts-ndigline-5 widthfile = floor(Integer,0.4ntext) widthfunc = floor(Integer,0.6ntext) - strs = Array(ByteString, length(lilist)) + strs = Array(String, length(lilist)) showextra = false if level > nindent nextra = level-nindent @@ -510,14 +510,14 @@ function callersf(matchfunc::Function, bt::Vector{UInt}, lidict) end # Utilities -function rtruncto(str::ByteString, w::Int) +function rtruncto(str::String, w::Int) ret = str if length(str) > w ret = string("...", str[end-w+4:end]) end ret end -function ltruncto(str::ByteString, w::Int) +function ltruncto(str::String, w::Int) ret = str if length(str) > w ret = string(str[1:w-4], "...") @@ -530,7 +530,7 @@ truncto(str::Symbol, w::Int) = truncto(string(str), w) # Order alphabetically (file, function) and then by line number function liperm(lilist::Vector{StackFrame}) - comb = Array(ByteString, length(lilist)) + comb = Array(String, length(lilist)) for i = 1:length(lilist) li = lilist[i] if li != UNKNOWN diff --git a/base/random.jl b/base/random.jl index 91e3b3837eb47..81b147cd56247 100644 --- a/base/random.jl +++ b/base/random.jl @@ -1258,7 +1258,7 @@ function Base.repr(u::UUID) end a[[24,19,14,9]] = '-' - return ASCIIString(a) + return String(a) end Base.show(io::IO, u::UUID) = write(io, Base.repr(u)) @@ -1266,7 +1266,7 @@ Base.show(io::IO, u::UUID) = write(io, Base.repr(u)) # return a random string (often useful for temporary filenames/dirnames) let b = UInt8['0':'9';'A':'Z';'a':'z'] global randstring - randstring(r::AbstractRNG, n::Int) = ASCIIString(b[rand(r, 1:length(b), n)]) + randstring(r::AbstractRNG, n::Int) = String(b[rand(r, 1:length(b), n)]) randstring(r::AbstractRNG) = randstring(r,8) randstring(n::Int) = randstring(GLOBAL_RNG, n) randstring() = randstring(GLOBAL_RNG) diff --git a/base/reflection.jl b/base/reflection.jl index 8fb9dd4b22fcf..41d3ef1fd910d 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -308,9 +308,9 @@ function _dump_function(f, t::ANY, native, wrapper, strip_ir_metadata, dump_modu end if native - str = ccall(:jl_dump_function_asm, Ref{ByteString}, (Ptr{Void},Cint), llvmf, 0) + str = ccall(:jl_dump_function_asm, Ref{String}, (Ptr{Void},Cint), llvmf, 0) else - str = ccall(:jl_dump_function_ir, Ref{ByteString}, + str = ccall(:jl_dump_function_ir, Ref{String}, (Ptr{Void}, Bool, Bool), llvmf, strip_ir_metadata, dump_module) end diff --git a/base/regex.jl b/base/regex.jl index 9b845ec308fd8..e723d2d40c626 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -8,7 +8,7 @@ const DEFAULT_COMPILER_OPTS = PCRE.UTF | PCRE.NO_UTF_CHECK | PCRE.ALT_BSUX const DEFAULT_MATCH_OPTS = PCRE.NO_UTF_CHECK type Regex - pattern::ByteString + pattern::String compile_options::UInt32 match_options::UInt32 regex::Ptr{Void} @@ -101,12 +101,12 @@ function show(io::IO, re::Regex) end end -# TODO: map offsets into non-ByteStrings back to original indices. +# TODO: map offsets into strings in other encodings back to original indices. # or maybe it's better to just fail since that would be quite slow immutable RegexMatch - match::SubString{UTF8String} - captures::Vector{Union{Void,SubString{UTF8String}}} + match::SubString{String} + captures::Vector{Union{Void,SubString{String}}} offset::Int offsets::Vector{Int} regex::Regex @@ -155,7 +155,7 @@ end (r::Regex)(s) = ismatch(r, s) -function match(re::Regex, str::Union{SubString{UTF8String}, UTF8String}, idx::Integer, add_opts::UInt32=UInt32(0)) +function match(re::Regex, str::Union{SubString{String}, String}, idx::Integer, add_opts::UInt32=UInt32(0)) compile(re) opts = re.match_options | add_opts if !PCRE.exec(re.regex, str, idx-1, opts, re.match_data) @@ -164,25 +164,20 @@ function match(re::Regex, str::Union{SubString{UTF8String}, UTF8String}, idx::In ovec = re.ovec n = div(length(ovec),2) - 1 mat = SubString(str, ovec[1]+1, ovec[2]) - cap = Union{Void,SubString{UTF8String}}[ + cap = Union{Void,SubString{String}}[ ovec[2i+1] == PCRE.UNSET ? nothing : SubString(str, ovec[2i+1]+1, ovec[2i+2]) for i=1:n ] off = Int[ ovec[2i+1]+1 for i=1:n ] RegexMatch(mat, cap, ovec[1]+1, off, re) end -_utf8(str) = utf8(str) -_utf8(str::SubString{ASCIIString}) = convert(SubString{UTF8String}, str) -match{T<:ByteString}(re::Regex, str::Union{T,SubString{T}}, idx::Integer, add_opts::UInt32=UInt32(0)) = - match(re, _utf8(str), idx, add_opts) - match(r::Regex, s::AbstractString) = match(r, s, start(s)) match(r::Regex, s::AbstractString, i::Integer) = throw(ArgumentError("regex matching is only available for bytestrings; use bytestring(s) to convert")) -function matchall(re::Regex, str::UTF8String, overlap::Bool=false) +function matchall(re::Regex, str::String, overlap::Bool=false) regex = compile(re).regex n = length(str.data) - matches = SubString{UTF8String}[] + matches = SubString{String}[] offset = UInt32(0) opts = re.match_options opts_nonempty = opts | PCRE.ANCHORED | PCRE.NOTEMPTY_ATSTART @@ -213,10 +208,10 @@ function matchall(re::Regex, str::UTF8String, overlap::Bool=false) matches end -matchall(re::Regex, str::Union{ByteString,SubString}, overlap::Bool=false) = +matchall(re::Regex, str::Union{String,SubString}, overlap::Bool=false) = matchall(re, utf8(str), overlap) -function search(str::Union{ByteString,SubString}, re::Regex, idx::Integer) +function search(str::Union{String,SubString}, re::Regex, idx::Integer) if idx > nextind(str,endof(str)) throw(BoundsError()) end @@ -314,7 +309,7 @@ end immutable RegexMatchIterator regex::Regex - string::UTF8String + string::String overlap::Bool function RegexMatchIterator(regex::Regex, string::AbstractString, ovr::Bool=false) diff --git a/base/require.jl b/base/require.jl index edff3d41cf71c..759ee3470f1c0 100644 --- a/base/require.jl +++ b/base/require.jl @@ -28,9 +28,9 @@ find_in_node1_path(name) = myid()==1 ? find_in_path(name) : remotecall_fetch(find_in_path, 1, name) # Store list of files and their load time -package_list = Dict{ByteString,Float64}() +package_list = Dict{String,Float64}() # to synchronize multiple tasks trying to require something -package_locks = Dict{ByteString,Any}() +package_locks = Dict{String,Any}() # only broadcast top-level (not nested) requires and reloads toplevel_load = true @@ -38,7 +38,7 @@ toplevel_load = true require(fname::AbstractString) = require(bytestring(fname)) require(f::AbstractString, fs::AbstractString...) = (require(f); for x in fs require(x); end) -function require(name::ByteString) +function require(name::String) path = find_in_node1_path(name) path == nothing && error("$name not found") diff --git a/base/rounding.jl b/base/rounding.jl index 692e1d81ba881..7d8c17b40d936 100644 --- a/base/rounding.jl +++ b/base/rounding.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license module Rounding -include(UTF8String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "fenv_constants.jl".data))) # include($BUILDROOT/base/fenv_constants.jl) +include(String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "fenv_constants.jl".data))) # include($BUILDROOT/base/fenv_constants.jl) export RoundingMode, RoundNearest, RoundToZero, RoundUp, RoundDown, RoundFromZero, diff --git a/base/serialize.jl b/base/serialize.jl index f2051f98f15fb..278d42a264fad 100644 --- a/base/serialize.jl +++ b/base/serialize.jl @@ -20,7 +20,7 @@ const TAGS = Any[ Symbol, Tuple, Expr, # dummy entries, intentionally shadowed by earlier ones LineNumberNode, Slot, LabelNode, GotoNode, QuoteNode, TopNode, TypeVar, Core.Box, LambdaInfo, - Module, #=UndefRefTag=#Symbol, Task, ASCIIString, UTF8String, + Module, #=UndefRefTag=#Symbol, Task, String, UTF16String, UTF32String, Float16, SimpleVector, #=BackrefTag=#Symbol, Method, :reserved12, diff --git a/base/sharedarray.jl b/base/sharedarray.jl index f37803de1318b..3e0e5ad50e941 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -7,7 +7,7 @@ type SharedArray{T,N} <: DenseArray{T,N} # The segname is currently used only in the test scripts to ensure that # the shmem segment has been unlinked. - segname::UTF8String + segname::String # Fields below are not to be serialized # Local shmem map. diff --git a/base/show.jl b/base/show.jl index bd21f6a5c096a..134d0e159f182 100644 --- a/base/show.jl +++ b/base/show.jl @@ -149,8 +149,8 @@ end show(io::IO, x::TypeConstructor) = show(io, x.body) function show_type_parameter(io::IO, p::ANY) - if p === ByteString - print(io, "ByteString") + if p === String + print(io, "String") else show(io, p) end @@ -220,9 +220,9 @@ end function lambdainfo_slotnames(l::LambdaInfo) slotnames = l.slotnames - isa(slotnames, Array) || return UTF8String[] - names = Dict{UTF8String,Int}() - printnames = Vector{UTF8String}(length(slotnames)) + isa(slotnames, Array) || return String[] + names = Dict{String,Int}() + printnames = Vector{String}(length(slotnames)) for i in eachindex(slotnames) name = string(slotnames[i]) idx = get!(names, name, i) @@ -546,9 +546,9 @@ function show_unquoted(io::IO, ex::Slot, ::Int, ::Int) end end slotnames = get(io, :LAMBDA_SLOTNAMES, false) - if (isa(slotnames, Vector{UTF8String}) && - slotid <= length(slotnames::Vector{UTF8String})) - print(io, (slotnames::Vector{UTF8String})[slotid]) + if (isa(slotnames, Vector{String}) && + slotid <= length(slotnames::Vector{String})) + print(io, (slotnames::Vector{String})[slotid]) else print(io, "_", slotid) end diff --git a/base/simdloop.jl b/base/simdloop.jl index 136926e60b4e4..8545e98cda037 100644 --- a/base/simdloop.jl +++ b/base/simdloop.jl @@ -8,7 +8,7 @@ export @simd, simd_outer_range, simd_inner_length, simd_index # Error thrown from ill-formed uses of @simd type SimdError <: Exception - msg::ASCIIString + msg::String end # Parse iteration space expression diff --git a/base/socket.jl b/base/socket.jl index ed0eb1bee770f..e42ac516b68ec 100644 --- a/base/socket.jl +++ b/base/socket.jl @@ -575,14 +575,15 @@ function uv_getaddrinfocb(req::Ptr{Void}, status::Cint, addrinfo::Ptr{Void}) nothing end -function getaddrinfo(cb::Function, host::ASCIIString) +function getaddrinfo(cb::Function, host::String) callback_dict[cb] = cb uv_error("getaddrinfo",ccall(:jl_getaddrinfo, Int32, (Ptr{Void}, Cstring, Ptr{UInt8}, Any, Ptr{Void}), eventloop(), host, C_NULL, cb, uv_jl_getaddrinfocb::Ptr{Void})) end getaddrinfo(cb::Function, host::AbstractString) = getaddrinfo(cb,ascii(host)) -function getaddrinfo(host::ASCIIString) +function getaddrinfo(host::String) + isascii(host) || error("non-ASCII hostname: $host") c = Condition() getaddrinfo(host) do IP notify(c,IP) @@ -591,7 +592,7 @@ function getaddrinfo(host::ASCIIString) isa(ip,UVError) && throw(ip) return ip::IPAddr end -getaddrinfo(host::AbstractString) = getaddrinfo(ascii(host)) +getaddrinfo(host::AbstractString) = getaddrinfo(String(host)) const _sizeof_uv_interface_address = ccall(:jl_uv_sizeof_interface_address,Int32,()) diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index 5418e2ca33e4b..1541421699094 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -602,7 +602,7 @@ function copy{Tv<:VRealTypes}(A::Sparse{Tv}, stype::Integer, mode::Integer) end ### cholmod_check.h ### -function print_sparse{Tv<:VTypes}(A::Sparse{Tv}, name::ASCIIString) +function print_sparse{Tv<:VTypes}(A::Sparse{Tv}, name::String) cm = common() set_print_level(cm, 3) @isok ccall((@cholmod_name("print_sparse", SuiteSparse_long),:libcholmod), Cint, @@ -610,7 +610,7 @@ function print_sparse{Tv<:VTypes}(A::Sparse{Tv}, name::ASCIIString) get(A.p), name, cm) nothing end -function print_factor{Tv<:VTypes}(F::Factor{Tv}, name::ASCIIString) +function print_factor{Tv<:VTypes}(F::Factor{Tv}, name::String) cm = common() set_print_level(cm, 3) @isok ccall((@cholmod_name("print_factor", SuiteSparse_long),:libcholmod), Cint, @@ -946,7 +946,7 @@ end convert(::Type{Sparse}, A::Dense) = dense_to_sparse(A, SuiteSparse_long) convert(::Type{Sparse}, L::Factor) = factor_to_sparse!(copy(L)) -function (::Type{Sparse})(filename::ByteString) +function (::Type{Sparse})(filename::String) open(filename) do f return read_sparse(f, SuiteSparse_long) end diff --git a/base/stream.jl b/base/stream.jl index 4a525e99aa6fa..bec5b1117e024 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -343,7 +343,7 @@ function displaysize(io::TTY) @windows_only if ispty(io) # io is actually a libuv pipe but a cygwin/msys2 pty try - h, w = map(x -> parse(Int, x), split(readstring(open(Base.Cmd(ByteString["stty", "size"]), "r", io)[1]))) + h, w = map(x -> parse(Int, x), split(readstring(open(Base.Cmd(String["stty", "size"]), "r", io)[1]))) h > 0 || (h = default_size[1]) w > 0 || (w = default_size[2]) return h, w diff --git a/base/strings/basic.jl b/base/strings/basic.jl index 40193949f42d7..7a2ac99e8fa3a 100644 --- a/base/strings/basic.jl +++ b/base/strings/basic.jl @@ -12,22 +12,22 @@ string(s::AbstractString) = s bytestring() = "" bytestring(s::Vector{UInt8}) = - ccall(:jl_pchar_to_string, Ref{ByteString}, (Ptr{UInt8},Int), s, length(s)) + ccall(:jl_pchar_to_string, Ref{String}, (Ptr{UInt8},Int), s, length(s)) function bytestring(p::Union{Ptr{UInt8},Ptr{Int8}}) p == C_NULL && throw(ArgumentError("cannot convert NULL to string")) - ccall(:jl_cstr_to_string, Ref{ByteString}, (Cstring,), p) + ccall(:jl_cstr_to_string, Ref{String}, (Cstring,), p) end bytestring(s::Cstring) = bytestring(convert(Ptr{UInt8}, s)) function bytestring(p::Union{Ptr{UInt8},Ptr{Int8}},len::Integer) p == C_NULL && throw(ArgumentError("cannot convert NULL to string")) - ccall(:jl_pchar_to_string, Ref{ByteString}, (Ptr{UInt8},Int), p, len) + ccall(:jl_pchar_to_string, Ref{String}, (Ptr{UInt8},Int), p, len) end convert(::Type{Vector{UInt8}}, s::AbstractString) = bytestring(s).data convert(::Type{Array{UInt8}}, s::AbstractString) = bytestring(s).data -convert(::Type{ByteString}, s::AbstractString) = bytestring(s) +convert(::Type{String}, s::AbstractString) = bytestring(s) convert(::Type{Vector{Char}}, s::AbstractString) = collect(s) convert(::Type{Symbol}, s::AbstractString) = Symbol(s) @@ -93,10 +93,10 @@ isless(a::AbstractString, b::AbstractString) = cmp(a,b) < 0 # faster comparisons for byte strings and symbols -cmp(a::ByteString, b::ByteString) = lexcmp(a.data, b.data) +cmp(a::String, b::String) = lexcmp(a.data, b.data) cmp(a::Symbol, b::Symbol) = Int(sign(ccall(:strcmp, Int32, (Cstring, Cstring), a, b))) -==(a::ByteString, b::ByteString) = endof(a) == endof(b) && cmp(a,b) == 0 +==(a::String, b::String) = endof(a) == endof(b) && cmp(a,b) == 0 isless(a::Symbol, b::Symbol) = cmp(a,b) < 0 ## Generic validation functions ## @@ -209,11 +209,10 @@ strwidth(s::AbstractString) = (w=0; for c in s; w += charwidth(c); end; w) isascii(c::Char) = c < Char(0x80) isascii(s::AbstractString) = all(isascii, s) -isascii(s::ASCIIString) = true ## string promotion rules ## -promote_rule{S<:AbstractString,T<:AbstractString}(::Type{S}, ::Type{T}) = UTF8String +promote_rule{S<:AbstractString,T<:AbstractString}(::Type{S}, ::Type{T}) = String isxdigit(c::Char) = '0'<=c<='9' || 'a'<=c<='f' || 'A'<=c<='F' isxdigit(s::AbstractString) = all(isxdigit, s) @@ -223,13 +222,12 @@ need_full_hex(s::AbstractString, i::Int) = !done(s,i) && isxdigit(next(s,i)[1]) byte_string_classify(data::Vector{UInt8}) = ccall(:u8_isvalid, Int32, (Ptr{UInt8}, Int), data, length(data)) -byte_string_classify(s::ByteString) = byte_string_classify(s.data) +byte_string_classify(s::String) = byte_string_classify(s.data) # 0: neither valid ASCII nor UTF-8 # 1: valid ASCII # 2: valid UTF-8 -isvalid(::Type{ASCIIString}, s::Union{Vector{UInt8},ByteString}) = byte_string_classify(s) == 1 -isvalid(::Type{UTF8String}, s::Union{Vector{UInt8},ByteString}) = byte_string_classify(s) != 0 +isvalid(::Type{String}, s::Union{Vector{UInt8},String}) = byte_string_classify(s) != 0 ## uppercase and lowercase transformations ## uppercase(s::AbstractString) = map(uppercase, s) @@ -244,9 +242,6 @@ end ## string map, filter, has ## -map_result(s::AbstractString, a::Vector{UInt8}) = UTF8String(a) -map_result(s::Union{ASCIIString,SubString{ASCIIString}}, a::Vector{UInt8}) = bytestring(a) - function map(f, s::AbstractString) out = IOBuffer(Array(UInt8,endof(s)),true,true) truncate(out,0) @@ -257,7 +252,7 @@ function map(f, s::AbstractString) end write(out, c2::Char) end - map_result(s, takebuf_array(out)) + String(takebuf_array(out)) end function filter(f, s::AbstractString) diff --git a/base/strings/io.jl b/base/strings/io.jl index 9e8c72780782e..9d10c74ffaf58 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -37,9 +37,7 @@ function sprint(size::Integer, f::Function, args...; env=nothing) else f(s, args...) end - d = s.data - resize!(d,s.size) - bytestring(d) + bytestring(resize!(s.data, s.size)) end sprint(f::Function, args...) = sprint(0, f, args...) @@ -64,9 +62,7 @@ function print_to_string(xs...; env=nothing) print(s, x) end end - d = s.data - resize!(d,s.size) - return isvalid(ASCIIString, d) ? ASCIIString(d) : UTF8String(d) + String(resize!(s.data, s.size)) end string_with_env(env, xs...) = print_to_string(xs...; env=env) @@ -77,7 +73,7 @@ print(io::IO, s::AbstractString) = (write(io, s); nothing) write(io::IO, s::AbstractString) = (len = 0; for c in s; len += write(io, c); end; len) show(io::IO, s::AbstractString) = print_quoted(io, s) -write{T<:ByteString}(to::AbstractIOBuffer, s::SubString{T}) = +write(to::AbstractIOBuffer, s::SubString{String}) = s.endof==0 ? 0 : write_sub(to, s.string.data, s.offset + 1, nextind(s, s.endof) - 1) ## printing literal quoted string data ## @@ -97,8 +93,8 @@ function repr(x) end # IOBuffer views of a (byte)string: -IOBuffer(str::ByteString) = IOBuffer(str.data) -IOBuffer{T<:ByteString}(s::SubString{T}) = IOBuffer(sub(s.string.data, s.offset + 1 : s.offset + sizeof(s))) +IOBuffer(str::String) = IOBuffer(str.data) +IOBuffer(s::SubString{String}) = IOBuffer(sub(s.string.data, s.offset + 1 : s.offset + sizeof(s))) # join is implemented using IO function print_joined(io, strings, delim, last) @@ -268,7 +264,7 @@ Removes leading indentation from string Returns: -* `ASCIIString` or `UTF8String` of multiline string, with leading indentation of `indent` removed +* `String` of multiline string, with leading indentation of `indent` removed """ function unindent(str::AbstractString, indent::Int; tabwidth=8) indent == 0 && return str diff --git a/base/strings/search.jl b/base/strings/search.jl index 1bd242d22e4f3..eb6f7ebd4e2f8 100644 --- a/base/strings/search.jl +++ b/base/strings/search.jl @@ -123,7 +123,7 @@ searchindex(s::AbstractString, t::AbstractString) = searchindex(s,t,start(s)) searchindex(s::AbstractString, c::Char, i::Integer) = _searchindex(s,c,i) searchindex(s::AbstractString, c::Char) = searchindex(s,c,start(s)) -function searchindex(s::ByteString, t::ByteString, i::Integer=1) +function searchindex(s::String, t::String, i::Integer=1) # Check for fast case of a single byte # (for multi-byte UTF-8 sequences, use searchindex on byte arrays instead) if endof(t) == 1 @@ -263,7 +263,7 @@ rsearchindex(s::ByteArray,t::ByteArray,i) = _rsearchindex(s,t,i) rsearchindex(s::AbstractString, t::AbstractString, i::Integer) = _rsearchindex(s,t,i) rsearchindex(s::AbstractString, t::AbstractString) = (isempty(s) && isempty(t)) ? 1 : rsearchindex(s,t,endof(s)) -function rsearchindex(s::ByteString, t::ByteString) +function rsearchindex(s::String, t::String) # Check for fast case of a single byte # (for multi-byte UTF-8 sequences, use rsearchindex instead) if endof(t) == 1 @@ -273,7 +273,7 @@ function rsearchindex(s::ByteString, t::ByteString) end end -function rsearchindex(s::ByteString, t::ByteString, i::Integer) +function rsearchindex(s::String, t::String, i::Integer) # Check for fast case of a single byte # (for multi-byte UTF-8 sequences, use rsearchindex instead) if endof(t) == 1 diff --git a/base/strings/types.jl b/base/strings/types.jl index 26ebd4c8c29b6..6253f00deeb31 100644 --- a/base/strings/types.jl +++ b/base/strings/types.jl @@ -31,8 +31,7 @@ SubString(s::SubString, i::Int, j::Int) = SubString(s.string, s.offset+i, s.offs SubString(s::AbstractString, i::Integer, j::Integer) = SubString(s, Int(i), Int(j)) SubString(s::AbstractString, i::Integer) = SubString(s, i, endof(s)) -sizeof(s::SubString{ASCIIString}) = s.endof -sizeof(s::SubString{UTF8String}) = s.endof == 0 ? 0 : nextind(s, s.endof) - 1 +sizeof(s::SubString{String}) = s.endof == 0 ? 0 : nextind(s, s.endof) - 1 # TODO: length(s::SubString) = ?? # default implementation will work but it's slow @@ -40,7 +39,7 @@ sizeof(s::SubString{UTF8String}) = s.endof == 0 ? 0 : nextind(s, s.endof) - 1 # that may require additional string interfaces length{T<:DirectIndexString}(s::SubString{T}) = endof(s) -function length(s::SubString{UTF8String}) +function length(s::SubString{String}) return s.endof==0 ? 0 : Int(ccall(:u8_charnum, Csize_t, (Ptr{UInt8}, Csize_t), pointer(s), nextind(s, s.endof) - 1)) end @@ -76,16 +75,14 @@ prevind(s::SubString, i::Integer) = prevind(s.string, i+s.offset)-s.offset convert{T<:AbstractString}(::Type{SubString{T}}, s::T) = SubString(s, 1, endof(s)) -bytestring{T <: ByteString}(p::SubString{T}) = bytestring(p.string.data[1+p.offset:p.offset+nextind(p, p.endof)-1]) +bytestring(p::SubString{String}) = bytestring(p.string.data[1+p.offset:p.offset+nextind(p, p.endof)-1]) function getindex(s::AbstractString, r::UnitRange{Int}) checkbounds(s, r) || throw(BoundsError(s, r)) SubString(s, first(r), last(r)) end -isascii(s::SubString{ASCIIString}) = true - -function cmp{T<:ByteString,S<:ByteString}(a::SubString{T}, b::SubString{S}) +function cmp(a::SubString{String}, b::SubString{String}) na = sizeof(a) nb = sizeof(b) c = ccall(:memcmp, Int32, (Ptr{UInt8}, Ptr{UInt8}, UInt), @@ -94,9 +91,9 @@ function cmp{T<:ByteString,S<:ByteString}(a::SubString{T}, b::SubString{S}) end # don't make unnecessary copies when passing substrings to C functions -cconvert{T<:ByteString}(::Type{Ptr{UInt8}}, s::SubString{T}) = s -cconvert{T<:ByteString}(::Type{Ptr{Int8}}, s::SubString{T}) = s -function unsafe_convert{T<:ByteString, R<:Union{Int8, UInt8}}(::Type{Ptr{R}}, s::SubString{T}) +cconvert(::Type{Ptr{UInt8}}, s::SubString{String}) = s +cconvert(::Type{Ptr{Int8}}, s::SubString{String}) = s +function unsafe_convert{R<:Union{Int8, UInt8}}(::Type{Ptr{R}}, s::SubString{String}) unsafe_convert(Ptr{R}, s.string.data) + s.offset end @@ -118,8 +115,6 @@ end reverse(s::AbstractString) = RevString(s) reverse(s::RevString) = s.string -isascii(s::RevString{ASCIIString}) = true - ## reverse an index i so that reverse(s)[i] == s[reverseind(s,i)] reverseind(s::Union{DirectIndexString,SubString{DirectIndexString}}, i::Integer) = length(s) + 1 - i @@ -170,7 +165,7 @@ end convert(::Type{RepString}, s::AbstractString) = RepString(s,1) -function repeat(s::ByteString, r::Integer) +function repeat(s::String, r::Integer) r < 0 && throw(ArgumentError("can't repeat a string $r times")) d = s.data; n = length(d) out = Array(UInt8, n*r) diff --git a/base/strings/util.jl b/base/strings/util.jl index 7e9d15b8837aa..726339d529955 100644 --- a/base/strings/util.jl +++ b/base/strings/util.jl @@ -30,7 +30,7 @@ function endswith(a::AbstractString, b::AbstractString) end endswith(str::AbstractString, chars::Chars) = !isempty(str) && last(str) in chars -startswith(a::ByteString, b::ByteString) = startswith(a.data, b.data) +startswith(a::String, b::String) = startswith(a.data, b.data) startswith(a::Vector{UInt8}, b::Vector{UInt8}) = (length(a) >= length(b) && ccall(:memcmp, Int32, (Ptr{UInt8}, Ptr{UInt8}, UInt), a, b, length(b)) == 0) @@ -45,12 +45,12 @@ function chomp(s::AbstractString) if (j < 1 || s[j] != '\r') return s[1:i-1] end return s[1:j-1] end -chomp(s::ByteString) = +chomp(s::String) = (endof(s) < 1 || s.data[end] != 0x0a) ? s : (endof(s) < 2 || s.data[end-1] != 0x0d) ? s[1:end-1] : s[1:end-2] # NOTE: use with caution -- breaks the immutable string convention! -function chomp!(s::ByteString) +function chomp!(s::String) if !isempty(s) && s.data[end] == 0x0a n = (endof(s) < 2 || s.data[end-1] != 0x0d) ? 1 : 2 ccall(:jl_array_del_end, Void, (Any, UInt), s.data, n) @@ -177,7 +177,7 @@ _replace(io, repl, str, r, pattern) = print(io, repl) _replace(io, repl::Function, str, r, pattern) = print(io, repl(SubString(str, first(r), last(r)))) -function replace(str::ByteString, pattern, repl, limit::Integer) +function replace(str::String, pattern, repl, limit::Integer) n = 1 e = endof(str) i = a = start(str) @@ -241,5 +241,5 @@ function bytes2hex(a::AbstractArray{UInt8}) b[i += 1] = hex_chars[1 + x >> 4] b[i += 1] = hex_chars[1 + x & 0xf] end - return ASCIIString(b) + return String(b) end diff --git a/base/sysimg.jl b/base/sysimg.jl index 25dfc399d9b64..aed8231efd4c9 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -113,8 +113,8 @@ typealias StridedMatrix{T,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Var typealias StridedVecOrMat{T} Union{StridedVector{T}, StridedMatrix{T}} # For OS specific stuff -include(UTF8String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "build_h.jl".data))) # include($BUILDROOT/base/build_h.jl) -include(UTF8String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "version_git.jl".data))) # include($BUILDROOT/base/version_git.jl) +include(String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "build_h.jl".data))) # include($BUILDROOT/base/build_h.jl) +include(String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "version_git.jl".data))) # include($BUILDROOT/base/version_git.jl) include("osutils.jl") include("c.jl") diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 099592c5befa8..cf4df358fb02a 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -27,8 +27,8 @@ function __init__() haskey(ENV,"JULIA_CPU_CORES") ? parse(Int,ENV["JULIA_CPU_CORES"]) : Int(ccall(:jl_cpu_cores, Int32, ())) global const SC_CLK_TCK = ccall(:jl_SC_CLK_TCK, Clong, ()) - global const cpu_name = ccall(:jl_get_cpu_name, Ref{ByteString}, ()) - global const JIT = ccall(:jl_get_JIT, Ref{ByteString}, ()) + global const cpu_name = ccall(:jl_get_cpu_name, Ref{String}, ()) + global const JIT = ccall(:jl_get_JIT, Ref{String}, ()) end type UV_cpu_info_t @@ -41,7 +41,7 @@ type UV_cpu_info_t cpu_times!irq::UInt64 end type CPUinfo - model::ASCIIString + model::String speed::Int32 cpu_times!user::UInt64 cpu_times!nice::UInt64 diff --git a/base/unicode/types.jl b/base/unicode/types.jl index 52765a853303b..61f69d6a6638d 100644 --- a/base/unicode/types.jl +++ b/base/unicode/types.jl @@ -30,5 +30,5 @@ immutable UTF32String <: DirectIndexString end UTF32String(data::Vector{Char}) = UTF32String(reinterpret(UInt32, data)) -isvalid{T<:Union{ASCIIString,UTF8String,UTF16String,UTF32String}}(str::T) = isvalid(T, str.data) -isvalid{T<:Union{ASCIIString,UTF8String,UTF16String,UTF32String}}(::Type{T}, str::T) = isvalid(T, str.data) +isvalid{T<:Union{String,UTF16String,UTF32String}}(str::T) = isvalid(T, str.data) +isvalid{T<:Union{String,UTF16String,UTF32String}}(::Type{T}, str::T) = isvalid(T, str.data) diff --git a/base/unicode/utf16.jl b/base/unicode/utf16.jl index 712adbb75a896..b819c2cfb106c 100644 --- a/base/unicode/utf16.jl +++ b/base/unicode/utf16.jl @@ -119,7 +119,7 @@ function convert(::Type{UTF16String}, str::AbstractString) UTF16String(buf) end -function convert(::Type{UTF16String}, str::UTF8String) +function convert(::Type{UTF16String}, str::String) dat = str.data # handle zero length string quickly sizeof(dat) == 0 && return empty_utf16 @@ -156,14 +156,14 @@ function convert(::Type{UTF16String}, str::UTF8String) UTF16String(buf) end -function convert(::Type{UTF8String}, str::UTF16String) +function convert(::Type{String}, str::UTF16String) dat = str.data len = sizeof(dat) >>> 1 # handle zero length string quickly len <= 1 && return empty_utf8 # get number of bytes to allocate len, flags, num4byte, num3byte, num2byte = unsafe_checkstring(dat, 1, len-1) - flags == 0 && @inbounds return UTF8String(copy!(Vector{UInt8}(len), 1, dat, 1, len)) + flags == 0 && @inbounds return String(copy!(Vector{UInt8}(len), 1, dat, 1, len)) return encode_to_utf8(UInt16, dat, len + num2byte + num3byte*2 + num4byte*3) end @@ -196,11 +196,6 @@ function encode_to_utf16(dat, len) UTF16String(buf) end -function convert(::Type{UTF16String}, str::ASCIIString) - dat = str.data - @inbounds return fast_utf_copy(UTF16String, UInt16, length(dat), dat, true) -end - convert(::Type{Vector{UInt16}}, str::UTF16String) = str.data convert(::Type{Array{UInt16}}, str::UTF16String) = str.data diff --git a/base/unicode/utf32.jl b/base/unicode/utf32.jl index 53d1c2fcabb8d..3d36b58fef103 100644 --- a/base/unicode/utf32.jl +++ b/base/unicode/utf32.jl @@ -23,18 +23,18 @@ function convert(::Type{UTF32String}, str::AbstractString) UTF32String(buf) end -function convert(::Type{UTF8String}, str::UTF32String) +function convert(::Type{String}, str::UTF32String) dat = str.data len = sizeof(dat) >>> 2 # handle zero length string quickly len <= 1 && return empty_utf8 # get number of bytes to allocate len, flags, num4byte, num3byte, num2byte = unsafe_checkstring(dat, 1, len-1) - flags == 0 && @inbounds return UTF8String(copy!(Vector{UInt8}(len), 1, dat, 1, len)) + flags == 0 && @inbounds return String(copy!(Vector{UInt8}(len), 1, dat, 1, len)) return encode_to_utf8(UInt32, dat, len + num2byte + num3byte*2 + num4byte*3) end -function convert(::Type{UTF32String}, str::UTF8String) +function convert(::Type{UTF32String}, str::String) dat = str.data # handle zero length string quickly sizeof(dat) == 0 && return empty_utf32 @@ -113,11 +113,6 @@ function convert(::Type{UTF16String}, str::UTF32String) return encode_to_utf16(dat, len + num4byte) end -function convert(::Type{UTF32String}, str::ASCIIString) - dat = str.data - @inbounds return fast_utf_copy(UTF32String, UInt32, length(dat), dat, true) -end - function convert(::Type{UTF32String}, dat::AbstractVector{UInt32}) @inbounds return fast_utf_copy(UTF32String, UInt32, length(dat), dat, true) end @@ -132,13 +127,13 @@ convert{T<:AbstractString, S<:Union{UInt32,Char,Int32}}(::Type{T}, v::AbstractVe convert(T, utf32(v)) # specialize for performance reasons: -function convert{T<:ByteString, S<:Union{UInt32,Char,Int32}}(::Type{T}, data::AbstractVector{S}) +function convert{T<:Union{UInt32,Char,Int32}}(::Type{String}, data::AbstractVector{T}) s = IOBuffer(Array(UInt8,length(data)), true, true) truncate(s,0) for x in data print(s, Char(x)) end - convert(T, takebuf_string(s)) + takebuf_string(s) end convert(::Type{Vector{UInt32}}, str::UTF32String) = str.data @@ -205,7 +200,7 @@ end # '\0', and which are terminated by a '\0' containsnul(s::AbstractString) = '\0' in s -containsnul(s::ByteString) = containsnul(unsafe_convert(Ptr{Cchar}, s), sizeof(s)) +containsnul(s::String) = containsnul(unsafe_convert(Ptr{Cchar}, s), sizeof(s)) containsnul(s::Union{UTF16String,UTF32String}) = findfirst(s.data, 0) != length(s.data) if sizeof(Cwchar_t) == 2 @@ -227,12 +222,12 @@ function unsafe_convert(::Type{Cwstring}, s::WString) end # pointer conversions of ASCII/UTF8/UTF16/UTF32 strings: -pointer(x::Union{ByteString,UTF16String,UTF32String}) = pointer(x.data) -pointer(x::ByteString, i::Integer) = pointer(x.data)+(i-1) +pointer(x::Union{String,UTF16String,UTF32String}) = pointer(x.data) +pointer(x::String, i::Integer) = pointer(x.data)+(i-1) pointer(x::Union{UTF16String,UTF32String}, i::Integer) = pointer(x)+(i-1)*sizeof(eltype(x.data)) # pointer conversions of SubString of ASCII/UTF8/UTF16/UTF32: -pointer{T<:ByteString}(x::SubString{T}) = pointer(x.string.data) + x.offset -pointer{T<:ByteString}(x::SubString{T}, i::Integer) = pointer(x.string.data) + x.offset + (i-1) +pointer(x::SubString{String}) = pointer(x.string.data) + x.offset +pointer(x::SubString{String}, i::Integer) = pointer(x.string.data) + x.offset + (i-1) pointer{T<:Union{UTF16String,UTF32String}}(x::SubString{T}) = pointer(x.string.data) + x.offset*sizeof(eltype(x.string.data)) pointer{T<:Union{UTF16String,UTF32String}}(x::SubString{T}, i::Integer) = pointer(x.string.data) + (x.offset + (i-1))*sizeof(eltype(x.string.data)) diff --git a/base/unicode/utf8.jl b/base/unicode/utf8.jl index 75e4c0094da0e..ded4d5ed630c6 100644 --- a/base/unicode/utf8.jl +++ b/base/unicode/utf8.jl @@ -2,7 +2,7 @@ ## from base/boot.jl: # -# immutable UTF8String <: AbstractString +# immutable String <: AbstractString # data::Vector{UInt8} # end # @@ -28,7 +28,7 @@ const utf8_trailing = [ ## required core functionality ## -function endof(s::UTF8String) +function endof(s::String) d = s.data i = length(d) i == 0 && return i @@ -38,7 +38,7 @@ function endof(s::UTF8String) i end -function length(s::UTF8String) +function length(s::String) d = s.data cnum = 0 for i = 1:length(d) @@ -47,7 +47,7 @@ function length(s::UTF8String) cnum end -function next(s::UTF8String, i::Int) +function next(s::String, i::Int) # potentially faster version # d = s.data # a::UInt32 = d[i] @@ -86,7 +86,7 @@ function first_utf8_byte(ch::Char) ((c>>18) | 0xf0)%UInt8 end -function reverseind(s::UTF8String, i::Integer) +function reverseind(s::String, i::Integer) j = lastidx(s) + 1 - i d = s.data while is_valid_continuation(d[j]) @@ -97,16 +97,16 @@ end ## overload methods for efficiency ## -sizeof(s::UTF8String) = sizeof(s.data) +sizeof(s::String) = sizeof(s.data) -lastidx(s::UTF8String) = length(s.data) +lastidx(s::String) = length(s.data) -isvalid(s::UTF8String, i::Integer) = +isvalid(s::String, i::Integer) = (1 <= i <= endof(s.data)) && !is_valid_continuation(s.data[i]) -const empty_utf8 = UTF8String(UInt8[]) +const empty_utf8 = String(UInt8[]) -function getindex(s::UTF8String, r::UnitRange{Int}) +function getindex(s::String, r::UnitRange{Int}) isempty(r) && return empty_utf8 i, j = first(r), last(r) d = s.data @@ -120,10 +120,10 @@ function getindex(s::UTF8String, r::UnitRange{Int}) throw(BoundsError()) end j = nextind(s,j)-1 - UTF8String(d[i:j]) + String(d[i:j]) end -function search(s::UTF8String, c::Char, i::Integer) +function search(s::String, c::Char, i::Integer) if i < 1 || i > sizeof(s) i == sizeof(s) + 1 && return 0 throw(BoundsError(s, i)) @@ -140,7 +140,7 @@ function search(s::UTF8String, c::Char, i::Integer) end end -function rsearch(s::UTF8String, c::Char, i::Integer) +function rsearch(s::String, c::Char, i::Integer) c < Char(0x80) && return rsearch(s.data, c%UInt8, i) b = first_utf8_byte(c) while true @@ -150,19 +150,19 @@ function rsearch(s::UTF8String, c::Char, i::Integer) end end -function string(a::ByteString...) +function string(a::String...) if length(a) == 1 - return a[1]::UTF8String + return a[1]::String end # ^^ at least one must be UTF-8 or the ASCII-only method would get called data = Array(UInt8,0) for d in a append!(data,d.data) end - UTF8String(data) + String(data) end -function string(a::Union{ByteString,Char}...) +function string(a::Union{String,Char}...) s = Array(UInt8,0) for d in a if isa(d,Char) @@ -189,10 +189,10 @@ function string(a::Union{ByteString,Char}...) append!(s,d.data) end end - UTF8String(s) + String(s) end -function reverse(s::UTF8String) +function reverse(s::String) dat = s.data n = length(dat) n <= 1 && return s @@ -221,29 +221,26 @@ function reverse(s::UTF8String) pos += 1 end end - UTF8String(buf) + String(buf) end ## outputting UTF-8 strings ## -write(io::IO, s::UTF8String) = write(io, s.data) +write(io::IO, s::String) = write(io, s.data) ## transcoding to UTF-8 ## -utf8(x) = convert(UTF8String, x) -convert(::Type{UTF8String}, s::UTF8String) = s -convert(::Type{UTF8String}, s::ASCIIString) = UTF8String(s.data) -convert(::Type{SubString{UTF8String}}, s::SubString{ASCIIString}) = - SubString(utf8(s.string), s.offset+1, s.endof+s.offset) +utf8(x) = convert(String, x) +convert(::Type{String}, s::String) = s -function convert(::Type{UTF8String}, dat::Vector{UInt8}) +function convert(::Type{String}, dat::Vector{UInt8}) # handle zero length string quickly isempty(dat) && return empty_utf8 # get number of bytes to allocate len, flags, num4byte, num3byte, num2byte = unsafe_checkstring(dat) if (flags & (UTF_LONG | UTF_SURROGATE)) == 0 len = sizeof(dat) - @inbounds return UTF8String(copy!(Vector{UInt8}(len), 1, dat, 1, len)) + @inbounds return String(copy!(Vector{UInt8}(len), 1, dat, 1, len)) end # Copy, but eliminate over-long encodings and surrogate pairs len += num2byte + num3byte*2 + num4byte*3 @@ -286,10 +283,10 @@ function convert(::Type{UTF8String}, dat::Vector{UInt8}) end end end - UTF8String(buf) + String(buf) end -function convert(::Type{UTF8String}, a::Vector{UInt8}, invalids_as::AbstractString) +function convert(::Type{String}, a::Vector{UInt8}, invalids_as::AbstractString) l = length(a) idx = 1 iscopy = false @@ -308,12 +305,12 @@ function convert(::Type{UTF8String}, a::Vector{UInt8}, invalids_as::AbstractStri splice!(a, idx:endn, invalids_as.data) l = length(a) end - UTF8String(a) + String(a) end -convert(::Type{UTF8String}, s::AbstractString) = utf8(bytestring(s)) +convert(::Type{String}, s::AbstractString) = utf8(bytestring(s)) """ -Converts an already validated vector of `UInt16` or `UInt32` to a `UTF8String` +Converts an already validated vector of `UInt16` or `UInt32` to a `String` Input Arguments: @@ -322,7 +319,7 @@ Input Arguments: Returns: -* `UTF8String` +* `String` """ function encode_to_utf8{T<:Union{UInt16, UInt32}}(::Type{T}, dat, len) buf = Vector{UInt8}(len) @@ -352,13 +349,12 @@ function encode_to_utf8{T<:Union{UInt16, UInt32}}(::Type{T}, dat, len) buf[out += 1] = 0x80 | (ch & 0x3f) end end - UTF8String(buf) + String(buf) end utf8(p::Ptr{UInt8}) = utf8(p, p == C_NULL ? Csize_t(0) : ccall(:strlen, Csize_t, (Ptr{UInt8},), p)) function utf8(p::Ptr{UInt8}, len::Integer) p == C_NULL && throw(ArgumentError("cannot convert NULL to string")) - UTF8String(ccall(:jl_pchar_to_array, Vector{UInt8}, - (Ptr{UInt8}, Csize_t), p, len)) + String(ccall(:jl_pchar_to_array, Vector{UInt8}, (Ptr{UInt8}, Csize_t), p, len)) end diff --git a/base/unicode/utf8proc.jl b/base/unicode/utf8proc.jl index be517a156bec1..64c0aab7773d9 100644 --- a/base/unicode/utf8proc.jl +++ b/base/unicode/utf8proc.jl @@ -68,14 +68,14 @@ const UTF8PROC_STRIPMARK = (1<<13) ############################################################################ -function utf8proc_map(s::ByteString, flags::Integer) +function utf8proc_map(s::String, flags::Integer) p = Ref{Ptr{UInt8}}() result = ccall(:utf8proc_map, Cssize_t, (Ptr{UInt8}, Cssize_t, Ref{Ptr{UInt8}}, Cint), s, sizeof(s), p, flags) result < 0 && error(bytestring(ccall(:utf8proc_errmsg, Cstring, (Cssize_t,), result))) - pointer_to_string(p[], result, true)::ByteString + pointer_to_string(p[], result, true)::String end utf8proc_map(s::AbstractString, flags::Integer) = utf8proc_map(bytestring(s), flags) @@ -156,8 +156,7 @@ iscntrl(c::Char) = (c <= Char(0x1f) || Char(0x7f) <= c <= Char(0x9f)) ispunct(c::Char) = (UTF8PROC_CATEGORY_PC <= category_code(c) <= UTF8PROC_CATEGORY_PO) # \u85 is the Unicode Next Line (NEL) character -# the check for \ufffd allows for branch removal on ASCIIStrings -@inline isspace(c::Char) = c == ' ' || '\t' <= c <='\r' || c == '\u85' || '\ua0' <= c && c != '\ufffd' && category_code(c)==UTF8PROC_CATEGORY_ZS +@inline isspace(c::Char) = c == ' ' || '\t' <= c <='\r' || c == '\u85' || '\ua0' <= c && category_code(c) == UTF8PROC_CATEGORY_ZS isprint(c::Char) = (UTF8PROC_CATEGORY_LU <= category_code(c) <= UTF8PROC_CATEGORY_ZS) diff --git a/base/version.jl b/base/version.jl index 7777fe765e1bb..66c595c302366 100644 --- a/base/version.jl +++ b/base/version.jl @@ -6,12 +6,12 @@ immutable VersionNumber major::Int minor::Int patch::Int - prerelease::Tuple{Vararg{Union{Int,ASCIIString}}} - build::Tuple{Vararg{Union{Int,ASCIIString}}} + prerelease::Tuple{Vararg{Union{Int,String}}} + build::Tuple{Vararg{Union{Int,String}}} function VersionNumber(major::Int, minor::Int, patch::Int, - pre::Tuple{Vararg{Union{Int,ASCIIString}}}, - bld::Tuple{Vararg{Union{Int,ASCIIString}}}) + pre::Tuple{Vararg{Union{Int,String}}}, + bld::Tuple{Vararg{Union{Int,String}}}) major >= 0 || throw(ArgumentError("invalid negative major version: $major")) minor >= 0 || throw(ArgumentError("invalid negative minor version: $minor")) patch >= 0 || throw(ArgumentError("invalid negative patch version: $patch")) @@ -42,8 +42,8 @@ VersionNumber(major::Integer, minor::Integer = 0, patch::Integer = 0, pre::Tuple{Vararg{Union{Integer,AbstractString}}} = (), bld::Tuple{Vararg{Union{Integer,AbstractString}}} = ()) = VersionNumber(Int(major), Int(minor), Int(patch), - map(x->isa(x,Integer) ? Int(x) : ASCIIString(x), pre), - map(x->isa(x,Integer) ? Int(x) : ASCIIString(x), bld)) + map(x->isa(x,Integer) ? Int(x) : String(x), pre), + map(x->isa(x,Integer) ? Int(x) : String(x), bld)) function print(io::IO, v::VersionNumber) v == typemax(VersionNumber) && return print(io, "∞") @@ -109,12 +109,12 @@ typemin(::Type{VersionNumber}) = v"0-" typemax(::Type{VersionNumber}) = VersionNumber(typemax(Int),typemax(Int),typemax(Int),(),("",)) ident_cmp(a::Int, b::Int) = cmp(a,b) -ident_cmp(a::Int, b::ASCIIString) = isempty(b) ? +1 : -1 -ident_cmp(a::ASCIIString, b::Int) = isempty(a) ? -1 : +1 -ident_cmp(a::ASCIIString, b::ASCIIString) = cmp(a,b) +ident_cmp(a::Int, b::String) = isempty(b) ? +1 : -1 +ident_cmp(a::String, b::Int) = isempty(a) ? -1 : +1 +ident_cmp(a::String, b::String) = cmp(a,b) -function ident_cmp(A::Tuple{Vararg{Union{Int,ASCIIString}}}, - B::Tuple{Vararg{Union{Int,ASCIIString}}}) +function ident_cmp(A::Tuple{Vararg{Union{Int,String}}}, + B::Tuple{Vararg{Union{Int,String}}}) i = start(A) j = start(B) while !done(A,i) && !done(B,i) diff --git a/contrib/Julia_Notepad++.xml b/contrib/Julia_Notepad++.xml index ea137be18b6a9..fe56575e970ae 100644 --- a/contrib/Julia_Notepad++.xml +++ b/contrib/Julia_Notepad++.xml @@ -25,7 +25,7 @@ true false C_NULL Inf NaN Inf32 NaN32 nothing - ASCIIString AbstractArray AbstractMatrix AbstractSparseMatrix AbstractString AbstractVector Any ArgumentError Array Associative AsyncStream BigFloat BigInt BitArray BitMatrix BitVector Bool BunchKaufman ByteString Cchar Cdouble Cfloat Char CharString CholeskyDense CholeskyPivotedDense Cint Cintmax_t Clong Clonglong Colon Complex Complex128 Complex64 ComplexPair Cptrdiff_t Cshort Csize_t Cuchar Cuint Cuintmax_t Culong Culonglong Cushort DArray Dict Dims DisconnectException EOFError EachLine EnvHash ErrorException Exception Expr Factorization Filter Float Float32 Float64 Function GSVDDense IO IOBuffer IOStream ImaginaryUnit InsertionSort Int Int128 Int16 Int32 Int64 Int8 IntSet Integer KeyError LDLTTridiagonal LUDense LUTridiagonal LoadError LocalProcess Matrix MergeSort MethodError NTuple Number ObjectIdDict ObjectIdDict OrdinalRange ParseError PipeBuffer ProcessGroup Ptr QRDense QRPivotedDense QuickSort Range Range1 RangeIndex Ranges Rational Real Regex RegexMatch RegexMatchIterator RemoteRef RepString RevString Reverse RopeString SVDDense Set Signed SparseMatrixCSC SpawnNullStream Stat StridedArray StridedMatrix StridedVecOrMat StridedVector SubArray SubDArray SubOrDArray SubString SymTridiagonal Symbol SystemError Task TCPSocket TimSort Tridiagonal Tuple Type TypeError UInt UInt128 UInt16 UInt32 UInt64 UInt8 UTF8String UVError Union Unsigned VecOrMat Vector VersionNumber Void WeakKeyDict WeakRef Zip + AbstractArray AbstractMatrix AbstractSparseMatrix AbstractString AbstractVector Any ArgumentError Array Associative AsyncStream BigFloat BigInt BitArray BitMatrix BitVector Bool BunchKaufman Cchar Cdouble Cfloat Char CharString CholeskyDense CholeskyPivotedDense Cint Cintmax_t Clong Clonglong Colon Complex Complex128 Complex64 ComplexPair Cptrdiff_t Cshort Csize_t Cuchar Cuint Cuintmax_t Culong Culonglong Cushort DArray Dict Dims DisconnectException EOFError EachLine EnvHash ErrorException Exception Expr Factorization Filter Float Float32 Float64 Function GSVDDense IO IOBuffer IOStream ImaginaryUnit InsertionSort Int Int128 Int16 Int32 Int64 Int8 IntSet Integer KeyError LDLTTridiagonal LUDense LUTridiagonal LoadError LocalProcess Matrix MergeSort MethodError NTuple Number ObjectIdDict ObjectIdDict OrdinalRange ParseError PipeBuffer ProcessGroup Ptr QRDense QRPivotedDense QuickSort Range Range1 RangeIndex Ranges Rational Real Regex RegexMatch RegexMatchIterator RemoteRef RepString RevString Reverse RopeString SVDDense Set Signed SparseMatrixCSC SpawnNullStream Stat StridedArray StridedMatrix StridedVecOrMat StridedVector String SubArray SubDArray SubOrDArray SubString SymTridiagonal Symbol SystemError Task TCPSocket TimSort Tridiagonal Tuple Type TypeError UInt UInt128 UInt16 UInt32 UInt64 UInt8 UVError Union Unsigned VecOrMat Vector VersionNumber Void WeakKeyDict WeakRef Zip abstract begin baremodule bitstype break catch ccall const continue do else elseif end export finally for function global if immutable import importall let local macro module quote return try type typealias using while close enumerate error info open print println read write warn print println diff --git a/contrib/add_license_to_files.jl b/contrib/add_license_to_files.jl index 53bb003f5267f..383fff8c059f5 100644 --- a/contrib/add_license_to_files.jl +++ b/contrib/add_license_to_files.jl @@ -71,8 +71,9 @@ const old_license = "" ### END CONFIG HERE -function check_lines!(path::AbstractString, lines::Vector, checktxt::AbstractString, - prefix::ASCIIString, oldcheck::Bool) +function check_lines!( + path::AbstractString, lines::Vector, checktxt::AbstractString, + prefix::AbstractString, oldcheck::Bool) remove = [] for i in 1:length(lines) line = lines[i] diff --git a/contrib/julia.hrc b/contrib/julia.hrc index 3e5b308fa5394..4ab36ca633ee4 100644 --- a/contrib/julia.hrc +++ b/contrib/julia.hrc @@ -141,7 +141,7 @@ - + diff --git a/contrib/julia.xml b/contrib/julia.xml index d068b9a56ec38..9514afa5999ed 100644 --- a/contrib/julia.xml +++ b/contrib/julia.xml @@ -81,7 +81,6 @@ AbstractVector Any Array - ASCIIString Associative AsyncStream Bidiagonal @@ -91,7 +90,6 @@ BitMatrix BitVector Bool - ByteString Char CharString Cholesky @@ -198,7 +196,6 @@ UInt128 Union Unsigned - UTF8String UVError VecOrMat Vector diff --git a/doc/devdocs/init.rst b/doc/devdocs/init.rst index 7fcb3b9de065f..d6aca3002337b 100644 --- a/doc/devdocs/init.rst +++ b/doc/devdocs/init.rst @@ -196,26 +196,26 @@ Stack frame Source code Notes ============================ ================= =============================================== jl_uv_write() jl_uv.c called though :func:`Base.ccall` julia_write_282942 stream.jl function write!{T}(s::AsyncStream, a::Array{T}) -julia_print_284639 ascii.jl print(io::IO, s::ASCIIString) = (write(io, s);nothing) +julia_print_284639 ascii.jl print(io::IO, s::String) = (write(io, s);nothing) jlcall_print_284639 jl_apply() julia.h jl_trampoline() builtins.c jl_apply() julia.h -jl_apply_generic() gf.c Base.print(Base.TTY, ASCIIString) +jl_apply_generic() gf.c Base.print(Base.TTY, String) jl_apply() julia.h jl_trampoline() builtins.c jl_apply() julia.h -jl_apply_generic() gf.c Base.print(Base.TTY, ASCIIString, Char, Char...) +jl_apply_generic() gf.c Base.print(Base.TTY, String, Char, Char...) jl_apply() julia.h jl_f_apply() builtins.c jl_apply() julia.h jl_trampoline() builtins.c jl_apply() julia.h -jl_apply_generic() gf.c Base.println(Base.TTY, ASCIIString, ASCIIString...) +jl_apply_generic() gf.c Base.println(Base.TTY, String, String...) jl_apply() julia.h jl_trampoline() builtins.c jl_apply() julia.h -jl_apply_generic() gf.c Base.println(ASCIIString,) +jl_apply_generic() gf.c Base.println(String,) jl_apply() julia.h do_call() interpreter.c eval() interpreter.c diff --git a/doc/genstdlib.jl b/doc/genstdlib.jl index 54de25528af82..d57828fe21754 100644 --- a/doc/genstdlib.jl +++ b/doc/genstdlib.jl @@ -10,10 +10,10 @@ const DOCSTRING_DIRECTIVE = r"^(.. (function):: ).*" typealias Signature Tuple{Binding, Type} type State - files :: Dict{UTF8String, Vector{UTF8String}} - validdocs :: Dict{UTF8String, Tuple{Module, Signature, DocStr}} + files :: Dict{String, Vector{String}} + validdocs :: Dict{String, Tuple{Module, Signature, DocStr}} baddocs :: Dict{Signature, Tuple{Module, DocStr}} - documented :: Dict{Signature, Tuple{Module, DocStr, UTF8String}} + documented :: Dict{Signature, Tuple{Module, DocStr, String}} errorlevel :: Int debug :: Bool State() = new(Dict(), Dict(), Dict(), Dict(), 0, "JULIA_GENSTDLIB_DEBUG" in keys(ENV)) diff --git a/doc/manual/calling-c-and-fortran-code.rst b/doc/manual/calling-c-and-fortran-code.rst index 7751bdf1afdee..6d3a7aed48459 100644 --- a/doc/manual/calling-c-and-fortran-code.rst +++ b/doc/manual/calling-c-and-fortran-code.rst @@ -266,7 +266,7 @@ First, a review of some relevant Julia type terminology: ============================== ============================== ====================================================== Syntax / Keyword Example Description ============================== ============================== ====================================================== -``type`` ``ASCIIString`` "Leaf Type" :: A group of related data that includes +``type`` ``String`` "Leaf Type" :: A group of related data that includes a type-tag, is managed by the Julia GC, and is defined by object-identity. The type parameters of a leaf type must be fully defined @@ -345,7 +345,7 @@ There are several special types to be aware of, as no other type can be defined If an array of eltype ``Ptr{T}`` is passed as a ``Ptr{Ptr{T}}`` argument, :func:`Base.cconvert` will attempt to first make a null-terminated copy of the array with each element replaced by its :func:`cconvert` version. This allows, for example, passing an ``argv`` - pointer array of type ``Vector{ByteString}`` to an argument of type ``Ptr{Ptr{Cchar}}``. + pointer array of type ``Vector{String}`` to an argument of type ``Ptr{Ptr{Cchar}}``. On all systems we currently support, basic C/C++ value types may be translated to Julia types as follows. Every C type also has a corresponding @@ -468,7 +468,7 @@ C name Standard Julia Alias Julia Base Type For string arguments (``char*``) the Julia type should be ``Cstring`` (if NUL- terminated data is expected) or either ``Ptr{Cchar}`` or ``Ptr{UInt8}`` otherwise (these two pointer types have the same effect), as described above, - not ``ASCIIString``. Similarly, for array arguments (``T[]`` or ``T*``), the + not ``String``. Similarly, for array arguments (``T[]`` or ``T*``), the Julia type should again be ``Ptr{T}``, not ``Vector{T}``. .. warning:: diff --git a/doc/manual/conversion-and-promotion.rst b/doc/manual/conversion-and-promotion.rst index 103f41fd2750e..7d37fc18d843b 100644 --- a/doc/manual/conversion-and-promotion.rst +++ b/doc/manual/conversion-and-promotion.rst @@ -97,7 +97,7 @@ requested conversion: .. doctest:: julia> convert(AbstractFloat, "foo") - ERROR: MethodError: Cannot `convert` an object of type ASCIIString to an object of type AbstractFloat + ERROR: MethodError: Cannot `convert` an object of type String to an object of type AbstractFloat This may have arisen from a call to the constructor AbstractFloat(...), since type constructors fall back to convert methods. Closest candidates are: diff --git a/doc/manual/dates.rst b/doc/manual/dates.rst index ee886e862f070..5b1ef2a0c4410 100644 --- a/doc/manual/dates.rst +++ b/doc/manual/dates.rst @@ -58,7 +58,7 @@ Delimited slots are marked by specifying the delimiter the parser should expect Fixed-width slots are specified by repeating the period character the number of times corresponding to the width with no delimiter between characters. So ``"yyyymmdd"`` would correspond to a date string like ``"20140716"``. The parser distinguishes a fixed-width slot by the absence of a delimiter, noting the transition ``"yyyymm"`` from one period character to the next. -Support for text-form month parsing is also supported through the ``u`` and ``U`` characters, for abbreviated and full-length month names, respectively. By default, only English month names are supported, so ``u`` corresponds to "Jan", "Feb", "Mar", etc. And ``U`` corresponds to "January", "February", "March", etc. Similar to other name=>value mapping functions :func:`dayname` and :func:`monthname`, custom locales can be loaded by passing in the ``locale=>Dict{UTF8String,Int}`` mapping to the :const:`MONTHTOVALUEABBR` and :const:`MONTHTOVALUE` dicts for abbreviated and full-name month names, respectively. +Support for text-form month parsing is also supported through the ``u`` and ``U`` characters, for abbreviated and full-length month names, respectively. By default, only English month names are supported, so ``u`` corresponds to "Jan", "Feb", "Mar", etc. And ``U`` corresponds to "January", "February", "March", etc. Similar to other name=>value mapping functions :func:`dayname` and :func:`monthname`, custom locales can be loaded by passing in the ``locale=>Dict{String,Int}`` mapping to the :const:`MONTHTOVALUEABBR` and :const:`MONTHTOVALUE` dicts for abbreviated and full-name month names, respectively. One note on parsing performance: using the ``Date(date_string,format_string)`` function is fine if only called a few times. If there are many similarly formatted date strings to parse however, it is much more efficient to first create a :class:`Dates.DateFormat`, and pass it instead of a raw format string. @@ -233,7 +233,7 @@ The :func:`dayname` and :func:`monthname` methods can also take an optional ``lo julia> Dates.dayname(t;locale="french") "Vendredi" -Similarly for the :func:`monthname` function, a mapping of ``locale=>Dict{Int,UTF8String}`` should be loaded in :const:`VALUETOMONTH`. +Similarly for the :func:`monthname` function, a mapping of ``locale=>Dict{Int,String}`` should be loaded in :const:`VALUETOMONTH`. TimeType-Period Arithmetic -------------------------- diff --git a/doc/manual/interacting-with-julia.rst b/doc/manual/interacting-with-julia.rst index 9c80679ff185f..bbb60d85f4dce 100644 --- a/doc/manual/interacting-with-julia.rst +++ b/doc/manual/interacting-with-julia.rst @@ -69,7 +69,7 @@ In addition to function names, complete function calls may be entered to see whi help> AbstractString DataType : AbstractString supertype: Any - subtypes : Any[DirectIndexString,RepString,RevString{T<:AbstractString},RopeString,SubString{T<:AbstractString},UTF16String,UTF8String] + subtypes : Any[DirectIndexString,RepString,RevString{T<:AbstractString},RopeString,SubString{T<:AbstractString},String] Help mode can be exited by pressing backspace at the beginning of the line. diff --git a/doc/manual/metaprogramming.rst b/doc/manual/metaprogramming.rst index 5c202e54e1ab6..8be410842f55c 100644 --- a/doc/manual/metaprogramming.rst +++ b/doc/manual/metaprogramming.rst @@ -611,7 +611,7 @@ Compare: .. doctest:: julia> typeof(:("a should equal b")) - ASCIIString + String julia> typeof(:("a ($a) should equal b ($b)!")) Expr @@ -620,11 +620,11 @@ Compare: Expr head: Symbol string args: Array(Any,(5,)) - 1: ASCIIString "a (" + 1: String "a (" 2: Symbol a - 3: ASCIIString ") should equal b (" + 3: String ") should equal b (" 4: Symbol b - 5: ASCIIString ")!" + 5: String ")!" typ: Any So now instead of getting a plain string in ``msg_body``, the macro is @@ -931,7 +931,7 @@ Let's see how ``foo`` behaves: 4 julia> y = foo("bar"); - ASCIIString + String julia> y "barbar" diff --git a/doc/manual/methods.rst b/doc/manual/methods.rst index 9b6dd768228d1..f501613d4388a 100644 --- a/doc/manual/methods.rst +++ b/doc/manual/methods.rst @@ -103,12 +103,12 @@ Applying it to any other types of arguments will result in a :exc:`MethodError`: f(!Matched::Float64, ::Float64) julia> f(2.0, "3.0") - ERROR: MethodError: `f` has no method matching f(::Float64, ::ASCIIString) + ERROR: MethodError: `f` has no method matching f(::Float64, ::String) Closest candidates are: f(::Float64, !Matched::Float64) julia> f("2.0", "3.0") - ERROR: MethodError: `f` has no method matching f(::ASCIIString, ::ASCIIString) + ERROR: MethodError: `f` has no method matching f(::String, ::String) As you can see, the arguments must be precisely of type :obj:`Float64`. Other numeric types, such as integers or 32-bit floating-point values, @@ -173,7 +173,7 @@ function ``f`` remains undefined, and applying it will still result in a .. doctest:: julia> f("foo", 3) - ERROR: MethodError: `f` has no method matching f(::ASCIIString, ::Int64) + ERROR: MethodError: `f` has no method matching f(::String, ::Int64) Closest candidates are: f(!Matched::Number, ::Number) @@ -539,10 +539,10 @@ can also constrain type parameters of methods:: true julia> same_type_numeric("foo", 2.0) - no method same_type_numeric(ASCIIString,Float64) + no method same_type_numeric(String,Float64) julia> same_type_numeric("foo", "bar") - no method same_type_numeric(ASCIIString,ASCIIString) + no method same_type_numeric(String,String) julia> same_type_numeric(Int32(1), Int64(2)) false diff --git a/doc/manual/networking-and-streams.rst b/doc/manual/networking-and-streams.rst index 31eb0ba56c905..523baae7168c8 100644 --- a/doc/manual/networking-and-streams.rst +++ b/doc/manual/networking-and-streams.rst @@ -118,7 +118,7 @@ are ``Hello, World!``:: IOStream() julia> readlines(f) - 1-element Array{Union{ASCIIString,UTF8String},1}: + 1-element Array{String,1}: "Hello, World!\n" If you want to write to a file, you can open it with the write (``"w"``) flag:: @@ -250,7 +250,7 @@ As with other streams, use :func:`close` to disconnect the socket:: Resolving IP Addresses ---------------------- -One of the :func:`connect` methods that does not follow the :func:`listen` methods is ``connect(host::ASCIIString,port)``, which will attempt to connect to the host +One of the :func:`connect` methods that does not follow the :func:`listen` methods is ``connect(host::String,port)``, which will attempt to connect to the host given by the ``host`` parameter on the port given by the port parameter. It allows you to do things like:: diff --git a/doc/manual/packages.rst b/doc/manual/packages.rst index e673b7d75dda6..dddb8df905b20 100644 --- a/doc/manual/packages.rst +++ b/doc/manual/packages.rst @@ -42,7 +42,7 @@ Packages can be in more complicated states, indicated by annotations to the righ For programmatic usage, :func:`Pkg.installed` returns a dictionary, mapping installed package names to the version of that package which is installed:: julia> Pkg.installed() - Dict{ASCIIString,VersionNumber} with 4 entries: + Dict{String,VersionNumber} with 4 entries: "Distributions" => v"0.2.8" "Stats" => v"0.2.6" "UTF16" => v"0.2.0" diff --git a/doc/manual/running-external-programs.rst b/doc/manual/running-external-programs.rst index 20b5b86440bfa..dcdf706468b43 100644 --- a/doc/manual/running-external-programs.rst +++ b/doc/manual/running-external-programs.rst @@ -127,7 +127,7 @@ case, just use an array (or any other iterable container): .. doctest:: julia> files = ["/etc/passwd","/Volumes/External HD/data.csv"] - 2-element Array{ASCIIString,1}: + 2-element Array{String,1}: "/etc/passwd" "/Volumes/External HD/data.csv" @@ -141,7 +141,7 @@ shell's ``{a,b,c}`` argument generation: .. doctest:: julia> names = ["foo","bar","baz"] - 3-element Array{ASCIIString,1}: + 3-element Array{String,1}: "foo" "bar" "baz" @@ -155,13 +155,13 @@ shell's Cartesian product generation behavior is emulated: .. doctest:: julia> names = ["foo","bar","baz"] - 3-element Array{ASCIIString,1}: + 3-element Array{String,1}: "foo" "bar" "baz" julia> exts = ["aux","log"] - 2-element Array{ASCIIString,1}: + 2-element Array{String,1}: "aux" "log" diff --git a/doc/manual/strings.rst b/doc/manual/strings.rst index 3b9384052d9e8..e402e2b400551 100644 --- a/doc/manual/strings.rst +++ b/doc/manual/strings.rst @@ -551,7 +551,7 @@ contained in a string: false julia> contains("Xylophon", 'o') - ERROR: MethodError: `contains` has no method matching contains(::ASCIIString, ::Char) + ERROR: MethodError: `contains` has no method matching contains(::String, ::Char) Closest candidates are: contains(!Matched::Function, ::Any, !Matched::Any) contains(::AbstractString, !Matched::AbstractString) @@ -707,7 +707,7 @@ a string is invalid). Here is a pair of somewhat contrived examples: "acd" julia> m.captures - 3-element Array{Union{SubString{UTF8String},Void},1}: + 3-element Array{Union{SubString{String},Void},1}: "a" "c" "d" @@ -728,7 +728,7 @@ a string is invalid). Here is a pair of somewhat contrived examples: "ad" julia> m.captures - 3-element Array{Union{SubString{UTF8String},Void},1}: + 3-element Array{Union{SubString{String},Void},1}: "a" nothing "d" diff --git a/doc/manual/types.rst b/doc/manual/types.rst index ae5401b2243da..b5c44007df66e 100644 --- a/doc/manual/types.rst +++ b/doc/manual/types.rst @@ -959,7 +959,7 @@ an appropriate tuple type is generated on demand: .. doctest:: julia> typeof((1,"foo",2.5)) - Tuple{Int64,ASCIIString,Float64} + Tuple{Int64,String,Float64} Note the implications of covariance: @@ -1196,7 +1196,7 @@ objects, they also have types, and we can ask what their types are: julia> typeof(Union{Real,Float64,Rational}) DataType - julia> typeof(Union{Real,ASCIIString}) + julia> typeof(Union{Real,String}) Union What if we repeat the process? What is the type of a type of a type? diff --git a/doc/stdlib/base.rst b/doc/stdlib/base.rst index 21f3d72aae543..cfe5fe679b4d4 100644 --- a/doc/stdlib/base.rst +++ b/doc/stdlib/base.rst @@ -128,7 +128,7 @@ Getting Around When searching for files, ``require`` first looks for package code under ``Pkg.dir()``\ , then tries paths in the global array ``LOAD_PATH``\ . -.. function:: Base.compilecache(module::ByteString) +.. function:: Base.compilecache(module::String) .. Docstring generated from Julia source diff --git a/doc/stdlib/collections.rst b/doc/stdlib/collections.rst index 85783d4b78af8..4e401e3cd6445 100644 --- a/doc/stdlib/collections.rst +++ b/doc/stdlib/collections.rst @@ -718,9 +718,9 @@ Associative Collections :obj:`WeakKeyDict` is a hash table implementation where the keys are weak references to objects, and thus may be garbage collected even when referenced in a hash table. -:obj:`Dict`\ s can be created by passing pair objects constructed with :func:`=>` to a :obj:`Dict` constructor: ``Dict("A"=>1, "B"=>2)``. This call will attempt to infer type information from the keys and values (i.e. this example creates a ``Dict{ASCIIString, Int64}``). +:obj:`Dict`\ s can be created by passing pair objects constructed with :func:`=>` to a :obj:`Dict` constructor: ``Dict("A"=>1, "B"=>2)``. This call will attempt to infer type information from the keys and values (i.e. this example creates a ``Dict{String, Int64}``). To explicitly specify types use the syntax ``Dict{KeyType,ValueType}(...)``. -For example, ``Dict{ASCIIString,Int32}("A"=>1, "B"=>2)``. +For example, ``Dict{String,Int32}("A"=>1, "B"=>2)``. As with :obj:`Array`\ s, :obj:`Dict`\ s may be created with comprehensions. For example, ``[i => f(i) for i = 1:10]``. @@ -738,7 +738,7 @@ Given a dictionary ``D``, the syntax ``D[x]`` returns the value of key ``x`` (if .. doctest:: julia> Dict([("A", 1), ("B", 2)]) - Dict{ASCIIString,Int64} with 2 entries: + Dict{String,Int64} with 2 entries: "B" => 2 "A" => 1 @@ -747,7 +747,7 @@ Given a dictionary ``D``, the syntax ``D[x]`` returns the value of key ``x`` (if .. doctest:: julia> Dict("A"=>1, "B"=>2) - Dict{ASCIIString,Int64} with 2 entries: + Dict{String,Int64} with 2 entries: "B" => 2 "A" => 1 @@ -838,23 +838,23 @@ Given a dictionary ``D``, the syntax ``D[x]`` returns the value of key ``x`` (if .. doctest:: julia> a = Dict("foo" => 0.0, "bar" => 42.0) - Dict{ASCIIString,Float64} with 2 entries: + Dict{String,Float64} with 2 entries: "bar" => 42.0 "foo" => 0.0 julia> b = Dict(utf8("baz") => 17, utf8("bar") => 4711) - Dict{UTF8String,Int64} with 2 entries: + Dict{String,Int64} with 2 entries: "bar" => 4711 "baz" => 17 julia> merge(a, b) - Dict{UTF8String,Float64} with 3 entries: + Dict{String,Float64} with 3 entries: "bar" => 4711.0 "baz" => 17.0 "foo" => 0.0 julia> merge(b, a) - Dict{UTF8String,Float64} with 3 entries: + Dict{String,Float64} with 3 entries: "bar" => 42.0 "baz" => 17.0 "foo" => 0.0 diff --git a/doc/stdlib/file.rst b/doc/stdlib/file.rst index 4b6f2cf9814a1..29a298728e3fc 100644 --- a/doc/stdlib/file.rst +++ b/doc/stdlib/file.rst @@ -22,7 +22,7 @@ Temporarily changes the current working directory and applies function ``f`` before returning. -.. function:: readdir([dir]) -> Vector{ByteString} +.. function:: readdir([dir]) -> Vector{String} .. Docstring generated from Julia source diff --git a/doc/stdlib/io-network.rst b/doc/stdlib/io-network.rst index b015c535c7374..1e7f5d857ea65 100644 --- a/doc/stdlib/io-network.rst +++ b/doc/stdlib/io-network.rst @@ -548,13 +548,13 @@ Text I/O Create an iterable object that will yield each line from an I/O stream or a file. The text is assumed to be encoded in UTF-8. -.. function:: readdlm(source, delim::Char, T::Type, eol::Char; header=false, skipstart=0, skipblanks=true, use_mmap, ignore_invalid_chars=false, quotes=true, dims, comments=true, comment_char='#') +.. function:: readdlm(source, delim::Char, T::Type, eol::Char; header=false, skipstart=0, skipblanks=true, use_mmap, quotes=true, dims, comments=true, comment_char='#') .. Docstring generated from Julia source Read a matrix from the source where each line (separated by ``eol``\ ) gives one row, with elements separated by the given delimiter. The source can be a text file, stream or byte array. Memory mapped files can be used by passing the byte array representation of the mapped segment as source. - If ``T`` is a numeric type, the result is an array of that type, with any non-numeric elements as ``NaN`` for floating-point types, or zero. Other useful values of ``T`` include ``ASCIIString``\ , ``AbstractString``\ , and ``Any``\ . + If ``T`` is a numeric type, the result is an array of that type, with any non-numeric elements as ``NaN`` for floating-point types, or zero. Other useful values of ``T`` include ``String``\ , ``AbstractString``\ , and ``Any``\ . If ``header`` is ``true``\ , the first row of data will be read as header and the tuple ``(data_cells, header_cells)`` is returned instead of only ``data_cells``\ . diff --git a/doc/stdlib/numbers.rst b/doc/stdlib/numbers.rst index 7bbbbe81fd347..e5dd2804b5749 100644 --- a/doc/stdlib/numbers.rst +++ b/doc/stdlib/numbers.rst @@ -140,7 +140,7 @@ Data Formats Convert a hexadecimal string to the floating point number it represents. -.. function:: hex2bytes(s::ASCIIString) +.. function:: hex2bytes(s::AbstractString) .. Docstring generated from Julia source @@ -150,7 +150,7 @@ Data Formats .. Docstring generated from Julia source - Convert an array of bytes to its hexadecimal representation. All characters are in lower-case. Returns an ``ASCIIString``\ . + Convert an array of bytes to its hexadecimal representation. All characters are in lower-case. Returns a ``String``\ . General Number Functions and Constants -------------------------------------- diff --git a/doc/stdlib/pkg.rst b/doc/stdlib/pkg.rst index 6c9f36ab8b12c..96fe1a2aa29e1 100644 --- a/doc/stdlib/pkg.rst +++ b/doc/stdlib/pkg.rst @@ -69,7 +69,7 @@ Functions for package development (e.g. ``tag``, ``publish``, etc.) have been mo Set the protocol used to access GitHub-hosted packages. Defaults to 'https', with a blank ``proto`` delegating the choice to the package developer. -.. function:: available() -> Vector{ASCIIString} +.. function:: available() -> Vector{String} .. Docstring generated from Julia source @@ -81,7 +81,7 @@ Functions for package development (e.g. ``tag``, ``publish``, etc.) have been mo Returns the version numbers available for package ``pkg``\ . -.. function:: installed() -> Dict{ASCIIString,VersionNumber} +.. function:: installed() -> Dict{String,VersionNumber} .. Docstring generated from Julia source diff --git a/doc/tabcomplete.jl b/doc/tabcomplete.jl index 2149f3b0bab44..16a7cf8930557 100644 --- a/doc/tabcomplete.jl +++ b/doc/tabcomplete.jl @@ -11,7 +11,7 @@ include("../base/emoji_symbols.jl") # Sometimes there is more than one way vals = Dict() for symbols in [latex_symbols, emoji_symbols], (k, v) in symbols - vals[v] = push!(get!(vals, v, ASCIIString[]), "\\"*k) + vals[v] = push!(get!(vals, v, String[]), "\\"*k) end # Join with Unicode names to aid in lookup diff --git a/examples/lru_test.jl b/examples/lru_test.jl index efce259074f10..cadf5212d3d67 100644 --- a/examples/lru_test.jl +++ b/examples/lru_test.jl @@ -2,8 +2,8 @@ using LRUExample -TestLRU = LRUExample.UnboundedLRU{ASCIIString, ASCIIString}() -TestBLRU = LRUExample.BoundedLRU{ASCIIString, ASCIIString}(1000) +TestLRU = LRUExample.UnboundedLRU{String, String}() +TestBLRU = LRUExample.BoundedLRU{String, String}(1000) get_str(i) = ascii(vcat(map(x->[x>>4; x&0x0F], reinterpret(UInt8, [Int32(i)]))...)) diff --git a/src/alloc.c b/src/alloc.c index b514aab695f71..72e7d7956be31 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -29,8 +29,7 @@ jl_value_t *jl_array_uint8_type; jl_value_t *jl_array_any_type=NULL; jl_value_t *jl_array_symbol_type; jl_datatype_t *jl_weakref_type; -jl_datatype_t *jl_ascii_string_type; -jl_datatype_t *jl_utf8_string_type; +jl_datatype_t *jl_string_type; jl_datatype_t *jl_expr_type; jl_datatype_t *jl_globalref_type; jl_datatype_t *jl_linenumbernode_type; diff --git a/src/array.c b/src/array.c index 99a1924ce1528..2e81e21e8308b 100644 --- a/src/array.c +++ b/src/array.c @@ -362,10 +362,8 @@ JL_DLLEXPORT jl_value_t *jl_array_to_string(jl_array_t *a) { if (!jl_typeis(a, jl_array_uint8_type)) jl_type_error("jl_array_to_string", (jl_value_t*)jl_array_uint8_type, (jl_value_t*)a); - jl_datatype_t *string_type = u8_isvalid((char*)a->data, jl_array_len(a)) == 1 ? // ASCII - jl_ascii_string_type : jl_utf8_string_type; jl_value_t *s = (jl_value_t*)jl_gc_alloc_1w(); - jl_set_typeof(s, string_type); + jl_set_typeof(s, jl_string_type); jl_set_nth_field(s, 0, (jl_value_t*)a); return s; } diff --git a/src/builtins.c b/src/builtins.c index 85f3f38310aa9..19937b2c7a812 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -1314,7 +1314,7 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt else if ((jl_value_t*)vt == jl_typeof(jl_nothing)) { n += jl_printf(out, "nothing"); } - else if (vt == jl_ascii_string_type || vt == jl_utf8_string_type) { + else if (vt == jl_string_type) { n += jl_printf(out, "\"%s\"", jl_iostr_data(v)); } else if (vt == jl_uniontype_type) { diff --git a/src/init.c b/src/init.c index 7730e84f37e5a..bf17c1a7c1a5c 100644 --- a/src/init.c +++ b/src/init.c @@ -830,8 +830,7 @@ void jl_get_builtin_hooks(void) jl_segv_exception = jl_new_struct_uninit((jl_datatype_t*)core("SegmentationFault")); #endif - jl_ascii_string_type = (jl_datatype_t*)core("ASCIIString"); - jl_utf8_string_type = (jl_datatype_t*)core("UTF8String"); + jl_string_type = (jl_datatype_t*)core("String"); jl_weakref_type = (jl_datatype_t*)core("WeakRef"); jl_vecelement_typename = ((jl_datatype_t*)core("VecElement"))->name; } diff --git a/src/jlapi.c b/src/jlapi.c index f6e60f191671c..06d0ec8b4c215 100644 --- a/src/jlapi.c +++ b/src/jlapi.c @@ -283,7 +283,7 @@ JL_DLLEXPORT const char *jl_ver_string(void) return JULIA_VERSION_STRING; } -// return char* from ByteString field in Base.GIT_VERSION_INFO +// return char* from String field in Base.GIT_VERSION_INFO static const char *git_info_string(const char *fld) { static jl_value_t *GIT_VERSION_INFO = NULL; diff --git a/src/julia.h b/src/julia.h index 24477e370c8d7..02dd3d72e66f9 100644 --- a/src/julia.h +++ b/src/julia.h @@ -470,8 +470,7 @@ extern JL_DLLEXPORT jl_datatype_t *jl_densearray_type; extern JL_DLLEXPORT jl_datatype_t *jl_array_type; extern JL_DLLEXPORT jl_typename_t *jl_array_typename; extern JL_DLLEXPORT jl_datatype_t *jl_weakref_type; -extern JL_DLLEXPORT jl_datatype_t *jl_ascii_string_type; -extern JL_DLLEXPORT jl_datatype_t *jl_utf8_string_type; +extern JL_DLLEXPORT jl_datatype_t *jl_string_type; extern JL_DLLEXPORT jl_datatype_t *jl_errorexception_type; extern JL_DLLEXPORT jl_datatype_t *jl_argumenterror_type; extern JL_DLLEXPORT jl_datatype_t *jl_loaderror_type; @@ -864,9 +863,8 @@ static inline uint32_t jl_fielddesc_size(int8_t fielddesc_type) #define jl_is_module(v) jl_typeis(v,jl_module_type) #define jl_is_mtable(v) jl_typeis(v,jl_methtable_type) #define jl_is_task(v) jl_typeis(v,jl_task_type) -#define jl_is_ascii_string(v) jl_typeis(v,jl_ascii_string_type) -#define jl_is_utf8_string(v) jl_typeis(v,jl_utf8_string_type) -#define jl_is_byte_string(v) (jl_is_ascii_string(v) || jl_is_utf8_string(v)) +#define jl_is_utf8_string(v) jl_typeis(v,jl_string_type) +#define jl_is_byte_string(v) jl_is_utf8_string(v) #define jl_is_cpointer(v) jl_is_cpointer_type(jl_typeof(v)) #define jl_is_pointer(v) jl_is_cpointer_type(jl_typeof(v)) diff --git a/src/sys.c b/src/sys.c index 25e458bbea7d6..c8de1c20407d0 100644 --- a/src/sys.c +++ b/src/sys.c @@ -697,7 +697,7 @@ static BOOL CALLBACK jl_EnumerateLoadedModulesProc64( ) { jl_array_grow_end((jl_array_t*)a, 1); - //XXX: change to jl_arrayset if array storage allocation for Array{ByteString,1} changes: + //XXX: change to jl_arrayset if array storage allocation for Array{String,1} changes: jl_value_t *v = jl_cstr_to_string(ModuleName); jl_cellset(a, jl_array_dim0(a)-1, v); return TRUE; diff --git a/src/toplevel.c b/src/toplevel.c index 2016d681aa423..6161465128eb9 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -573,7 +573,7 @@ JL_DLLEXPORT jl_value_t *jl_load(const char *fname, size_t len) return jl_parse_eval_all(fpath, len, NULL, 0); } -// load from filename given as a ByteString object +// load from filename given as a String object JL_DLLEXPORT jl_value_t *jl_load_(jl_value_t *str) { return jl_load(jl_string_data(str), jl_string_len(str)); diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index c70639dea4077..c5b8dcee08474 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -214,10 +214,10 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes` write(testfile, """ println(ARGS) """) - @test readchomp(`$exename $testfile foo -bar --baz`) == "UTF8String[\"foo\",\"-bar\",\"--baz\"]" - @test readchomp(`$exename $testfile -- foo -bar --baz`) == "UTF8String[\"foo\",\"-bar\",\"--baz\"]" - @test readchomp(`$exename -L $testfile -e 'exit(0)' -- foo -bar --baz`) == "UTF8String[\"foo\",\"-bar\",\"--baz\"]" - @test split(readchomp(`$exename -L $testfile $testfile`), '\n') == ["UTF8String[\"$(escape(testfile))\"]", "UTF8String[]"] + @test readchomp(`$exename $testfile foo -bar --baz`) == "String[\"foo\",\"-bar\",\"--baz\"]" + @test readchomp(`$exename $testfile -- foo -bar --baz`) == "String[\"foo\",\"-bar\",\"--baz\"]" + @test readchomp(`$exename -L $testfile -e 'exit(0)' -- foo -bar --baz`) == "String[\"foo\",\"-bar\",\"--baz\"]" + @test split(readchomp(`$exename -L $testfile $testfile`), '\n') == ["String[\"$(escape(testfile))\"]", "String[]"] @test !success(`$exename --foo $testfile`) @test !success(`$exename -L $testfile -e 'exit(0)' -- foo -bar -- baz`) finally @@ -249,7 +249,7 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes` end # issue #10562 - @test readchomp(`$exename -e 'println(ARGS);' ''`) == "UTF8String[\"\"]" + @test readchomp(`$exename -e 'println(ARGS);' ''`) == "String[\"\"]" # issue #12679 extrapath = @windows? joinpath(JULIA_HOME,"..","Git","usr","bin")*";" : "" diff --git a/test/core.jl b/test/core.jl index 6938208a591df..4a1fb33e10f7e 100644 --- a/test/core.jl +++ b/test/core.jl @@ -208,8 +208,8 @@ h11840{T<:Tuple}(::Type{T}) = '4' @test typejoin(Array{Float64},BitArray) <: AbstractArray @test typejoin(Array{Bool},BitArray) <: AbstractArray{Bool} @test typejoin(Tuple{Int,Int8},Tuple{Int8,Float64}) === Tuple{Signed,Real} -@test Base.typeseq(typejoin(Tuple{ASCIIString,ASCIIString},Tuple{UTF8String,ASCIIString}, - Tuple{ASCIIString,UTF8String},Tuple{Int,ASCIIString,Int}), +@test Base.typeseq(typejoin(Tuple{String,String},Tuple{DirectIndexString,String}, + Tuple{String,DirectIndexString},Tuple{Int,String,Int}), Tuple{Any,AbstractString,Vararg{Int}}) @test Base.typeseq(typejoin(Tuple{Int8,Vararg{Int}},Tuple{Int8,Int8}), Tuple{Int8,Vararg{Signed}}) @@ -583,10 +583,10 @@ end let local mytype function mytype(vec) - convert(Vector{Tuple{ASCIIString, DataType}}, vec) + convert(Vector{Tuple{String, DataType}}, vec) end some_data = Any[("a", Int32), ("b", Int32)] - @test isa(mytype(some_data),Vector{Tuple{ASCIIString, DataType}}) + @test isa(mytype(some_data),Vector{Tuple{String, DataType}}) end type MyArray{N} <: AbstractArray{Int, N} @@ -1349,7 +1349,7 @@ end # issue #4518 f4518(x, y::Union{Int32,Int64}) = 0 -f4518(x::ByteString, y::Union{Int32,Int64}) = 1 +f4518(x::String, y::Union{Int32,Int64}) = 1 @test f4518("",1) == 1 # issue #4581 diff --git a/test/dict.jl b/test/dict.jl index e4b1dfaafede7..cba050ec8bde1 100644 --- a/test/dict.jl +++ b/test/dict.jl @@ -149,7 +149,7 @@ end # issue #1821 let - d = Dict{UTF8String, Vector{Int}}() + d = Dict{String, Vector{Int}}() d["a"] = [1, 2] @test_throws MethodError d["b"] = 1 @test isa(repr(d), AbstractString) # check that printable without error @@ -342,7 +342,7 @@ end let a = Dict("foo" => 0.0, "bar" => 42.0) b = Dict("フー" => 17, "バー" => 4711) - @test is(typeof(merge(a, b)), Dict{UTF8String,Float64}) + @test is(typeof(merge(a, b)), Dict{String,Float64}) end # issue 9295 @@ -396,16 +396,16 @@ d = Dict('a'=>1, 'b'=>1, 'c'=> 3) # ImmutableDict import Base.ImmutableDict -let d = ImmutableDict{UTF8String, UTF8String}(), - k1 = UTF8String("key1"), - k2 = UTF8String("key2"), - v1 = UTF8String("value1"), - v2 = UTF8String("value2"), +let d = ImmutableDict{String, String}(), + k1 = "key1", + k2 = "key2", + v1 = "value1", + v2 = "value2", d1 = ImmutableDict(d, k1 => v1), d2 = ImmutableDict(d1, k2 => v2), d3 = ImmutableDict(d2, k1 => v2), d4 = ImmutableDict(d3, k2 => v1), - dnan = ImmutableDict{UTF8String, Float64}(k2, NaN), + dnan = ImmutableDict{String, Float64}(k2, NaN), dnum = ImmutableDict(dnan, k2 => 1) @test isempty(collect(d)) @@ -471,7 +471,7 @@ end # issue #15077 immutable MyString <: AbstractString - str::ASCIIString + str::String end import Base.== @@ -483,19 +483,21 @@ Base.next(s::MyString, v::Int) = next(s.str, v) Base.isequal(a::MyString, b::MyString) = isequal(a.str, b.str) ==(a::MyString, b::MyString) = (a.str == b.str) -let badKeys = ASCIIString["FINO_emv5.0","FINO_ema0.1","RATE_ema1.0","NIBPM_ema1.0", - "SAO2_emv5.0","O2FLOW_ema5.0","preop_Neuro/Psych_","gender_", - "FIO2_ema0.1","PEAK_ema5.0","preop_Reproductive_denies","O2FLOW_ema0.1", - "preop_Endocrine_denies","preop_Respiratory_", - "NIBPM_ema0.1","PROPOFOL_MCG/KG/MIN_decay5.0","NIBPD_ema1.0","NIBPS_ema5.0", - "anesthesiaStartTime","NIBPS_ema1.0","RESPRATE_ema1.0","PEAK_ema0.1", - "preop_GU_denies","preop_Cardiovascular_","PIP_ema5.0","preop_ENT_denies", - "preop_Skin_denies","preop_Renal_denies","asaCode_IIIE","N2OFLOW_emv5.0", - "NIBPD_emv5.0", # <--- here is the key that we later can't find - "NIBPM_ema5.0","preop_Respiratory_complete","ETCO2_ema5.0", - "RESPRATE_ema0.1","preop_Functional Status_<2","preop_Renal_symptoms", - "ECGRATE_ema5.0","FIO2_emv5.0","RESPRATE_emv5.0","7wu3ty0a4fs","BVO", - "4UrCWXUsaT"] +let badKeys = [ + "FINO_emv5.0","FINO_ema0.1","RATE_ema1.0","NIBPM_ema1.0", + "SAO2_emv5.0","O2FLOW_ema5.0","preop_Neuro/Psych_","gender_", + "FIO2_ema0.1","PEAK_ema5.0","preop_Reproductive_denies","O2FLOW_ema0.1", + "preop_Endocrine_denies","preop_Respiratory_", + "NIBPM_ema0.1","PROPOFOL_MCG/KG/MIN_decay5.0","NIBPD_ema1.0","NIBPS_ema5.0", + "anesthesiaStartTime","NIBPS_ema1.0","RESPRATE_ema1.0","PEAK_ema0.1", + "preop_GU_denies","preop_Cardiovascular_","PIP_ema5.0","preop_ENT_denies", + "preop_Skin_denies","preop_Renal_denies","asaCode_IIIE","N2OFLOW_emv5.0", + "NIBPD_emv5.0", # <--- here is the key that we later can't find + "NIBPM_ema5.0","preop_Respiratory_complete","ETCO2_ema5.0", + "RESPRATE_ema0.1","preop_Functional Status_<2","preop_Renal_symptoms", + "ECGRATE_ema5.0","FIO2_emv5.0","RESPRATE_emv5.0","7wu3ty0a4fs","BVO", + "4UrCWXUsaT" +] d = Dict{AbstractString,Int}() for i = 1:length(badKeys) d[badKeys[i]] = i diff --git a/test/docs.jl b/test/docs.jl index 67ceec689ac32..6208797ebada6 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -656,7 +656,7 @@ type C <: A end immutable D <: B one - two::UTF8String + two::String three::Float64 end @@ -723,7 +723,7 @@ immutable Undocumented.D <: Undocumented.B **Fields:** ``` one :: Any -two :: UTF8String +two :: String three :: Float64 ``` """) diff --git a/test/operators.jl b/test/operators.jl index 1b562f4004598..36f80a6033ddf 100644 --- a/test/operators.jl +++ b/test/operators.jl @@ -20,7 +20,7 @@ B = [true true false] @test reverse(Pair(1,2)) == Pair(2,1) @test reverse(Pair("13","24")) == Pair("24","13") -@test typeof(reverse(Pair{ByteString,Int64}("a",1))) == Pair{Int64,ByteString} +@test typeof(reverse(Pair{String,Int64}("a",1))) == Pair{Int64,String} p = 1=>:foo @test first(p) == 1 diff --git a/test/path.jl b/test/path.jl index bf97d3f26781d..c9db47528c8f1 100644 --- a/test/path.jl +++ b/test/path.jl @@ -89,5 +89,5 @@ end test_relpath() # Test type stability -@test isa(joinpath("a", "b"), ASCIIString) -@test isa(joinpath(abspath("a"), "b"), ASCIIString) +@test isa(joinpath("a", "b"), String) +@test isa(joinpath(abspath("a"), "b"), String) diff --git a/test/perf/kernel/actor_centrality.jl b/test/perf/kernel/actor_centrality.jl index acfc336d1f1f3..483ef80f4170b 100644 --- a/test/perf/kernel/actor_centrality.jl +++ b/test/perf/kernel/actor_centrality.jl @@ -1,13 +1,13 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license type Node - name::UTF8String + name::String n::Set{Node} Node(name) = new(name, Set{Node}()) end -typealias Graph Dict{UTF8String, Node} +typealias Graph Dict{String, Node} function get(G::Graph, name) if haskey(G, name) @@ -56,7 +56,7 @@ end function actor_centrality() G, actors = read_graph() - d = Dict{UTF8String, Float64}() + d = Dict{String, Float64}() for a in actors[1:50] d[a] = centrality_mean(G, a) diff --git a/test/read.jl b/test/read.jl index cabda7b3f5d04..bf39dc23265c3 100644 --- a/test/read.jl +++ b/test/read.jl @@ -178,10 +178,10 @@ for (name, f) in l for text in [ old_text, - UTF8String(Char['A' + i % 52 for i in 1:(div(Base.SZ_UNBUFFERED_IO,2))]), - UTF8String(Char['A' + i % 52 for i in 1:( Base.SZ_UNBUFFERED_IO -1)]), - UTF8String(Char['A' + i % 52 for i in 1:( Base.SZ_UNBUFFERED_IO )]), - UTF8String(Char['A' + i % 52 for i in 1:( Base.SZ_UNBUFFERED_IO +1)]) + String(Char['A' + i % 52 for i in 1:(div(Base.SZ_UNBUFFERED_IO,2))]), + String(Char['A' + i % 52 for i in 1:( Base.SZ_UNBUFFERED_IO -1)]), + String(Char['A' + i % 52 for i in 1:( Base.SZ_UNBUFFERED_IO )]), + String(Char['A' + i % 52 for i in 1:( Base.SZ_UNBUFFERED_IO +1)]) ] write(filename, text) diff --git a/test/regex.jl b/test/regex.jl index e3a90abb1c591..be153a142cd82 100644 --- a/test/regex.jl +++ b/test/regex.jl @@ -34,7 +34,7 @@ show(buf, r"") # see #10994, #11447: PCRE2 allows NUL chars in the pattern @test ismatch(Regex("^a\0b\$"), "a\0b") -# regex match / search string must be a ByteString +# regex match / search string must be a String @test_throws ArgumentError match(r"test", utf32("this is a test")) @test_throws ArgumentError search(utf32("this is a test"), r"test") diff --git a/test/remote.jl b/test/remote.jl index b359b611c2663..e87ec4940c7de 100644 --- a/test/remote.jl +++ b/test/remote.jl @@ -2,8 +2,8 @@ # Check that serializer hasn't gone out-of-frame @test Serializer.sertag(Symbol) == 2 -@test Serializer.sertag(()) == 47 -@test Serializer.sertag(false) == 123 +@test Serializer.sertag(()) == 46 +@test Serializer.sertag(false) == 122 # issue #1770 let diff --git a/test/repl.jl b/test/repl.jl index 06834cfe0d753..6f7724cdea50c 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -348,7 +348,7 @@ begin LineEdit.accept_result(s, histp) @test LineEdit.mode(s) == repl_mode @test buffercontents(LineEdit.buffer(s)) == "shell" - @test position(LineEdit.buffer(s)) == 4 + @test position(LineEdit.buffer(s)) == 2 # Test that searching backwards doesn't skip matches (#9352) # (for a search with multiple one-byte characters, or UTF-8 characters) diff --git a/test/replcompletions.jl b/test/replcompletions.jl index ac5e5cf4c6ed9..f446004fdccbd 100644 --- a/test/replcompletions.jl +++ b/test/replcompletions.jl @@ -252,11 +252,11 @@ c, r, res = test_complete(s) s = "prevind(\"θ\",1," c, r, res = test_complete(s) -@test c[1] == string(first(methods(prevind, Tuple{UTF8String, Int}))) +@test c[1] == string(first(methods(prevind, Tuple{String, Int}))) @test r == 1:7 @test s[r] == "prevind" -for (T, arg) in [(ASCIIString,"\")\""),(Char, "')'")] +for (T, arg) in [(String,"\")\""),(Char, "')'")] s = "(1, CompletionFoo.test2($arg," c, r, res = test_complete(s) @test length(c) == 1 @@ -287,7 +287,7 @@ c, r, res = test_complete(s) s = "CompletionFoo.test4(\"e\",r\" \"," c, r, res = test_complete(s) @test !res -@test c[1] == string(first(methods(CompletionFoo.test4, Tuple{ASCIIString, Regex}))) +@test c[1] == string(first(methods(CompletionFoo.test4, Tuple{String, Regex}))) @test r == 1:19 @test length(c) == 1 @test s[r] == "CompletionFoo.test4" @@ -302,7 +302,7 @@ s = "CompletionFoo.test4(CompletionFoo.test_y_array[1]()[1], CompletionFoo.test_ c, r, res = test_complete(s) @test !res @test length(c) == 1 -@test c[1] == string(first(methods(CompletionFoo.test4, Tuple{ASCIIString, ASCIIString}))) +@test c[1] == string(first(methods(CompletionFoo.test4, Tuple{String, String}))) # Test that string escaption is handled correct s = """CompletionFoo.test4("\\"",""" @@ -436,7 +436,7 @@ c, r, res = test_scomplete(s) # The return type is of importance, before #8995 it would return nothing # which would raise an error in the repl code. -@test (UTF8String[], 0:-1, false) == test_scomplete("\$a") +@test (String[], 0:-1, false) == test_scomplete("\$a") @unix_only begin #Assume that we can rely on the existence and accessibility of /tmp diff --git a/test/replutil.jl b/test/replutil.jl index fd4ca10c06d7f..652081723e89e 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -183,11 +183,11 @@ let undefvar err_str = @except_str 0::7 TypeError @test err_str == "TypeError: typeassert: expected Type{T}, got $Int" err_str = @except_str "" <: AbstractString TypeError - @test err_str == "TypeError: subtype: expected Type{T}, got ASCIIString" + @test err_str == "TypeError: subtype: expected Type{T}, got String" err_str = @except_str AbstractString <: "" TypeError - @test err_str == "TypeError: subtype: expected Type{T}, got ASCIIString" + @test err_str == "TypeError: subtype: expected Type{T}, got String" err_str = @except_str Type{""} TypeError - @test err_str == "TypeError: Type: in parameter, expected Type{T}, got ASCIIString" + @test err_str == "TypeError: Type: in parameter, expected Type{T}, got String" err_str = @except_str TypeWithIntParam{Any} TypeError @test err_str == "TypeError: TypeWithIntParam: in T, expected T<:Integer, got Type{Any}" diff --git a/test/resolve.jl b/test/resolve.jl index ffc9aad485fe8..04ef78a335b09 100644 --- a/test/resolve.jl +++ b/test/resolve.jl @@ -59,14 +59,14 @@ end # auxiliary functions function deps_from_data(deps_data) - deps = Dict{ByteString,Dict{VersionNumber,Available}}() + deps = Dict{String,Dict{VersionNumber,Available}}() for d in deps_data p = d[1]; vn = d[2]; r = d[3:end] if !haskey(deps, p) deps[p] = Dict{VersionNumber,Available}() end if !haskey(deps[p], vn) - deps[p][vn] = Available("$(p)_$(vn)_sha1", Dict{ByteString,VersionSet}()) + deps[p][vn] = Available("$(p)_$(vn)_sha1", Dict{String,VersionSet}()) end isempty(r) && continue rp = r[1] @@ -80,7 +80,7 @@ function deps_from_data(deps_data) deps end function reqs_from_data(reqs_data) - reqs = Dict{ByteString,VersionSet}() + reqs = Dict{String,VersionSet}() for r in reqs_data p = r[1] reqs[p] = VersionSet(VersionNumber[r[2:end]...]) @@ -91,7 +91,7 @@ function sanity_tst(deps_data, expected_result; pkgs=[]) deps = deps_from_data(deps_data) #println("deps=$deps") #println() - result = sanity_check(deps, Set(ByteString[pkgs...])) + result = sanity_check(deps, Set(String[pkgs...])) length(result) == length(expected_result) || return false for (p, vn, pp) in result in((p, vn), expected_result) || return false diff --git a/test/sets.jl b/test/sets.jl index a3a622e23f9f7..bebced5b518b3 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -13,9 +13,9 @@ data_out = collect(s) @test length(data_out) == length(data_in) # hash -s1 = Set{ASCIIString}(["bar", "foo"]) -s2 = Set{ASCIIString}(["foo", "bar"]) -s3 = Set{ASCIIString}(["baz"]) +s1 = Set(["bar", "foo"]) +s2 = Set(["foo", "bar"]) +s3 = Set(["baz"]) @test hash(s1) == hash(s2) @test hash(s1) != hash(s3) diff --git a/test/show.jl b/test/show.jl index 9c79bc031a8ad..dacb25bb03e9c 100644 --- a/test/show.jl +++ b/test/show.jl @@ -7,9 +7,9 @@ replstr(x) = sprint((io,x) -> writemime(io,MIME("text/plain"),x), x) @test replstr(cell(2,2,2)) == "2×2×2 Array{Any,3}:\n[:, :, 1] =\n #undef #undef\n #undef #undef\n\n[:, :, 2] =\n #undef #undef\n #undef #undef" immutable T5589 - names::Vector{UTF8String} + names::Vector{String} end -@test replstr(T5589(Array(UTF8String,100))) == "T5589(UTF8String[#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef … #undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef])" +@test replstr(T5589(Array(String,100))) == "T5589(String[#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef … #undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef,#undef])" @test replstr(parse("type X end")) == ":(type X\n end)" @test replstr(parse("immutable X end")) == ":(immutable X\n end)" diff --git a/test/socket.jl b/test/socket.jl index 550fc65b73d5f..fe7341ec7c57e 100644 --- a/test/socket.jl +++ b/test/socket.jl @@ -92,19 +92,17 @@ wait(tsk) mktempdir() do tmpdir socketname = @windows ? ("\\\\.\\pipe\\uv-test-" * randstring(6)) : joinpath(tmpdir, "socket") c = Base.Condition() - for T in (ASCIIString, UTF8String, UTF16String) # test for issue #9435 - tsk = @async begin - s = listen(T(socketname)) - Base.notify(c) - sock = accept(s) - write(sock,"Hello World\n") - close(s) - close(sock) - end - wait(c) - @test readstring(connect(socketname)) == "Hello World\n" - wait(tsk) + tsk = @async begin + s = listen(socketname) + Base.notify(c) + sock = accept(s) + write(sock,"Hello World\n") + close(s) + close(sock) end + wait(c) + @test readstring(connect(socketname)) == "Hello World\n" + wait(tsk) end @test_throws Base.UVError getaddrinfo(".invalid") diff --git a/test/string.jl b/test/string.jl index 1bff360c9c6ac..892f3e3042d89 100644 --- a/test/string.jl +++ b/test/string.jl @@ -2,10 +2,17 @@ ## generic string uses only endof and next; used for testing ## +immutable CharString <: DirectIndexString + chars::Vector{Char} +end +Base.convert(::Type{CharString}, s::AbstractString) = CharString(collect(s)) +Base.endof(s::CharString) = length(s.chars) +Base.next(s::CharString, i::Int) = next(s.chars, i) + immutable GenericString <: AbstractString string::AbstractString end - +Base.convert(::Type{GenericString}, s::AbstractString) = GenericString(s) Base.endof(s::GenericString) = endof(s.string) Base.next(s::GenericString, i::Int) = next(s.string, i) diff --git a/test/strings/basic.jl b/test/strings/basic.jl index 0683fa48ef049..efda879c33527 100644 --- a/test/strings/basic.jl +++ b/test/strings/basic.jl @@ -87,14 +87,13 @@ end @test checkbounds("hello", [1:5;]) # issue #15624 (indexing with out of bounds empty range) +@test ""[10:9] == "" @test "hello"[10:9] == "" @test "hellø"[10:9] == "" @test SubString("hello", 1, 6)[10:9] == "" @test SubString("hello", 1, 0)[10:9] == "" @test SubString("hellø", 1, 6)[10:9] == "" @test SubString("hellø", 1, 0)[10:9] == "" -@test ASCIIString("")[10:9] == "" -@test UTF8String("")[10:9] == "" @test SubString("", 1, 6)[10:9] == "" @test SubString("", 1, 0)[10:9] == "" @@ -138,12 +137,6 @@ end @test [parse(Float32,x) for x in split("0,1\n",",")][2] == 1.0 @test_throws ArgumentError parse(Float32,split("0,1 X\n",",")[2]) -#more ascii tests -@test convert(ASCIIString, UInt8[32,107,75], "*") == " kK" -@test convert(ASCIIString, UInt8[132,107,75], "*") == "*kK" -@test convert(ASCIIString, UInt8[], "*") == "" -@test convert(ASCIIString, UInt8[255], "*") == "*" - @test ucfirst("Hola")=="Hola" @test ucfirst("hola")=="Hola" @test ucfirst("")=="" @@ -154,13 +147,13 @@ end @test lcfirst("")=="" @test lcfirst("*")=="*" -#more UTF8String tests -@test convert(UTF8String, UInt8[32,107,75], "*") == " kK" -@test convert(UTF8String, UInt8[132,107,75], "*") == "*kK" -@test convert(UTF8String, UInt8[32,107,75], "αβ") == " kK" -@test convert(UTF8String, UInt8[132,107,75], "αβ") == "αβkK" -@test convert(UTF8String, UInt8[], "*") == "" -@test convert(UTF8String, UInt8[255], "αβ") == "αβ" +#more String tests +@test convert(String, UInt8[32,107,75], "*") == " kK" +@test convert(String, UInt8[132,107,75], "*") == "*kK" +@test convert(String, UInt8[32,107,75], "αβ") == " kK" +@test convert(String, UInt8[132,107,75], "αβ") == "αβkK" +@test convert(String, UInt8[], "*") == "" +@test convert(String, UInt8[255], "αβ") == "αβ" # test AbstractString functions at beginning of string.jl immutable tstStringType <: AbstractString @@ -221,8 +214,8 @@ s = "abcdefghij" sp = pointer(s) @test ascii(sp) == s @test ascii(sp,5) == "abcde" -@test typeof(ascii(sp)) == ASCIIString -@test typeof(utf8(sp)) == UTF8String +@test typeof(ascii(sp)) == String +@test typeof(utf8(sp)) == String s = "abcde\uff\u2000\U1f596" sp = pointer(s) @test utf8(sp) == s @@ -230,7 +223,7 @@ sp = pointer(s) @test_throws ArgumentError ascii(sp) @test ascii(sp, 5) == "abcde" @test_throws ArgumentError ascii(sp, 6) -@test typeof(utf8(sp)) == UTF8String +@test typeof(utf8(sp)) == String @test get(tryparse(BigInt, "1234567890")) == BigInt(1234567890) @test isnull(tryparse(BigInt, "1234567890-")) @@ -289,11 +282,6 @@ c[1] = 'A' @test isvalid(utf32("\x00")) == true @test isvalid(UTF32String, UInt32[0xd800,0]) == false -# Issue #11241 - -@test isvalid(ASCIIString, "is_valid_ascii") == true -@test isvalid(ASCIIString, "Σ_not_valid_ascii") == false - # test all edge conditions for (val, pass) in ( (0, true), (0xd7ff, true), @@ -330,7 +318,7 @@ for (val, pass) in ( (b"\udc00\u0100", false), (b"\udc00\ud800", false) ) - @test isvalid(UTF8String, val) == pass + @test isvalid(String, val) == pass end for (val, pass) in ( (UInt16[0x0000], true), @@ -362,8 +350,7 @@ for (val, pass) in ( end # Issue #11203 -@test isvalid(ASCIIString,UInt8[]) == true -@test isvalid(UTF8String, UInt8[]) == true +@test isvalid(String, UInt8[]) == true @test isvalid(UTF16String,UInt16[]) == true @test isvalid(UTF32String,UInt32[]) == true @@ -372,18 +359,18 @@ end # then single continuation bytes and lead bytes with no following continuation bytes (false) for (rng,flg) in ((0:0x7f, true), (0x80:0xff, false)) for byt in rng - @test isvalid(UTF8String, UInt8[byt]) == flg + @test isvalid(String, UInt8[byt]) == flg end end # Check overlong lead bytes for 2-character sequences (false) for byt = 0xc0:0xc1 - @test isvalid(UTF8String, UInt8[byt,0x80]) == false + @test isvalid(String, UInt8[byt,0x80]) == false end # Check valid lead-in to two-byte sequences (true) for byt = 0xc2:0xdf for (rng,flg) in ((0x00:0x7f, false), (0x80:0xbf, true), (0xc0:0xff, false)) for cont in rng - @test isvalid(UTF8String, UInt8[byt, cont]) == flg + @test isvalid(String, UInt8[byt, cont]) == flg end end end @@ -391,11 +378,11 @@ end for r1 in (0xe0:0xec, 0xee:0xef) for byt = r1 # Check for short sequence - @test isvalid(UTF8String, UInt8[byt]) == false + @test isvalid(String, UInt8[byt]) == false for (rng,flg) in ((0x00:0x7f, false), (0x80:0xbf, true), (0xc0:0xff, false)) for cont in rng - @test isvalid(UTF8String, UInt8[byt, cont]) == false - @test isvalid(UTF8String, UInt8[byt, cont, 0x80]) == flg + @test isvalid(String, UInt8[byt, cont]) == false + @test isvalid(String, UInt8[byt, cont, 0x80]) == flg end end end @@ -404,8 +391,8 @@ end # Check for short sequence, or start of surrogate pair for (rng,flg) in ((0x00:0x7f, false), (0x80:0x9f, true), (0xa0:0xff, false)) for cont in rng - @test isvalid(UTF8String, UInt8[0xed, cont]) == false - @test isvalid(UTF8String, UInt8[0xed, cont, 0x80]) == flg + @test isvalid(String, UInt8[0xed, cont]) == false + @test isvalid(String, UInt8[0xed, cont, 0x80]) == flg end end # Check valid four-byte sequences @@ -419,22 +406,22 @@ for byt = 0xf0:0xf4 end for (rng,flg) in r0 for cont in rng - @test isvalid(UTF8String, UInt8[byt, cont]) == false - @test isvalid(UTF8String, UInt8[byt, cont, 0x80]) == false - @test isvalid(UTF8String, UInt8[byt, cont, 0x80, 0x80]) == flg + @test isvalid(String, UInt8[byt, cont]) == false + @test isvalid(String, UInt8[byt, cont, 0x80]) == false + @test isvalid(String, UInt8[byt, cont, 0x80, 0x80]) == flg end end end # Check five-byte sequences, should be invalid for byt = 0xf8:0xfb - @test isvalid(UTF8String, UInt8[byt, 0x80, 0x80, 0x80, 0x80]) == false + @test isvalid(String, UInt8[byt, 0x80, 0x80, 0x80, 0x80]) == false end # Check six-byte sequences, should be invalid for byt = 0xfc:0xfd - @test isvalid(UTF8String, UInt8[byt, 0x80, 0x80, 0x80, 0x80, 0x80]) == false + @test isvalid(String, UInt8[byt, 0x80, 0x80, 0x80, 0x80, 0x80]) == false end # Check seven-byte sequences, should be invalid -@test isvalid(UTF8String, UInt8[0xfe, 0x80, 0x80, 0x80, 0x80, 0x80]) == false +@test isvalid(String, UInt8[0xfe, 0x80, 0x80, 0x80, 0x80, 0x80]) == false # 11482 @@ -448,8 +435,7 @@ let s = "abcdef", u8 = "abcdef\uff", u16 = utf16(u8), u32 = utf32(u8), @test isvalid(u8) @test isvalid(u16) @test isvalid(u32) - @test isvalid(ASCIIString, s) - @test isvalid(UTF8String, u8) + @test isvalid(String, u8) @test isvalid(UTF16String, u16) @test isvalid(UTF32String, u32) end @@ -476,14 +462,14 @@ end @test lcfirst(utf32("a")) == "a" @test ucfirst(utf32("A")) == "A" -# issue # 11464: uppercase/lowercase of UTF16String becomes a UTF8String +# issue # 11464: uppercase/lowercase of UTF16String becomes a String str = "abcdef\uff\uffff\u10ffffABCDEF" -@test typeof(uppercase("abcdef")) == ASCIIString -@test typeof(uppercase(utf8(str))) == UTF8String +@test typeof(uppercase("abcdef")) == String +@test typeof(uppercase(utf8(str))) == String @test typeof(uppercase(utf16(str))) == UTF16String @test typeof(uppercase(utf32(str))) == UTF32String -@test typeof(lowercase("ABCDEF")) == ASCIIString -@test typeof(lowercase(utf8(str))) == UTF8String +@test typeof(lowercase("ABCDEF")) == String +@test typeof(lowercase(utf8(str))) == String @test typeof(lowercase(utf16(str))) == UTF16String @test typeof(lowercase(utf32(str))) == UTF32String diff --git a/test/strings/io.jl b/test/strings/io.jl index 4b73b926bc267..eda49201b39a8 100644 --- a/test/strings/io.jl +++ b/test/strings/io.jl @@ -168,7 +168,7 @@ else close(f) f=open(joinpath(unicodedir,"UTF-8.unicode")) - str2 = UTF8String(read(f, UInt8, 4382595)[4:end]) + str2 = String(read(f, UInt8, 4382595)[4:end]) close(f) @test str1 == str2 diff --git a/test/strings/types.jl b/test/strings/types.jl index a904c87e321bc..5371924f86663 100644 --- a/test/strings/types.jl +++ b/test/strings/types.jl @@ -62,7 +62,7 @@ write(b, u) @test_throws BoundsError getindex(u, 0:1) @test_throws BoundsError getindex(u, 7:7) @test reverseind(u, 1) == 4 -@test typeof(Base.cconvert(Ptr{Int8},u)) == SubString{UTF8String} +@test typeof(Base.cconvert(Ptr{Int8},u)) == SubString{String} @test Base.cconvert(Ptr{Int8},u) == u str = "føøbar" @@ -131,7 +131,7 @@ let s="lorem ipsum", end end #let -#for isvalid(SubString{UTF8String}) +#for isvalid(SubString{String}) let s = utf8("Σx + βz - 2") for i in -1:length(s)+2 ss=SubString(s,1,i) @@ -145,7 +145,7 @@ ss=SubString("hello",1,5) @test_throws BoundsError chr2ind(ss, 10) @test_throws BoundsError ind2chr(ss, 10) -# length(SubString{UTF8String}) performance specialization +# length(SubString{String}) performance specialization let s = "|η(α)-ϕ(κ)| < ε" @test length(SubString(s,1,0))==length(s[1:0]) @test length(SubString(s,4,4))==length(s[4:4]) @@ -165,11 +165,10 @@ rs = RevString("foobar") @test parse(Float64,RevString("64")) === 46.0 # reverseind -for T in (ASCIIString, UTF8String, UTF16String, UTF32String) +for T in (String, UTF16String, UTF32String) for prefix in ("", "abcd", "\U0001d6a4\U0001d4c1", "\U0001d6a4\U0001d4c1c", " \U0001d6a4\U0001d4c1") for suffix in ("", "abcde", "\U0001d4c1β\U0001d6a4", "\U0001d4c1β\U0001d6a4c", " \U0001d4c1β\U0001d6a4") for c in ('X', 'δ', '\U0001d6a5') - T != ASCIIString || (isascii(prefix) && isascii(suffix) && isascii(c)) || continue s = convert(T, string(prefix, c, suffix)) ri = search(reverse(s), c) @test reverse(s) == RevString(s) diff --git a/test/strings/util.jl b/test/strings/util.jl index d3a4e92034bf6..d52189554f320 100644 --- a/test/strings/util.jl +++ b/test/strings/util.jl @@ -21,7 +21,7 @@ for s in ("", " ", " abc", "abc ", " abc "), f in (lstrip, rstrip, strip) fs = f(s) - for T = (ASCIIString, UTF8String, UTF16String, UTF32String) + for T = (String, UTF16String, UTF32String) t = convert(T,s) ft = f(t) @test s == t diff --git a/test/test_sourcepath.jl b/test/test_sourcepath.jl index ac19d8b70bd37..1e4f55b5b287c 100644 --- a/test/test_sourcepath.jl +++ b/test/test_sourcepath.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license # source path in tasks -path = Base.source_path()::ByteString # this variable is leaked to the source script +path = Base.source_path()::String # this variable is leaked to the source script @test endswith(path, joinpath("test","test_sourcepath.jl")) @test let ct = current_task() yieldto(@task yieldto(ct, Base.source_path())) diff --git a/test/unicode/utf32.jl b/test/unicode/utf32.jl index 53e7de500ed3e..54e3dff171604 100644 --- a/test/unicode/utf32.jl +++ b/test/unicode/utf32.jl @@ -13,7 +13,7 @@ u32 = utf32(u8) @test_throws UnicodeError utf32(UInt8[1,2,3]) # issue #11551 (#11004,#10959) -function tstcvt(strUTF8::UTF8String, strUTF16::UTF16String, strUTF32::UTF32String) +function tstcvt(strUTF8::String, strUTF16::UTF16String, strUTF32::UTF32String) @test utf16(strUTF8) == strUTF16 @test utf32(strUTF8) == strUTF32 @test utf8(strUTF16) == strUTF8 @@ -30,9 +30,9 @@ strL_UTF8 = "abcdef\uff\uff" str2_UTF8 = "abcd\uff\uff\u7ff\u7ff" str3_UTF8 = "abcd\uff\uff\u7fff\u7fff" str4_UTF8 = "abcd\uff\u7ff\u7fff\U7ffff" -strS_UTF8 = UTF8String(b"abcd\xc3\xbf\xdf\xbf\xe7\xbf\xbf\xed\xa0\x80\xed\xb0\x80") -strC_UTF8 = UTF8String(b"abcd\xc3\xbf\xdf\xbf\xe7\xbf\xbf\U10000") -strz_UTF8 = UTF8String(b"abcd\xc3\xbf\xdf\xbf\xe7\xbf\xbf\0") +strS_UTF8 = String(b"abcd\xc3\xbf\xdf\xbf\xe7\xbf\xbf\xed\xa0\x80\xed\xb0\x80") +strC_UTF8 = String(b"abcd\xc3\xbf\xdf\xbf\xe7\xbf\xbf\U10000") +strz_UTF8 = String(b"abcd\xc3\xbf\xdf\xbf\xe7\xbf\xbf\0") strZ = b"abcd\xc3\xbf\xdf\xbf\xe7\xbf\xbf\xc0\x80" strA_UTF16 = utf16(strA_UTF8) @@ -69,16 +69,16 @@ tstcvt(str4_UTF8,str4_UTF16,str4_UTF32) # Test converting overlong \0 @test utf8(strZ) == strz_UTF8 -@test utf16(UTF8String(strZ)) == strz_UTF8 -@test utf32(UTF8String(strZ)) == strz_UTF8 +@test utf16(String(strZ)) == strz_UTF8 +@test utf32(String(strZ)) == strz_UTF8 # Test invalid sequences -strval(::Type{UTF8String}, dat) = dat -strval(::Union{Type{UTF16String},Type{UTF32String}}, dat) = UTF8String(dat) +strval(::Type{String}, dat) = dat +strval(::Union{Type{UTF16String},Type{UTF32String}}, dat) = String(dat) byt = 0x0 -for T in (UTF8String, UTF16String, UTF32String) +for T in (String, UTF16String, UTF32String) try # Continuation byte not after lead for byt in 0x80:0xbf @@ -238,28 +238,21 @@ let str = ascii("this ") @test unsafe_load(p16,1) == 0x0068 @test typeof(p32) == Ptr{UInt32} @test unsafe_load(p32,1) == 'h' - sa = SubString{ASCIIString}(str, 3, 5) - s8 = SubString{UTF8String}(u8, 3, 5) + s8 = SubString{String}(u8, 3, 5) s16 = SubString{UTF16String}(u16, 3, 5) s32 = SubString{UTF32String}(u32, 3, 5) - pa = pointer(sa) p8 = pointer(s8) p16 = pointer(s16) p32 = pointer(s32) - @test typeof(pa) == Ptr{UInt8} - @test unsafe_load(pa,1) == 0x69 @test typeof(p8) == Ptr{UInt8} @test unsafe_load(p8,1) == 0x69 @test typeof(p16) == Ptr{UInt16} @test unsafe_load(p16,1) == 0x0069 @test typeof(p32) == Ptr{UInt32} @test unsafe_load(p32,1) == 'i' - pa = pointer(sa, 2) p8 = pointer(s8, 2) p16 = pointer(s16, 2) p32 = pointer(s32, 2) - @test typeof(pa) == Ptr{UInt8} - @test unsafe_load(pa,1) == 0x73 @test typeof(p8) == Ptr{UInt8} @test unsafe_load(p8,1) == 0x73 @test typeof(p16) == Ptr{UInt16} diff --git a/test/unicode/utf8.jl b/test/unicode/utf8.jl index 591cb961e404e..073f5f2b4d29c 100644 --- a/test/unicode/utf8.jl +++ b/test/unicode/utf8.jl @@ -5,35 +5,31 @@ let ch = 0x10000 for hichar = 0xd800:0xdbff for lochar = 0xdc00:0xdfff - @test convert(UTF8String, utf8(Char[hichar, lochar]).data) == string(Char(ch)) + @test convert(String, utf8(Char[hichar, lochar]).data) == string(Char(ch)) ch += 1 end end end -let str = UTF8String(b"this is a test\xed\x80") +let str = String(b"this is a test\xed\x80") @test next(str, 15) == ('\ufffd', 16) @test_throws BoundsError getindex(str, 0:3) @test_throws BoundsError getindex(str, 17:18) @test_throws BoundsError getindex(str, 2:17) @test_throws UnicodeError getindex(str, 16:17) @test string(Char(0x110000)) == "\ufffd" - sa = SubString{ASCIIString}(ascii("This is a silly test"), 1, 14) - s8 = convert(SubString{UTF8String}, sa) - @test typeof(s8) == SubString{UTF8String} - @test s8 == "This is a sill" - @test convert(UTF8String, b"this is a test\xed\x80\x80") == "this is a test\ud000" + @test convert(String, b"this is a test\xed\x80\x80") == "this is a test\ud000" end -## Reverse of UTF8String -@test reverse(UTF8String("")) == "" -@test reverse(UTF8String("a")) == "a" -@test reverse(UTF8String("abc")) == "cba" -@test reverse(UTF8String("xyz\uff\u800\uffff\U10ffff")) == "\U10ffff\uffff\u800\uffzyx" +## Reverse of String +@test reverse("") == "" +@test reverse("a") == "a" +@test reverse("abc") == "cba" +@test reverse("xyz\uff\u800\uffff\U10ffff") == "\U10ffff\uffff\u800\uffzyx" for str in (b"xyz\xc1", b"xyz\xd0", b"xyz\xe0", b"xyz\xed\x80", b"xyz\xf0", b"xyz\xf0\x80", b"xyz\xf0\x80\x80") - @test_throws UnicodeError reverse(UTF8String(str)) + @test_throws UnicodeError reverse(String(str)) end ## Specifically check UTF-8 string whose lead byte is same as a surrogate -@test convert(UTF8String,b"\xed\x9f\xbf") == "\ud7ff" +@test convert(String, b"\xed\x9f\xbf") == "\ud7ff" diff --git a/test/unicode/utf8proc.jl b/test/unicode/utf8proc.jl index 4f979c347b721..2fd82cd917ae8 100644 --- a/test/unicode/utf8proc.jl +++ b/test/unicode/utf8proc.jl @@ -227,7 +227,7 @@ end let grphtest = (("b\u0300lahβlahb\u0302láh", ["b\u0300","l","a","h", "β","l","a","h", "b\u0302","l","á","h"]), - ("", UTF8String[]), + ("", String[]), ("x\u0302", ["x\u0302"]), ("\U1d4c1\u0302", ["\U1d4c1\u0302"]), ("\U1d4c1\u0302\U1d4c1\u0300", ["\U1d4c1\u0302", @@ -292,6 +292,6 @@ let str = ascii("This is a test") @test convert(UTF16String, g) == str io = IOBuffer() show(io, g) - check = "length-14 GraphemeIterator{ASCIIString} for \"$str\"" + check = "length-14 GraphemeIterator{String} for \"$str\"" @test takebuf_string(io) == check end diff --git a/test/version.jl b/test/version.jl index 83d40817a6566..3dbf92389e65a 100644 --- a/test/version.jl +++ b/test/version.jl @@ -231,12 +231,12 @@ io = IOBuffer() @test VERSION.minor == ccall(:jl_ver_minor, Cint, ()) @test VERSION.patch == ccall(:jl_ver_patch, Cint, ()) -# test construction with non-Int and non-ASCIIString components +# test construction with non-Int and non-String components @test_throws MethodError VersionNumber() @test VersionNumber(true) == v"1" @test VersionNumber(true, 0x2) == v"1.2" @test VersionNumber(true, 0x2, Int128(3)) == v"1.2.3" @test VersionNumber(true, 0x2, Int128(3)) == v"1.2.3" -@test VersionNumber(true, 0x2, Int128(3), (UTF8String("rc"), 0x1)) == v"1.2.3-rc.1" -@test VersionNumber(true, 0x2, Int128(3), (UTF8String("rc"), 0x1)) == v"1.2.3-rc.1" -@test VersionNumber(true, 0x2, Int128(3), (), (UTF8String("sp"), 0x2)) == v"1.2.3+sp.2" +@test VersionNumber(true, 0x2, Int128(3), (utf16("rc"), 0x1)) == v"1.2.3-rc.1" +@test VersionNumber(true, 0x2, Int128(3), (utf16("rc"), 0x1)) == v"1.2.3-rc.1" +@test VersionNumber(true, 0x2, Int128(3), (), (utf16("sp"), 0x2)) == v"1.2.3+sp.2" diff --git a/ui/repl.c b/ui/repl.c index 8c51aaffcad00..7a184a7b2d842 100644 --- a/ui/repl.c +++ b/ui/repl.c @@ -532,7 +532,7 @@ static NOINLINE int true_main(int argc, char *argv[]) int i; for (i=0; i < argc; i++) { jl_value_t *s = (jl_value_t*)jl_cstr_to_string(argv[i]); - jl_set_typeof(s,jl_utf8_string_type); + jl_set_typeof(s,jl_string_type); jl_arrayset(args, s, i); } } From 011f4ee79152552be9b6a67ec1ec40777fcc58f6 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Mon, 2 May 2016 18:07:00 -0400 Subject: [PATCH 2/5] REPL: make all string fields concrete (i.e. String) --- base/REPL.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/base/REPL.jl b/base/REPL.jl index e6a6623e36e4d..bc3e4f9f2d254 100644 --- a/base/REPL.jl +++ b/base/REPL.jl @@ -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 @@ -297,7 +297,7 @@ end type REPLHistoryProvider <: HistoryProvider - history::Array{AbstractString,1} + history::Array{String,1} history_file start_idx::Int cur_idx::Int @@ -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 = """ @@ -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 From 530ba95fe4fd3ac9e69df658316f11a16c283ac2 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Wed, 4 May 2016 11:18:35 -0400 Subject: [PATCH 3/5] delete redundant String inner constructor --- base/boot.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/base/boot.jl b/base/boot.jl index db55a2aecc3e6..ade257c92f727 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -220,7 +220,6 @@ abstract DirectIndexString <: AbstractString immutable String <: AbstractString data::Array{UInt8,1} - String(d::Array{UInt8,1}) = new(d) end include(fname::String) = ccall(:jl_load_, Any, (Any,), fname) From 16a5d050f08f0f8cf53dfa39d0c69a7f5c3a2753 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Wed, 4 May 2016 11:18:45 -0400 Subject: [PATCH 4/5] replace jl_is_utf8_string and jl_is_byte_string with jl_is_string --- src/ccall.cpp | 10 +++++----- src/cgutils.cpp | 2 +- src/interpreter.c | 2 +- src/jlapi.c | 2 +- src/julia.h | 3 +-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ccall.cpp b/src/ccall.cpp index f75426033a37f..196ec82ee802f 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -366,7 +366,7 @@ static native_sym_arg_t interpret_symbol_arg(jl_value_t *arg, jl_codectx_t *ctx, } if (jl_is_symbol(ptr)) f_name = jl_symbol_name((jl_sym_t*)ptr); - else if (jl_is_byte_string(ptr)) + else if (jl_is_string(ptr)) f_name = jl_string_data(ptr); if (f_name != NULL) { // just symbol, default to JuliaDLHandle @@ -383,13 +383,13 @@ static native_sym_arg_t interpret_symbol_arg(jl_value_t *arg, jl_codectx_t *ctx, jl_value_t *t1 = jl_fieldref(ptr,1); if (jl_is_symbol(t0)) f_name = jl_symbol_name((jl_sym_t*)t0); - else if (jl_is_byte_string(t0)) + else if (jl_is_string(t0)) f_name = jl_string_data(t0); else JL_TYPECHKS(fname, symbol, t0); if (jl_is_symbol(t1)) f_lib = jl_symbol_name((jl_sym_t*)t1); - else if (jl_is_byte_string(t1)) + else if (jl_is_string(t1)) f_lib = jl_string_data(t1); else JL_TYPECHKS(fname, symbol, t1); @@ -653,10 +653,10 @@ static jl_cgval_t emit_llvmcall(jl_value_t **args, size_t nargs, jl_codectx_t *c jl_error("Tuple as first argument to llvmcall must have exactly two children"); decl = jl_fieldref(ir,0); ir = jl_fieldref(ir,1); - if (!jl_is_byte_string(decl)) + if (!jl_is_string(decl)) jl_error("Declarations passed to llvmcall must be a string"); } - bool isString = jl_is_byte_string(ir); + bool isString = jl_is_string(ir); bool isPtr = jl_is_cpointer(ir); if (!isString && !isPtr) { jl_error("IR passed to llvmcall must be a string or pointer to an LLVM Function"); diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 12e21221dbcbe..2d790b5b56f43 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -1598,7 +1598,7 @@ static void emit_setfield(jl_datatype_t *sty, const jl_cgval_t &strct, size_t id static bool might_need_root(jl_value_t *ex) { return (!jl_is_symbol(ex) && !jl_is_slot(ex) && !jl_is_ssavalue(ex) && - !jl_is_bool(ex) && !jl_is_quotenode(ex) && !jl_is_byte_string(ex) && + !jl_is_bool(ex) && !jl_is_quotenode(ex) && !jl_is_string(ex) && !jl_is_globalref(ex)); } diff --git a/src/interpreter.c b/src/interpreter.c index d1754101378f6..a93d6128cbb8e 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -414,7 +414,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la else if (ex->head == error_sym || ex->head == jl_incomplete_sym) { if (nargs == 0) jl_error("malformed \"error\" expression"); - if (jl_is_byte_string(args[0])) + if (jl_is_string(args[0])) jl_errorf("syntax: %s", jl_string_data(args[0])); jl_throw(args[0]); } diff --git a/src/jlapi.c b/src/jlapi.c index 06d0ec8b4c215..479132d996c59 100644 --- a/src/jlapi.c +++ b/src/jlapi.c @@ -290,7 +290,7 @@ static const char *git_info_string(const char *fld) if (!GIT_VERSION_INFO) GIT_VERSION_INFO = jl_get_global(jl_base_module, jl_symbol("GIT_VERSION_INFO")); jl_value_t *f = jl_get_field(GIT_VERSION_INFO, fld); - assert(jl_is_byte_string(f)); + assert(jl_is_string(f)); return jl_string_data(f); } diff --git a/src/julia.h b/src/julia.h index 02dd3d72e66f9..8066af83bc133 100644 --- a/src/julia.h +++ b/src/julia.h @@ -863,8 +863,7 @@ static inline uint32_t jl_fielddesc_size(int8_t fielddesc_type) #define jl_is_module(v) jl_typeis(v,jl_module_type) #define jl_is_mtable(v) jl_typeis(v,jl_methtable_type) #define jl_is_task(v) jl_typeis(v,jl_task_type) -#define jl_is_utf8_string(v) jl_typeis(v,jl_string_type) -#define jl_is_byte_string(v) jl_is_utf8_string(v) +#define jl_is_string(v) jl_typeis(v,jl_string_type) #define jl_is_cpointer(v) jl_is_cpointer_type(jl_typeof(v)) #define jl_is_pointer(v) jl_is_cpointer_type(jl_typeof(v)) From 8509862170745ed75da2867b3c2b6528782d811f Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Wed, 4 May 2016 11:22:32 -0400 Subject: [PATCH 5/5] error on non-ASCII names passed to SuiteSparse --- base/sparse/cholmod.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index 1541421699094..a765cd6d3b1ff 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -603,6 +603,7 @@ end ### cholmod_check.h ### function print_sparse{Tv<:VTypes}(A::Sparse{Tv}, name::String) + isascii(name) || error("non-ASCII name: $name") cm = common() set_print_level(cm, 3) @isok ccall((@cholmod_name("print_sparse", SuiteSparse_long),:libcholmod), Cint,