aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-19 14:45:28 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-19 14:45:28 -0300
commitb6adfdd01be0e436e9627a1d712ff8e0d53a244d (patch)
tree5aa723b7edd85dc93deb3703f8ba27ef6805a03d
parentb90b4bbd3aaa287b53663d0892d0ff85fe04b812 (diff)
downloadlua-b6adfdd01be0e436e9627a1d712ff8e0d53a244d.tar.gz
lua-b6adfdd01be0e436e9627a1d712ff8e0d53a244d.tar.bz2
lua-b6adfdd01be0e436e9627a1d712ff8e0d53a244d.zip
gsub aborts if error occurs.
-rw-r--r--strlib.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/strlib.c b/strlib.c
index d34268b7..974fdb2e 100644
--- a/strlib.c
+++ b/strlib.c
@@ -3,7 +3,7 @@
3** String library to LUA 3** String library to LUA
4*/ 4*/
5 5
6char *rcs_strlib="$Id: strlib.c,v 1.43 1997/06/18 20:15:47 roberto Exp roberto $"; 6char *rcs_strlib="$Id: strlib.c,v 1.44 1997/06/18 21:20:45 roberto Exp roberto $";
7 7
8#include <string.h> 8#include <string.h>
9#include <stdio.h> 9#include <stdio.h>
@@ -388,6 +388,7 @@ static void add_s (lua_Object newp, lua_Object table, int n)
388 else if (lua_isfunction(newp)) { 388 else if (lua_isfunction(newp)) {
389 lua_Object res; 389 lua_Object res;
390 struct lbuff oldbuff; 390 struct lbuff oldbuff;
391 int status;
391 lua_beginblock(); 392 lua_beginblock();
392 if (lua_istable(table)) 393 if (lua_istable(table))
393 lua_pushobject(table); 394 lua_pushobject(table);
@@ -396,10 +397,12 @@ static void add_s (lua_Object newp, lua_Object table, int n)
396 /* function may use lbuffer, so save it and create a new one */ 397 /* function may use lbuffer, so save it and create a new one */
397 oldbuff = lbuffer; 398 oldbuff = lbuffer;
398 lbuffer.b = NULL; lbuffer.max = lbuffer.size = 0; 399 lbuffer.b = NULL; lbuffer.max = lbuffer.size = 0;
399 lua_callfunction(newp); 400 status = lua_callfunction(newp);
400 /* restore old buffer */ 401 /* restore old buffer */
401 free(lbuffer.b); 402 free(lbuffer.b);
402 lbuffer = oldbuff; 403 lbuffer = oldbuff;
404 if (status != 0)
405 lua_error(NULL);
403 res = lua_getresult(1); 406 res = lua_getresult(1);
404 addstr(lua_isstring(res) ? lua_getstring(res) : ""); 407 addstr(lua_isstring(res) ? lua_getstring(res) : "");
405 lua_endblock(); 408 lua_endblock();