diff options
author | Marius <mariausol@gmail.com> | 2011-02-09 18:00:12 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-02-09 18:00:12 +0200 |
commit | 9273ab2ccc41973a34fbde3c7667beec8021f2eb (patch) | |
tree | 1885d69505b9f40d9a3f7e54c8445a44977cec4c /scripts | |
parent | ed637df24cc8435fc78d30bc08c89f7db60b39c9 (diff) | |
download | context-9273ab2ccc41973a34fbde3c7667beec8021f2eb.tar.gz |
beta 2011.02.09 16:42
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/lua/mtx-context.lua | 11 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 29 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 29 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mtxrun | 29 |
4 files changed, 67 insertions, 31 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 2ffab155a..da629323e 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -1313,17 +1313,20 @@ end -- modules local labels = { "title", "comment", "status" } +local cards = { "*.mkvi", "*.mkiv", "*.tex" } function scripts.context.modules(pattern) local list = { } local found = resolvers.findfile("context.mkiv") if not pattern or pattern == "" then -- official files in the tree - resolvers.findwildcardfiles("*.tex",list) - resolvers.findwildcardfiles("*.mkiv",list) + for _, card in ipairs(cards) do + resolvers.findwildcardfiles(card,list) + end -- my dev path - dir.glob(file.join(file.dirname(found),"*.tex"),list) - dir.glob(file.join(file.dirname(found),"*.mkiv"),list) + for _, card in ipairs(cards) do + dir.glob(file.join(file.dirname(found),card),list) + end else resolvers.findwildcardfiles(pattern,list) dir.glob(file.join(file.dirname(found,pattern)),list) diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index fed0e13f4..187b26e06 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -2927,21 +2927,32 @@ end -- optimizing for no find (*) does not save time +local lfsisdir = isdir + +local function isdir(path) + path = gsub(path,"[/\\]+$","") + return lfsisdir(path) +end + +lfs.isdir = isdir + local function globpattern(path,patt,recurse,action) if path == "/" then path = path .. "." elseif not find(path,"/$") then path = path .. '/' end - for name in walkdir(path) do - local full = path .. name - local mode = attributes(full,'mode') - if mode == 'file' then - if find(full,patt) then - action(full) - end - elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then - globpattern(full,patt,recurse,action) + if isdir(path) then -- lfs.isdir does not like trailing / + for name in walkdir(path) do -- lfs.dir accepts trailing / + local full = path .. name + local mode = attributes(full,'mode') + if mode == 'file' then + if find(full,patt) then + action(full) + end + elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then + globpattern(full,patt,recurse,action) + end end end end diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index fed0e13f4..187b26e06 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -2927,21 +2927,32 @@ end -- optimizing for no find (*) does not save time +local lfsisdir = isdir + +local function isdir(path) + path = gsub(path,"[/\\]+$","") + return lfsisdir(path) +end + +lfs.isdir = isdir + local function globpattern(path,patt,recurse,action) if path == "/" then path = path .. "." elseif not find(path,"/$") then path = path .. '/' end - for name in walkdir(path) do - local full = path .. name - local mode = attributes(full,'mode') - if mode == 'file' then - if find(full,patt) then - action(full) - end - elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then - globpattern(full,patt,recurse,action) + if isdir(path) then -- lfs.isdir does not like trailing / + for name in walkdir(path) do -- lfs.dir accepts trailing / + local full = path .. name + local mode = attributes(full,'mode') + if mode == 'file' then + if find(full,patt) then + action(full) + end + elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then + globpattern(full,patt,recurse,action) + end end end end diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index fed0e13f4..187b26e06 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -2927,21 +2927,32 @@ end -- optimizing for no find (*) does not save time +local lfsisdir = isdir + +local function isdir(path) + path = gsub(path,"[/\\]+$","") + return lfsisdir(path) +end + +lfs.isdir = isdir + local function globpattern(path,patt,recurse,action) if path == "/" then path = path .. "." elseif not find(path,"/$") then path = path .. '/' end - for name in walkdir(path) do - local full = path .. name - local mode = attributes(full,'mode') - if mode == 'file' then - if find(full,patt) then - action(full) - end - elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then - globpattern(full,patt,recurse,action) + if isdir(path) then -- lfs.isdir does not like trailing / + for name in walkdir(path) do -- lfs.dir accepts trailing / + local full = path .. name + local mode = attributes(full,'mode') + if mode == 'file' then + if find(full,patt) then + action(full) + end + elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then + globpattern(full,patt,recurse,action) + end end end end |