Skip to content

Commit 982f9dc

Browse files
fixes for windows
1 parent 98ef664 commit 982f9dc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

stdlib/Profile/src/Profile.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ using StyledStrings: @styled_str
4343

4444
const nmeta = 4 # number of metadata fields per block (threadid, taskid, cpu_cycle_clock, thread_sleeping)
4545

46+
const slash = Sys.iswindows() ? "\\" : "/"
47+
4648
# deprecated functions: use `getdict` instead
4749
lookup(ip::UInt) = lookup(convert(Ptr{Cvoid}, ip))
4850

@@ -944,8 +946,8 @@ function print_flat(io::IO, lilist::Vector{StackFrame},
944946
Base.printstyled(io, pkgname, color=pkgcolor)
945947
file_trunc = ltruncate(file, max(1, wfile))
946948
wpad = wfile - textwidth(pkgname)
947-
if !isempty(pkgname) && !startswith(file_trunc, "/")
948-
Base.print(io, "/")
949+
if !isempty(pkgname) && !startswith(file_trunc, slash)
950+
Base.print(io, slash)
949951
wpad -= 1
950952
end
951953
if isempty(path)
@@ -1048,8 +1050,8 @@ function tree_format(frames::Vector{<:StackFrameTree}, level::Int, cols::Int, ma
10481050
pkgcolor = get!(() -> popfirst!(Base.STACKTRACE_MODULECOLORS), PACKAGE_FIXEDCOLORS, pkgname)
10491051
remaining_path = ltruncate(filename, max(1, widthfile - textwidth(pkgname) - 1))
10501052
linenum = li.line == -1 ? "?" : string(li.line)
1051-
slash = (!isempty(pkgname) && !startswith(remaining_path, "/")) ? "/" : ""
1052-
styled_path = styled"{$pkgcolor:$pkgname}$slash$remaining_path:$linenum"
1053+
_slash = (!isempty(pkgname) && !startswith(remaining_path, slash)) ? slash : ""
1054+
styled_path = styled"{$pkgcolor:$pkgname}$(_slash)$remaining_path:$linenum"
10531055
rich_file = if isempty(path)
10541056
styled_path
10551057
else

stdlib/Profile/test/runtests.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,13 @@ import InteractiveUtils
213213
ioc = IOContext(io, :displaysize=>(1000,1000))
214214
Profile.print(ioc, C=true)
215215
str = String(take!(io))
216-
@test occursin("@Compiler/", str)
217-
@test occursin("@Base/", str)
218-
@test occursin("@InteractiveUtils/", str)
219-
@test occursin("@LinearAlgebra/", str)
220-
@test occursin("@juliasrc/", str)
221-
@test occursin("@julialib/", str)
216+
slash = Sys.iswindows() ? "\\" : "/"
217+
@test occursin("@Compiler" * slash, str)
218+
@test occursin("@Base" * slash, str)
219+
@test occursin("@InteractiveUtils" * slash, str)
220+
@test occursin("@LinearAlgebra" * slash, str)
221+
@test occursin("@juliasrc" * slash, str)
222+
@test occursin("@julialib" * slash, str)
222223
end
223224

224225
# Profile deadlocking in compilation (debuginfo registration)

0 commit comments

Comments
 (0)