about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-13 14:38:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-03-13 14:41:41 -0700
commitee7f893a7e9440b0caaeddb804e8e1ac34f5c9a2 (patch)
treee391d63f26491b8486b3a8936a261d70da0e9625
parent35a6794386d347baec5349fceeb419f940361b87 (diff)
downloadteliva-ee7f893a7e9440b0caaeddb804e8e1ac34f5c9a2.tar.gz
drop string.dump, clean up docs around it
-rw-r--r--doc/manual.html19
-rw-r--r--src/lbaselib.c4
-rw-r--r--src/lstrlib.c21
3 files changed, 5 insertions, 39 deletions
diff --git a/doc/manual.html b/doc/manual.html
index fe40d5d..5ece5c0 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -2721,20 +2721,6 @@ Note that numerical codes are not necessarily portable across platforms.
 
 
 
-
-<p>
-<hr><h3><a name="pdf-string.dump"><code>string.dump (function)</code></a></h3>
-
-
-<p>
-Returns a string containing a binary representation of the given function,
-so that a later <a href="#pdf-loadstring"><code>loadstring</code></a> on this string returns
-a copy of the function.
-<code>function</code> must be a Lua function without upvalues.
-
-
-
-
 <p>
 <hr><h3><a name="pdf-string.find"><code>string.find (s, pattern [, init [, plain]])</code></a></h3>
 Looks for the first match of
@@ -2903,11 +2889,6 @@ Here are some examples:
      x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)
      --&gt; x="home = /home/roberto, user = roberto"
      
-     x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
-           return loadstring(s)()
-         end)
-     --&gt; x="4+5 = 9"
-     
      local t = {name="lua", version="5.1"}
      x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
      --&gt; x="lua-5.1.tar.gz"
diff --git a/src/lbaselib.c b/src/lbaselib.c
index 8a4d651..6f78f7f 100644
--- a/src/lbaselib.c
+++ b/src/lbaselib.c
@@ -380,10 +380,14 @@ static int luaB_newproxy (lua_State *L) {
 static const luaL_Reg base_funcs[] = {
   {"assert", luaB_assert},
   {"collectgarbage", luaB_collectgarbage},
+  /* no 'dofile' without sandboxing it */
   {"error", luaB_error},
   {"gcinfo", luaB_gcinfo},
   {"getfenv", luaB_getfenv},
   {"getmetatable", luaB_getmetatable},
+  /* no 'loadfile' without sandboxing it */
+  /* no 'load' without sandboxing it */
+  /* no 'loadstring' without sandboxing it */
   {"next", luaB_next},
   {"pcall", luaB_pcall},
   {"print", luaB_print},
diff --git a/src/lstrlib.c b/src/lstrlib.c
index 7a03489..8ac753d 100644
--- a/src/lstrlib.c
+++ b/src/lstrlib.c
@@ -137,25 +137,6 @@ static int str_char (lua_State *L) {
 }
 
 
-static int writer (lua_State *L, const void* b, size_t size, void* B) {
-  (void)L;
-  luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
-  return 0;
-}
-
-
-static int str_dump (lua_State *L) {
-  luaL_Buffer b;
-  luaL_checktype(L, 1, LUA_TFUNCTION);
-  lua_settop(L, 1);
-  luaL_buffinit(L,&b);
-  if (lua_dump(L, writer, &b) != 0)
-    luaL_error(L, "unable to dump given function");
-  luaL_pushresult(&b);
-  return 1;
-}
-
-
 
 /*
 ** {======================================================
@@ -827,7 +808,7 @@ static int str_format (lua_State *L) {
 static const luaL_Reg strlib[] = {
   {"byte", str_byte},
   {"char", str_char},
-  {"dump", str_dump},
+  /* no 'dump' without sandboxing 'loadstring', etc. */
   {"find", str_find},
   {"format", str_format},
   {"gfind", gfind_nodef},