extract a common function call
This commit is contained in:
parent
503ad706fb
commit
7a315e3d9f
|
@ -131,10 +131,11 @@ static int io_open (lua_State *L) {
|
|||
snprintf(buffer, 1020, "io.open(\"%s\", \"%s\")", filename, mode);
|
||||
append_to_audit_log(L, buffer);
|
||||
FILE **pf = newfile(L);
|
||||
if (file_operation_permitted(caller(L), filename, mode))
|
||||
const char *caller = get_caller(L);
|
||||
if (file_operation_permitted(caller, filename, mode))
|
||||
*pf = fopen(filename, mode);
|
||||
else {
|
||||
snprintf(iolib_errbuf, 1024, "app tried to open file '%s' from caller '%s'; adjust its permissions (ctrl-p) if that is expected", filename, caller(L));
|
||||
snprintf(iolib_errbuf, 1024, "app tried to open file '%s' from caller '%s'; adjust its permissions (ctrl-p) if that is expected", filename, caller);
|
||||
Previous_message = iolib_errbuf;
|
||||
}
|
||||
return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
|
||||
|
|
|
@ -324,7 +324,7 @@ void save_caller(lua_State* L, const char* name, int call_graph_depth) {
|
|||
if (ar.name) save_caller_as(L, name, ar.name);
|
||||
}
|
||||
|
||||
char* caller(lua_State* L) {
|
||||
char* get_caller(lua_State* L) {
|
||||
static char result[1024] = {0};
|
||||
lua_Debug ar;
|
||||
lua_getstack(L, 1, &ar);
|
||||
|
|
|
@ -165,7 +165,7 @@ extern void save_editor_state(int rowoff, int coloff, int cy, int cx);
|
|||
int editor_view_in_progress(lua_State* L);
|
||||
|
||||
extern void assign_call_graph_depth_to_name(lua_State* L, int depth, const char* name);
|
||||
extern char* caller(lua_State* L);
|
||||
extern char* get_caller(lua_State* L);
|
||||
extern void save_caller(lua_State* L, const char* name, int call_graph_depth);
|
||||
extern void draw_callers_of_current_definition(lua_State* L);
|
||||
extern void append_to_audit_log(lua_State* L, const char* buffer);
|
||||
|
|
Loading…
Reference in New Issue