diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/l-os.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/l-os.lua | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/l-os.lua b/Master/texmf-dist/tex/context/base/mkiv/l-os.lua index 0a86ea6d697..9b54c9840c4 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/l-os.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/l-os.lua @@ -119,7 +119,7 @@ end local execute = os.execute local iopopen = io.popen -function os.resultof(command) +local function resultof(command) local handle = iopopen(command,"r") -- already has flush if handle then local result = handle:read("*all") or "" @@ -130,9 +130,15 @@ function os.resultof(command) end end +os.resultof = resultof + +function os.pipeto(command) + return iopopen(command,"w") -- already has flush +end + if not io.fileseparator then if find(os.getenv("PATH"),";",1,true) then - io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "mswin" + io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "windows" else io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end @@ -203,17 +209,17 @@ end }) local name, platform = os.name or "linux", os.getenv("MTX_PLATFORM") or "" -local function guess() - local architecture = os.resultof("uname -m") or "" - if architecture ~= "" then - return architecture - end - architecture = os.getenv("HOSTTYPE") or "" - if architecture ~= "" then - return architecture - end - return os.resultof("echo $HOSTTYPE") or "" -end +-- local function guess() +-- local architecture = resultof("uname -m") or "" +-- if architecture ~= "" then +-- return architecture +-- end +-- architecture = os.getenv("HOSTTYPE") or "" +-- if architecture ~= "" then +-- return architecture +-- end +-- return resultof("echo $HOSTTYPE") or "" +-- end -- os.bits = 32 | 64 @@ -245,7 +251,7 @@ elseif name == "linux" then function resolvers.platform(t,k) -- we sometimes have HOSTTYPE set so let's check that first - local platform, architecture = "", os.getenv("HOSTTYPE") or os.resultof("uname -m") or "" + local platform, architecture = "", os.getenv("HOSTTYPE") or resultof("uname -m") or "" if find(architecture,"x86_64",1,true) then platform = "linux-64" elseif find(architecture,"ppc",1,true) then @@ -273,9 +279,9 @@ elseif name == "macosx" then function resolvers.platform(t,k) -- local platform, architecture = "", os.getenv("HOSTTYPE") or "" -- if architecture == "" then - -- architecture = os.resultof("echo $HOSTTYPE") or "" + -- architecture = resultof("echo $HOSTTYPE") or "" -- end - local platform, architecture = "", os.resultof("echo $HOSTTYPE") or "" + local platform, architecture = "", resultof("echo $HOSTTYPE") or "" if architecture == "" then -- print("\nI have no clue what kind of OSX you're running so let's assume an 32 bit intel.\n") platform = "osx-intel" @@ -294,7 +300,7 @@ elseif name == "macosx" then elseif name == "sunos" then function resolvers.platform(t,k) - local platform, architecture = "", os.resultof("uname -m") or "" + local platform, architecture = "", resultof("uname -m") or "" if find(architecture,"sparc",1,true) then platform = "solaris-sparc" else -- if architecture == 'i86pc' @@ -308,7 +314,7 @@ elseif name == "sunos" then elseif name == "freebsd" then function resolvers.platform(t,k) - local platform, architecture = "", os.resultof("uname -m") or "" + local platform, architecture = "", resultof("uname -m") or "" if find(architecture,"amd64",1,true) then platform = "freebsd-amd64" else @@ -323,7 +329,7 @@ elseif name == "kfreebsd" then function resolvers.platform(t,k) -- we sometimes have HOSTTYPE set so let's check that first - local platform, architecture = "", os.getenv("HOSTTYPE") or os.resultof("uname -m") or "" + local platform, architecture = "", os.getenv("HOSTTYPE") or resultof("uname -m") or "" if find(architecture,"x86_64",1,true) then platform = "kfreebsd-amd64" else @@ -502,8 +508,10 @@ end -- These are moved from core-con.lua (as I needed them elsewhere). -local function isleapyear(year) - return (year % 400 == 0) or ((year % 100 ~= 0) and (year % 4 == 0)) +local function isleapyear(year) -- timed for bram's cs practicum + -- return (year % 400 == 0) or (year % 100 ~= 0 and year % 4 == 0) -- 3:4:1600:1900 = 9.9 : 8.2 : 5.0 : 6.8 (29.9) + return (year % 4 == 0) and (year % 100 ~= 0 or year % 400 == 0) -- 3:4:1600:1900 = 5.1 : 6.5 : 8.1 : 10.2 (29.9) + -- return (year % 4 == 0) and (year % 400 == 0 or year % 100 ~= 0) -- 3:4:1600:1900 = 5.2 : 8.5 : 6.8 : 10.1 (30.6) end os.isleapyear = isleapyear |