From 1f0e3ed568ea41f6fd5523d33c689be9ee31f799 Mon Sep 17 00:00:00 2001 From: starkos Date: Tue, 29 Sep 2009 19:27:33 +0000 Subject: [PATCH] Fixed os.match() for very large result sets; fixed bug in action tests --- CHANGES.txt | 8 +++++- src/base/action.lua | 52 +++++++++++++++++----------------- src/host/os_match.c | 7 +++-- tests/base/test_action.lua | 2 ++ tests/{ => base}/test_path.lua | 19 +++++++++---- tests/premake4.lua | 2 +- 6 files changed, 55 insertions(+), 35 deletions(-) rename tests/{ => base}/test_path.lua (92%) diff --git a/CHANGES.txt b/CHANGES.txt index b4c8d8c3..bf0321a9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,12 +3,18 @@ ----- - Added support for Apple Xcode 3 + + +------- + 4.1.2 +------- + - Changed arguments to GCC link step to fix static linking - Fixed ManagedExtension setting for Visual Studio ------- - 4.1.1 (in progress) + 4.1.1 ------- - Use libtool instead of ar for Mac OS X Universal static libraries diff --git a/src/base/action.lua b/src/base/action.lua index 2e7edc9c..9d28a29d 100644 --- a/src/base/action.lua +++ b/src/base/action.lua @@ -39,32 +39,6 @@ end --- --- Retrieve the current action, as determined by _ACTION. --- --- @return --- The current action, or nil if _ACTION is nil or does not match any action. --- - - function premake.action.current() - return premake.action.get(_ACTION) - end - - --- --- Retrieve an action by name. --- --- @param name --- The name of the action to retrieve. --- @returns --- The requested action, or nil if the action does not exist. --- - - function premake.action.get(name) - return premake.action.list[name] - end - - -- -- Trigger an action. -- @@ -94,6 +68,32 @@ end +-- +-- Retrieve the current action, as determined by _ACTION. +-- +-- @return +-- The current action, or nil if _ACTION is nil or does not match any action. +-- + + function premake.action.current() + return premake.action.get(_ACTION) + end + + +-- +-- Retrieve an action by name. +-- +-- @param name +-- The name of the action to retrieve. +-- @returns +-- The requested action, or nil if the action does not exist. +-- + + function premake.action.get(name) + return premake.action.list[name] + end + + -- -- Iterator for the list of actions. -- diff --git a/src/host/os_match.c b/src/host/os_match.c index 2b171a37..9d8e89f9 100644 --- a/src/host/os_match.c +++ b/src/host/os_match.c @@ -106,13 +106,15 @@ int os_matchstart(lua_State* L) m->path = (char*)malloc(split - mask + 1); strncpy(m->path, mask, split - mask); m->path[split - mask] = '\0'; - m->mask = (char*)(split + 1); + m->mask = (char*)malloc(mask + strlen(mask) - split); + strcpy(m->mask, split + 1); } else { m->path = (char*)malloc(2); strcpy(m->path, "."); - m->mask = (char*)mask; + m->mask = (char*)malloc(strlen(mask)+1); + strcpy(m->mask, mask); } m->handle = opendir(m->path); @@ -126,6 +128,7 @@ int os_matchdone(lua_State* L) if (m->handle != NULL) closedir(m->handle); free(m->path); + free(m->mask); free(m); return 0; } diff --git a/tests/base/test_action.lua b/tests/base/test_action.lua index 9aee2f9c..b0421df0 100644 --- a/tests/base/test_action.lua +++ b/tests/base/test_action.lua @@ -65,7 +65,9 @@ -- function T.action.set_SetsActionOS() + local oldos = _OS _OS = "linux" premake.action.set("vs2008") test.isequal(_OS, "windows") + _OS = oldos end diff --git a/tests/test_path.lua b/tests/base/test_path.lua similarity index 92% rename from tests/test_path.lua rename to tests/base/test_path.lua index 7c05e8fb..3338741c 100644 --- a/tests/test_path.lua +++ b/tests/base/test_path.lua @@ -1,10 +1,9 @@ -- --- tests/test_path.lua --- Automated test suite for the path manipulation functions. --- Copyright (c) 2008 Jason Perkins and the Premake project +-- tests/base/test_path.lua +-- Automated test suite for the action list. +-- Copyright (c) 2008,2009 Jason Perkins and the Premake project -- - T.path = { } @@ -160,7 +159,17 @@ test.isequal("trailing", path.join(".", "trailing")) end - + +-- +-- path.rebase() tests +-- + + function T.path.rebase_WithEndingSlashOnPath() + local cwd = os.getcwd() + test.isequal("src", path.rebase("../src/", cwd, path.getdirectory(cwd))) + end + + -- -- path.translate() tests -- diff --git a/tests/premake4.lua b/tests/premake4.lua index 4583b3a0..ab45ce96 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -39,7 +39,6 @@ dofile("test_dofile.lua") dofile("test_os.lua") - dofile("test_path.lua") dofile("test_string.lua") dofile("test_table.lua") dofile("test_premake.lua") @@ -58,6 +57,7 @@ dofile("test_gmake_cpp.lua") dofile("test_gmake_cs.lua") dofile("base/test_action.lua") + dofile("base/test_path.lua") dofile("base/test_tree.lua") dofile("actions/test_clean.lua") dofile("actions/test_xcode.lua")