Skip to content

Commit

Permalink
fixup varg passing c.f. teal-language/tl#873
Browse files Browse the repository at this point in the history
  • Loading branch information
atticus-sullivan committed Dec 18, 2024
1 parent ea1626a commit 3997986
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
20 changes: 11 additions & 9 deletions src_teal/texrunner/pathutil_unix.tl
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,20 @@ local function joinpath2(x: string, y: string): string
end
end

local function joinpath(...: string): string
local args = {...}
local function joinpath(a?:string, b?:string, ...: string): string
local n = select("#", ...)
if n == 2 then
return joinpath2(args[1], args[2])
elseif n == 0 then
if not a then
-- 0 argument
return "."
elseif n == 1 then
return ...
elseif not b then
-- 1 argument
return a
elseif n == 0 then
-- 2 arguments
return joinpath2(a, b)
else
-- n is >= 3
return joinpath(joinpath2(args[1], args[2]), select(3, ...))
-- >= 3 arguments
return joinpath(joinpath2(a, b), ...)
end
end

Expand Down
20 changes: 11 additions & 9 deletions src_teal/texrunner/pathutil_windows.tl
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,20 @@ local function joinpath2(x: string, y: string): string
end
end

local function joinpath(...: string): string
local args = {...}
local function joinpath(a?:string, b?:string, ...: string): string
local n = select("#", ...)
if n == 2 then
return joinpath2(args[1], args[2])
elseif n == 0 then
if not a then
-- 0 argument
return "."
elseif n == 1 then
return ...
elseif not b then
-- 1 argument
return a
elseif n == 0 then
-- 2 arguments
return joinpath2(a, b)
else
-- n is >= 3
return joinpath(joinpath2(args[1], args[2]), select(3, ...))
-- >= 3 arguments
return joinpath(joinpath2(a, b), ...)
end
end

Expand Down

0 comments on commit 3997986

Please sign in to comment.