|
1 | 1 | function checkname(fdef::Expr, name) |
2 | 2 | fproto = fdef.args[1] |
3 | 3 | fdef.head === :where && return checkname(fproto, name) |
| 4 | + fdef.head === :call || return false |
4 | 5 | if fproto isa Expr |
| 6 | + # A metaprogramming-generated function |
| 7 | + fproto.head === :$ && return true # uncheckable, let's assume all is well |
5 | 8 | # Is the check below redundant? |
6 | 9 | fproto.head === :. || return false |
7 | 10 | # E.g. `function Mod.bar.foo(a, b)` |
@@ -137,3 +140,35 @@ function postpath(filename, pre) |
137 | 140 | post[1:1] == Base.Filesystem.path_separator && return post[2:end] |
138 | 141 | return post |
139 | 142 | end |
| 143 | + |
| 144 | +if Base.VERSION < v"1.1" |
| 145 | + function splitpath(p::String) |
| 146 | + # splitpath became available with Julia 1.1 |
| 147 | + # Implementation copied from Base except doesn't handle the drive |
| 148 | + out = String[] |
| 149 | + isempty(p) && (pushfirst!(out,p)) # "" means the current directory. |
| 150 | + while !isempty(p) |
| 151 | + dir, base = _splitdir_nodrive(p) |
| 152 | + dir == p && (pushfirst!(out, dir); break) # Reached root node. |
| 153 | + if !isempty(base) # Skip trailing '/' in basename |
| 154 | + pushfirst!(out, base) |
| 155 | + end |
| 156 | + p = dir |
| 157 | + end |
| 158 | + return out |
| 159 | + end |
| 160 | + splitpath(p::AbstractString) = splitpath(String(p)) |
| 161 | + |
| 162 | + _splitdir_nodrive(path::String) = _splitdir_nodrive("", path) |
| 163 | + function _splitdir_nodrive(a::String, b::String) |
| 164 | + m = match(Base.Filesystem.path_dir_splitter,b) |
| 165 | + m === nothing && return (a,b) |
| 166 | + a = string(a, isempty(m.captures[1]) ? m.captures[2][1] : m.captures[1]) |
| 167 | + a, String(m.captures[3]) |
| 168 | + end |
| 169 | +end |
| 170 | + |
| 171 | +# Robust across Julia versions |
| 172 | +getpkgid(project::AbstractString, libname) = getpkgid(Base.project_deps_get(project, libname), libname) |
| 173 | +getpkgid(id::PkgId, libname) = id |
| 174 | +getpkgid(uuid::UUID, libname) = PkgId(uuid, libname) |
0 commit comments