Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2014-04-24 18:44:03 +0400
committerJason Perkins <starkos@industriousone.com>2014-04-24 18:44:03 +0400
commitb27d1accb89968833ee089e6544030829ca74ec0 (patch)
treec5621454e0904de07e258c903893b21f6cf9c9c3
parent6b21344759a95fa95f40f2b36a842f6f5ac25bb1 (diff)
Fix issue #20 - can now find files with a dot prefix; directories are still ignored
-rw-r--r--src/base/os.lua4
-rw-r--r--src/host/os_match.c18
-rw-r--r--tests/base/test_os.lua39
3 files changed, 33 insertions, 28 deletions
diff --git a/src/base/os.lua b/src/base/os.lua
index deff1d0..bc33451 100644
--- a/src/base/os.lua
+++ b/src/base/os.lua
@@ -206,7 +206,9 @@
while (os.matchnext(m)) do
if not os.matchisfile(m) then
local dirname = os.matchname(m)
- matchwalker(path.join(basedir, dirname))
+ if (not dirname:startswith(".")) then
+ matchwalker(path.join(basedir, dirname))
+ end
end
end
os.matchdone(m)
diff --git a/src/host/os_match.c b/src/host/os_match.c
index a267381..5ccc04d 100644
--- a/src/host/os_match.c
+++ b/src/host/os_match.c
@@ -57,9 +57,10 @@ int os_matchisfile(lua_State* L)
int os_matchnext(lua_State* L)
{
MatchInfo* m = (MatchInfo*)lua_touserdata(L, 1);
- if (m->handle == INVALID_HANDLE_VALUE)
+ if (m->handle == INVALID_HANDLE_VALUE) {
return 0;
-
+ }
+
while (m) /* loop forever */
{
if (!m->is_first)
@@ -69,11 +70,8 @@ int os_matchnext(lua_State* L)
}
m->is_first = 0;
- if (m->entry.cFileName[0] != '.')
- {
- lua_pushboolean(L, 1);
- return 1;
- }
+ lua_pushboolean(L, 1);
+ return 1;
}
return 0;
@@ -155,7 +153,7 @@ int os_matchisfile(lua_State* L)
lua_pushboolean(L, S_ISREG(info.st_mode));
return 1;
}
-
+
return 0;
}
@@ -164,12 +162,12 @@ int os_matchnext(lua_State* L)
MatchInfo* m = (MatchInfo*)lua_touserdata(L, 1);
if (m->handle == NULL)
return 0;
-
+
m->entry = readdir(m->handle);
while (m->entry != NULL)
{
const char* name = m->entry->d_name;
- if (name[0] != '.' && fnmatch(m->mask, name, 0) == 0)
+ if (fnmatch(m->mask, name, 0) == 0)
{
lua_pushboolean(L, 1);
return 1;
diff --git a/tests/base/test_os.lua b/tests/base/test_os.lua
index fb720c9..db49547 100644
--- a/tests/base/test_os.lua
+++ b/tests/base/test_os.lua
@@ -8,7 +8,7 @@
T.os = { }
local suite = T.os
-
+
--
-- os.findlib() tests
--
@@ -17,17 +17,17 @@
if os.is("windows") then
test.istrue(os.findlib("user32"))
elseif os.is("haiku") then
- test.istrue(os.findlib("root"))
+ test.istrue(os.findlib("root"))
else
- test.istrue(os.findlib("m"))
+ test.istrue(os.findlib("m"))
end
end
-
+
function suite.findlib_FailsOnBadLibName()
test.isfalse(os.findlib("NoSuchLibraryAsThisOneHere"))
end
-
-
+
+
--
-- os.isfile() tests
--
@@ -49,7 +49,7 @@
function suite.matchfiles_OnNonRecursive()
local result = os.matchfiles("*.lua")
test.istrue(table.contains(result, "testfx.lua"))
- test.isfalse(table.contains(result, "folder/ok.lua"))
+ test.isfalse(table.contains(result, "folder/ok.lua"))
end
function suite.matchfiles_Recursive()
@@ -61,31 +61,36 @@
local result = os.matchfiles("**.lua")
test.isfalse(table.contains(result, ".svn/text-base/testfx.lua.svn-base"))
end
-
+
function suite.matchfiles_OnSubfolderMatch()
local result = os.matchfiles("**/xcode/*")
test.istrue(table.contains(result, "actions/xcode/test_xcode_project.lua"))
test.isfalse(table.contains(result, "premake4.lua"))
end
-
+
function suite.matchfiles_OnDotSlashPrefix()
local result = os.matchfiles("./**.lua")
test.istrue(table.contains(result, "folder/ok.lua"))
end
-
+
function suite.matchfiles_OnImplicitEndOfString()
local result = os.matchfiles("folder/*.lua")
test.istrue(table.contains(result, "folder/ok.lua"))
test.isfalse(table.contains(result, "folder/ok.lua.2"))
end
-
+
function suite.matchfiles_OnLeadingDotSlashWithPath()
local result = os.matchfiles("./folder/*.lua")
test.istrue(table.contains(result, "folder/ok.lua"))
end
+ function suite.matchfiles_OnDottedFile()
+ local result = os.matchfiles("../.*")
+ test.istrue(table.contains(result, "../.hgignore"))
+ end
+
+
-
--
-- os.pathsearch() tests
--
@@ -93,20 +98,20 @@
function suite.pathsearch_ReturnsNil_OnNotFound()
test.istrue( os.pathsearch("nosuchfile", "aaa;bbb;ccc") == nil )
end
-
+
function suite.pathsearch_ReturnsPath_OnFound()
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", os.getcwd()))
end
-
+
function suite.pathsearch_FindsFile_OnComplexPath()
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", "aaa;"..os.getcwd()..";bbb"))
end
-
+
function suite.pathsearch_NilPathsAllowed()
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", nil, os.getcwd(), nil))
end
-
+
--
-- os.uuid() tests
--
@@ -123,4 +128,4 @@
test.isequal("-", g:sub(19,19))
test.isequal("-", g:sub(24,24))
end
-
+