#
#
# patch "ChangeLog"
# from [9fe5f1edb4fd1051f924420ad7fe481478468ff1]
# to [0a62cdf266445b20fe95f91f4c13f8b1f467d4dc]
#
# patch "lua.cc"
# from [6583ce3385e41b5082117dfb7c7c74fd8650e403]
# to [a9045fcf6d8283a12a96f422b79fb54ae2da727c]
#
============================================================
--- ChangeLog 9fe5f1edb4fd1051f924420ad7fe481478468ff1
+++ ChangeLog 0a62cdf266445b20fe95f91f4c13f8b1f467d4dc
@@ -1,3 +1,8 @@
+2006-02-19 Matthew Gregan
+
+ * lua.cc: Use the safer luaL_check* rather than lua_to* in
+ monotone_*_for_lua functions.
+
2006-02-18 Matthew Gregan
* tests/t_log_nofiles_merges.at: Add test for the log options
============================================================
--- lua.cc 6583ce3385e41b5082117dfb7c7c74fd8650e403
+++ lua.cc a9045fcf6d8283a12a96f422b79fb54ae2da727c
@@ -426,7 +426,7 @@
{
int fd = -1;
FILE **pf = NULL;
- char const *filename = lua_tostring (L, -1);
+ char const *filename = luaL_checkstring (L, -1);
std::string dup(filename);
fd = monotone_mkstemp(dup);
@@ -458,7 +458,7 @@
static int
monotone_existsonpath_for_lua(lua_State *L)
{
- const char *exe = lua_tostring(L, -1);
+ const char *exe = luaL_checkstring(L, -1);
lua_pushnumber(L, existsonpath(exe));
return 1;
}
@@ -466,7 +466,7 @@
static int
monotone_is_executable_for_lua(lua_State *L)
{
- const char *path = lua_tostring(L, -1);
+ const char *path = luaL_checkstring(L, -1);
lua_pushboolean(L, is_executable(path));
return 1;
}
@@ -474,7 +474,7 @@
static int
monotone_make_executable_for_lua(lua_State *L)
{
- const char *path = lua_tostring(L, -1);
+ const char *path = luaL_checkstring(L, -1);
lua_pushnumber(L, make_executable(path));
return 1;
}
@@ -483,14 +483,14 @@
monotone_spawn_for_lua(lua_State *L)
{
int n = lua_gettop(L);
- const char *path = lua_tostring(L, -n);
+ const char *path = luaL_checkstring(L, -n);
char **argv = (char**)malloc((n+1)*sizeof(char*));
int i;
pid_t ret;
if (argv==NULL)
return 0;
argv[0] = (char*)path;
- for (i=1; i(luaL_checknumber(L, -1));
int res;
int ret;
ret = process_wait(pid, &res);
@@ -514,10 +514,10 @@
monotone_kill_for_lua(lua_State *L)
{
int n = lua_gettop(L);
- pid_t pid = (pid_t)lua_tonumber(L, -2);
+ pid_t pid = static_cast(luaL_checknumber(L, -2));
int sig;
if (n>1)
- sig = (int)lua_tonumber(L, -1);
+ sig = static_cast(luaL_checknumber(L, -1));
else
sig = SIGTERM;
lua_pushnumber(L, process_kill(pid, sig));
@@ -527,7 +527,7 @@
static int
monotone_sleep_for_lua(lua_State *L)
{
- int seconds = (int)lua_tonumber(L, -1);
+ int seconds = static_cast(luaL_checknumber(L, -1));
lua_pushnumber(L, process_sleep(seconds));
return 1;
}
@@ -535,7 +535,7 @@
static int
monotone_guess_binary_file_contents_for_lua(lua_State *L)
{
- const char *path = lua_tostring(L, -1);
+ const char *path = luaL_checkstring(L, -1);
N(path, F("%s called with an invalid parameter") % "guess_binary");
std::ifstream file(path, ios_base::binary);
@@ -564,7 +564,7 @@
static int
monotone_include_for_lua(lua_State *L)
{
- const char *path = lua_tostring(L, -1);
+ const char *path = luaL_checkstring(L, -1);
N(path, F("%s called with an invalid parameter") % "Include");
bool res =Lua(L)
@@ -579,7 +579,7 @@
static int
monotone_includedir_for_lua(lua_State *L)
{
- const char *pathstr = lua_tostring(L, -1);
+ const char *pathstr = luaL_checkstring(L, -1);
N(pathstr, F("%s called with an invalid parameter") % "IncludeDir");
fs::path locpath(pathstr, fs::native);
@@ -613,8 +613,8 @@
static int
monotone_regex_search_for_lua(lua_State *L)
{
- const char *re = lua_tostring(L, -2);
- const char *str = lua_tostring(L, -1);
+ const char *re = luaL_checkstring(L, -2);
+ const char *str = luaL_checkstring(L, -1);
boost::cmatch what;
bool result = false;
@@ -632,8 +632,8 @@
static int
monotone_globish_match_for_lua(lua_State *L)
{
- const char *re = lua_tostring(L, -2);
- const char *str = lua_tostring(L, -1);
+ const char *re = luaL_checkstring(L, -2);
+ const char *str = luaL_checkstring(L, -1);
bool result = false;
try {
@@ -661,7 +661,7 @@
static int
monotone_gettext_for_lua(lua_State *L)
{
- const char *msgid = lua_tostring(L, -1);
+ const char *msgid = luaL_checkstring(L, -1);
lua_pushstring(L, gettext(msgid));
return 1;
}
@@ -685,7 +685,7 @@
monotone_parse_basic_io_for_lua(lua_State *L)
{
vector > > res;
- const string str(lua_tostring(L, -1), lua_strlen(L, -1));
+ const string str(luaL_checkstring(L, -1), lua_strlen(L, -1));
basic_io::input_source in(str, "monotone_parse_basic_io_for_lua");
basic_io::tokenizer tok(in);
try