MAJOR=4 MINOR=3 DEVNAME=tty3 8 ˆl–Ãa¾”ji?uA à¸)‹Fÿ�þBG•fäC#o¹`óÇ …\e°ÿÆÅÄ?÷ #!/usr/bin/env texlua local io, os, string, table, package, require, assert, error, ipairs, type, select, arg = io, os, string, table, package, require, assert, error, ipairs, type, select, arg local CLUTTEX_VERBOSITY, CLUTTEX_VERSION os.type = os.type or "unix" if lfs and not package.loaded['lfs'] then package.loaded['lfs'] = lfs end if os.type == "windows" then package.preload["texrunner.pathutil"] = function(...) --[[ Copyright 2016 ARATA Mizuki This file is part of ClutTeX. ClutTeX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ClutTeX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ClutTeX. If not, see . ]] -- pathutil module local assert = assert local select = select local string = string local string_find = string.find local string_sub = string.sub local string_match = string.match local string_gsub = string.gsub local filesys = require "lfs" local function basename(path) local i = 0 while true do local j = string_find(path, "[\\/]", i + 1) if j == nil then return string_sub(path, i + 1) elseif j == #path then return string_sub(path, i + 1, -2) end i = j end end local function dirname(path) local i = 0 while true do local j = string_find(path, "[\\/]", i + 1) if j == nil then if i == 0 then -- No directory portion return "." elseif i == 1 then -- Root return string_sub(path, 1, 1) else -- Directory portion without trailing slash return string_sub(path, 1, i - 1) end end i = j end end local function parentdir(path) local i = 0 while true do local j = string_find(path, "[\\/]", i + 1) if j == nil then if i == 0 then -- No directory portion return "." elseif i == 1 then -- Root return string_sub(path, 1, 1) else -- Directory portion without trailing slash return string_sub(path, 1, i - 1) end elseif j == #path then -- Directory portion without trailing slash return string_sub(path, 1, i - 1) end i = j end end local function trimext(path) return (string_gsub(path, "%.[^\\/%.]*$", "")) end local function ext(path) return string_match(path, "%.([^\\/%.]*)$") or "" end local function replaceext(path, newext) local newpath, n = string_gsub(path, "%.([^\\/%.]*)$", function() return "." .. newext end) if n == 0 then return newpath .. "." .. newext else return newpath end end local function joinpath2(x, y) local xd = x local last = string_sub(x, -1) if last ~= "/" and last ~= "\\" then xd = x .. "\\" end if y == "." then return xd elseif y == ".." then return dirname(x) else if string_match(y, "^%.[\\/]") then return xd .. string_sub(y, 3) else return xd .. y end end end local function joinpath(...) local n = select("#", ...) if n == 2 then return joinpath2(...) elseif n == 0 then return "." elseif n == 1 then return ... else return joinpath(joinpath2(...), select(3, ...)) end end -- https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx local function isabspath(path) local init = string_sub(path, 1, 1) return init == "\\" or init == "/" or string_match(path, "^%a:[/\\]") end local function abspath(path, cwd) if isabspath(path) then -- absolute path return path else -- TODO: relative path with a drive letter is not supported cwd = cwd or fil