Skip to content

Commit 0c16a42

Browse files
committed
Details
Added compiler option LUA_NODEBUGLIB to make Lua with no open debug library + small improvements in the manual.
1 parent d0bd25d commit 0c16a42

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

lua.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,13 @@ static void doREPL (lua_State *L) {
714714
/* }================================================================== */
715715

716716
#if !defined(luai_openlibs)
717-
#define luai_openlibs(L) luaL_openselectedlibs(L, ~0, 0)
717+
#if defined(LUA_NODEBUGLIB)
718+
/* With this option, code must require the debug library before using it */
719+
#define luai_openlibs(L) luaL_openselectedlibs(L, ~LUA_DBLIBK, LUA_DBLIBK)
720+
#else
721+
/* The default is to open all standard libraries */
722+
#define luai_openlibs(L) luaL_openselectedlibs(L, ~0, 0)
723+
#endif
718724
#endif
719725

720726

manual/manual.of

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3962,8 +3962,8 @@ this confuses the next call to @Lid{lua_next}.
39623962

39633963
This function may raise an error if the given key
39643964
is neither @nil nor present in the table.
3965-
See function @Lid{next} for the caveats of modifying
3966-
the table during its traversal.
3965+
3966+
See function @Lid{next} for more details about the traversal.
39673967

39683968
}
39693969

@@ -4448,7 +4448,7 @@ Starts and resumes a coroutine in the given thread @id{L}.
44484448
To start a coroutine,
44494449
you push the main function plus any arguments
44504450
onto the empty stack of the thread.
4451-
then you call @Lid{lua_resume},
4451+
Then you call @Lid{lua_resume},
44524452
with @id{nargs} being the number of arguments.
44534453
The function returns when the coroutine suspends,
44544454
finishes its execution, or raises an unprotected error.
@@ -4628,7 +4628,7 @@ You can resume threads with status @Lid{LUA_OK}
46284628
}
46294629

46304630
@APIEntry{size_t lua_stringtonumber (lua_State *L, const char *s);|
4631-
@apii{0,1,-}
4631+
@apii{0,0|1,-}
46324632

46334633
Converts the zero-terminated string @id{s} to a number,
46344634
pushes that number into the stack,
@@ -4958,7 +4958,7 @@ Lua calls the given @x{continuation function} @id{k} to continue
49584958
the execution of the @N{C function} that yielded @see{continuations}.
49594959
This continuation function receives the same stack
49604960
from the previous function,
4961-
with the @id{n} results removed and
4961+
with all the results (@id{nresults}) removed and
49624962
replaced by the arguments passed to @Lid{lua_resume}.
49634963
Moreover,
49644964
the continuation function receives the value @id{ctx}
@@ -5048,7 +5048,7 @@ the function was defined in a string where
50485048
}
50495049

50505050
@item{@id{srclen}|
5051-
The length of the string @id{source}.
5051+
the length of the string @id{source}.
50525052
}
50535053

50545054
@item{@id{short_src}|
@@ -5212,7 +5212,7 @@ running at the given level;
52125212
}
52135213

52145214
@item{@Char{S}|
5215-
fills in the fields @id{source}, @id{short_src},
5215+
fills in the fields @id{source}, @id{srclen}, @id{short_src},
52165216
@id{linedefined}, @id{lastlinedefined}, and @id{what};
52175217
}
52185218

@@ -5388,7 +5388,9 @@ Returns @id{NULL} (and pops nothing)
53885388
when the index is greater than
53895389
the number of active local variables.
53905390

5391-
Parameters @id{ar} and @id{n} are as in the function @Lid{lua_getlocal}.
5391+
Parameters @id{ar} and @id{n} are as in the function @Lid{lua_getlocal},
5392+
except that @id{ar} cannot be @id{NULL},
5393+
as @id{lua_setlocal} only operates on activation records.
53925394

53935395
}
53945396

@@ -6832,8 +6834,7 @@ for k,v in pairs(t) do @rep{body} end
68326834
}
68336835
will iterate over all key@En{}value pairs of table @id{t}.
68346836

6835-
See function @Lid{next} for the caveats of modifying
6836-
the table during its traversal.
6837+
See function @Lid{next} for more details about the traversal.
68376838

68386839
}
68396840

@@ -9123,6 +9124,7 @@ which automatically removes the file when the program ends.
91239124

91249125
This library provides
91259126
the functionality of the @link{debugI|debug interface} to Lua programs.
9127+
91269128
You should exert care when using this library.
91279129
Several of its functions
91289130
violate basic assumptions about Lua code
@@ -9132,6 +9134,8 @@ that userdata metatables cannot be changed by Lua code;
91329134
that Lua programs do not crash)
91339135
and therefore can compromise otherwise secure code.
91349136
Moreover, some functions in this library may be slow.
9137+
It is good practice to always require this library explicitly
9138+
before using it.
91359139

91369140
All functions in this library are provided
91379141
inside the @defid{debug} table.

0 commit comments

Comments
 (0)