about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-07 08:52:41 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-03-07 08:52:41 -0800
commit7a315e3d9f1c668b54d57b472b612c7f6d738ede (patch)
treebdb5ee31c70ec27491a7c20b08fb25e8dd43205c /src
parent503ad706fbe7400f197f92dc1d895fd2f3db7cb8 (diff)
downloadteliva-7a315e3d9f1c668b54d57b472b612c7f6d738ede.tar.gz
extract a common function call
Diffstat (limited to 'src')
-rw-r--r--src/liolib.c5
-rw-r--r--src/teliva.c2
-rw-r--r--src/teliva.h2
3 files changed, 5 insertions, 4 deletions
diff --git a/src/liolib.c b/src/liolib.c
index 75876d2..45d40a9 100644
--- a/src/liolib.c
+++ b/src/liolib.c
@@ -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;
diff --git a/src/teliva.c b/src/teliva.c
index 52c1ae3..71576b5 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -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);
diff --git a/src/teliva.h b/src/teliva.h
index a7fb084..db2138d 100644
--- a/src/teliva.h
+++ b/src/teliva.h
@@ -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);