diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-09-24 14:31:06 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-09-24 14:31:06 -0300 |
commit | 03cde80b58ea7f112f1b7a35c037893093b59f2e (patch) | |
tree | d92d64bca2b0ebe3e026fbf7955bf080db17e480 | |
parent | 6b2e202df55f3d1f3c670eab65981db6e125c758 (diff) | |
download | lua-03cde80b58ea7f112f1b7a35c037893093b59f2e.tar.gz lua-03cde80b58ea7f112f1b7a35c037893093b59f2e.tar.bz2 lua-03cde80b58ea7f112f1b7a35c037893093b59f2e.zip |
'setCstacklimit' renamed to 'setcstacklimit'
Function names in the API use only lowercase letters.
-rw-r--r-- | ldblib.c | 6 | ||||
-rw-r--r-- | lstate.c | 2 | ||||
-rw-r--r-- | lua.h | 2 | ||||
-rw-r--r-- | manual/manual.of | 12 | ||||
-rw-r--r-- | testes/cstack.lua | 24 |
5 files changed, 23 insertions, 23 deletions
@@ -437,9 +437,9 @@ static int db_traceback (lua_State *L) { | |||
437 | } | 437 | } |
438 | 438 | ||
439 | 439 | ||
440 | static int db_setCstacklimit (lua_State *L) { | 440 | static int db_setcstacklimit (lua_State *L) { |
441 | int limit = (int)luaL_checkinteger(L, 1); | 441 | int limit = (int)luaL_checkinteger(L, 1); |
442 | int res = lua_setCstacklimit(L, limit); | 442 | int res = lua_setcstacklimit(L, limit); |
443 | if (res == 0) | 443 | if (res == 0) |
444 | lua_pushboolean(L, 0); | 444 | lua_pushboolean(L, 0); |
445 | else | 445 | else |
@@ -465,7 +465,7 @@ static const luaL_Reg dblib[] = { | |||
465 | {"setmetatable", db_setmetatable}, | 465 | {"setmetatable", db_setmetatable}, |
466 | {"setupvalue", db_setupvalue}, | 466 | {"setupvalue", db_setupvalue}, |
467 | {"traceback", db_traceback}, | 467 | {"traceback", db_traceback}, |
468 | {"setCstacklimit", db_setCstacklimit}, | 468 | {"setcstacklimit", db_setcstacklimit}, |
469 | {NULL, NULL} | 469 | {NULL, NULL} |
470 | }; | 470 | }; |
471 | 471 | ||
@@ -96,7 +96,7 @@ void luaE_setdebt (global_State *g, l_mem debt) { | |||
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | LUA_API int lua_setCstacklimit (lua_State *L, unsigned int limit) { | 99 | LUA_API int lua_setcstacklimit (lua_State *L, unsigned int limit) { |
100 | global_State *g = G(L); | 100 | global_State *g = G(L); |
101 | int ccalls; | 101 | int ccalls; |
102 | luaE_freeCI(L); /* release unused CIs */ | 102 | luaE_freeCI(L); /* release unused CIs */ |
@@ -462,7 +462,7 @@ LUA_API lua_Hook (lua_gethook) (lua_State *L); | |||
462 | LUA_API int (lua_gethookmask) (lua_State *L); | 462 | LUA_API int (lua_gethookmask) (lua_State *L); |
463 | LUA_API int (lua_gethookcount) (lua_State *L); | 463 | LUA_API int (lua_gethookcount) (lua_State *L); |
464 | 464 | ||
465 | LUA_API int (lua_setCstacklimit) (lua_State *L, unsigned int limit); | 465 | LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit); |
466 | 466 | ||
467 | struct lua_Debug { | 467 | struct lua_Debug { |
468 | int event; | 468 | int event; |
diff --git a/manual/manual.of b/manual/manual.of index 292d1e51..cca4ca08 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -4814,7 +4814,7 @@ calling @Lid{lua_yield} with @id{nresults} equal to zero | |||
4814 | 4814 | ||
4815 | } | 4815 | } |
4816 | 4816 | ||
4817 | @APIEntry{int (lua_setCstacklimit) (lua_State *L, unsigned int limit);| | 4817 | @APIEntry{int (lua_setcstacklimit) (lua_State *L, unsigned int limit);| |
4818 | @apii{0,0,-} | 4818 | @apii{0,0,-} |
4819 | 4819 | ||
4820 | Sets a new limit for the C stack. | 4820 | Sets a new limit for the C stack. |
@@ -4823,7 +4823,7 @@ with the intent of avoiding a stack overflow. | |||
4823 | Returns the old limit in case of success, | 4823 | Returns the old limit in case of success, |
4824 | or zero in case of error. | 4824 | or zero in case of error. |
4825 | For more details about this function, | 4825 | For more details about this function, |
4826 | see @Lid{debug.setCstacklimit}, | 4826 | see @Lid{debug.setcstacklimit}, |
4827 | its equivalent in the standard library. | 4827 | its equivalent in the standard library. |
4828 | 4828 | ||
4829 | } | 4829 | } |
@@ -8565,7 +8565,7 @@ to the userdata @id{u} plus a boolean, | |||
8565 | 8565 | ||
8566 | } | 8566 | } |
8567 | 8567 | ||
8568 | @LibEntry{debug.setCstacklimit (limit)| | 8568 | @LibEntry{debug.setcstacklimit (limit)| |
8569 | 8569 | ||
8570 | Sets a new limit for the C stack. | 8570 | Sets a new limit for the C stack. |
8571 | This limit controls how deeply nested calls can go in Lua, | 8571 | This limit controls how deeply nested calls can go in Lua, |
@@ -8586,10 +8586,10 @@ This function has the following restrictions: | |||
8586 | @item{@id{limit} must be less than 40000;} | 8586 | @item{@id{limit} must be less than 40000;} |
8587 | @item{@id{limit} cannot be less than the amount of C stack in use.} | 8587 | @item{@id{limit} cannot be less than the amount of C stack in use.} |
8588 | } | 8588 | } |
8589 | In case of success, | 8589 | If a call does not respect some restriction, |
8590 | this function returns the old limit. | ||
8591 | In case of error, | ||
8592 | it returns @false. | 8590 | it returns @false. |
8591 | Otherwise, | ||
8592 | the call returns the old limit. | ||
8593 | 8593 | ||
8594 | } | 8594 | } |
8595 | 8595 | ||
diff --git a/testes/cstack.lua b/testes/cstack.lua index 2a55ce21..486abc1d 100644 --- a/testes/cstack.lua +++ b/testes/cstack.lua | |||
@@ -8,7 +8,7 @@ print"If this test craches, see its file ('cstack.lua')" | |||
8 | 8 | ||
9 | -- Segmentation faults in these tests probably result from a C-stack | 9 | -- Segmentation faults in these tests probably result from a C-stack |
10 | -- overflow. To avoid these errors, you can use the function | 10 | -- overflow. To avoid these errors, you can use the function |
11 | -- 'debug.setCstacklimit' to set a smaller limit for the use of | 11 | -- 'debug.setcstacklimit' to set a smaller limit for the use of |
12 | -- C stack by Lua. After finding a reliable limit, you might want | 12 | -- C stack by Lua. After finding a reliable limit, you might want |
13 | -- to recompile Lua with this limit as the value for | 13 | -- to recompile Lua with this limit as the value for |
14 | -- the constant 'LUAI_MAXCCALLS', which defines the default limit. | 14 | -- the constant 'LUAI_MAXCCALLS', which defines the default limit. |
@@ -19,12 +19,12 @@ print"If this test craches, see its file ('cstack.lua')" | |||
19 | -- higher than 2_000. | 19 | -- higher than 2_000. |
20 | 20 | ||
21 | 21 | ||
22 | local origlimit = debug.setCstacklimit(400) | 22 | local origlimit = debug.setcstacklimit(400) |
23 | print("default stack limit: " .. origlimit) | 23 | print("default stack limit: " .. origlimit) |
24 | 24 | ||
25 | -- change this value for different limits for this test suite | 25 | -- change this value for different limits for this test suite |
26 | local currentlimit = origlimit | 26 | local currentlimit = origlimit |
27 | debug.setCstacklimit(currentlimit) | 27 | debug.setcstacklimit(currentlimit) |
28 | print("current stack limit: " .. currentlimit) | 28 | print("current stack limit: " .. currentlimit) |
29 | 29 | ||
30 | 30 | ||
@@ -102,10 +102,10 @@ end | |||
102 | 102 | ||
103 | do print("testing changes in C-stack limit") | 103 | do print("testing changes in C-stack limit") |
104 | 104 | ||
105 | assert(not debug.setCstacklimit(0)) -- limit too small | 105 | assert(not debug.setcstacklimit(0)) -- limit too small |
106 | assert(not debug.setCstacklimit(50000)) -- limit too large | 106 | assert(not debug.setcstacklimit(50000)) -- limit too large |
107 | local co = coroutine.wrap (function () | 107 | local co = coroutine.wrap (function () |
108 | return debug.setCstacklimit(400) | 108 | return debug.setcstacklimit(400) |
109 | end) | 109 | end) |
110 | assert(co() == false) -- cannot change C stack inside coroutine | 110 | assert(co() == false) -- cannot change C stack inside coroutine |
111 | 111 | ||
@@ -118,26 +118,26 @@ do print("testing changes in C-stack limit") | |||
118 | return n | 118 | return n |
119 | end | 119 | end |
120 | 120 | ||
121 | assert(debug.setCstacklimit(400) == currentlimit) | 121 | assert(debug.setcstacklimit(400) == currentlimit) |
122 | local lim400 = check() | 122 | local lim400 = check() |
123 | -- a very low limit (given that the several calls to arive here) | 123 | -- a very low limit (given that the several calls to arive here) |
124 | local lowlimit = 38 | 124 | local lowlimit = 38 |
125 | assert(debug.setCstacklimit(lowlimit) == 400) | 125 | assert(debug.setcstacklimit(lowlimit) == 400) |
126 | assert(check() < lowlimit - 30) | 126 | assert(check() < lowlimit - 30) |
127 | assert(debug.setCstacklimit(600) == lowlimit) | 127 | assert(debug.setcstacklimit(600) == lowlimit) |
128 | local lim600 = check() | 128 | local lim600 = check() |
129 | assert(lim600 == lim400 + 200) | 129 | assert(lim600 == lim400 + 200) |
130 | 130 | ||
131 | 131 | ||
132 | -- 'setCstacklimit' works inside protected calls. (The new stack | 132 | -- 'setcstacklimit' works inside protected calls. (The new stack |
133 | -- limit is kept when 'pcall' returns.) | 133 | -- limit is kept when 'pcall' returns.) |
134 | assert(pcall(function () | 134 | assert(pcall(function () |
135 | assert(debug.setCstacklimit(400) == 600) | 135 | assert(debug.setcstacklimit(400) == 600) |
136 | assert(check() <= lim400) | 136 | assert(check() <= lim400) |
137 | end)) | 137 | end)) |
138 | 138 | ||
139 | assert(check() == lim400) | 139 | assert(check() == lim400) |
140 | assert(debug.setCstacklimit(origlimit) == 400) -- restore original limit | 140 | assert(debug.setcstacklimit(origlimit) == 400) -- restore original limit |
141 | end | 141 | end |
142 | 142 | ||
143 | 143 | ||