mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
gsub aborts if error occurs.
This commit is contained in:
parent
b90b4bbd3a
commit
b6adfdd01b
7
strlib.c
7
strlib.c
@ -3,7 +3,7 @@
|
|||||||
** String library to LUA
|
** String library to LUA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_strlib="$Id: strlib.c,v 1.43 1997/06/18 20:15:47 roberto Exp roberto $";
|
char *rcs_strlib="$Id: strlib.c,v 1.44 1997/06/18 21:20:45 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -388,6 +388,7 @@ static void add_s (lua_Object newp, lua_Object table, int n)
|
|||||||
else if (lua_isfunction(newp)) {
|
else if (lua_isfunction(newp)) {
|
||||||
lua_Object res;
|
lua_Object res;
|
||||||
struct lbuff oldbuff;
|
struct lbuff oldbuff;
|
||||||
|
int status;
|
||||||
lua_beginblock();
|
lua_beginblock();
|
||||||
if (lua_istable(table))
|
if (lua_istable(table))
|
||||||
lua_pushobject(table);
|
lua_pushobject(table);
|
||||||
@ -396,10 +397,12 @@ static void add_s (lua_Object newp, lua_Object table, int n)
|
|||||||
/* function may use lbuffer, so save it and create a new one */
|
/* function may use lbuffer, so save it and create a new one */
|
||||||
oldbuff = lbuffer;
|
oldbuff = lbuffer;
|
||||||
lbuffer.b = NULL; lbuffer.max = lbuffer.size = 0;
|
lbuffer.b = NULL; lbuffer.max = lbuffer.size = 0;
|
||||||
lua_callfunction(newp);
|
status = lua_callfunction(newp);
|
||||||
/* restore old buffer */
|
/* restore old buffer */
|
||||||
free(lbuffer.b);
|
free(lbuffer.b);
|
||||||
lbuffer = oldbuff;
|
lbuffer = oldbuff;
|
||||||
|
if (status != 0)
|
||||||
|
lua_error(NULL);
|
||||||
res = lua_getresult(1);
|
res = lua_getresult(1);
|
||||||
addstr(lua_isstring(res) ? lua_getstring(res) : "");
|
addstr(lua_isstring(res) ? lua_getstring(res) : "");
|
||||||
lua_endblock();
|
lua_endblock();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user