diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-06-19 14:45:28 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-06-19 14:45:28 -0300 |
commit | b6adfdd01be0e436e9627a1d712ff8e0d53a244d (patch) | |
tree | 5aa723b7edd85dc93deb3703f8ba27ef6805a03d | |
parent | b90b4bbd3aaa287b53663d0892d0ff85fe04b812 (diff) | |
download | lua-github-b6adfdd01be0e436e9627a1d712ff8e0d53a244d.tar.gz |
gsub aborts if error occurs.
-rw-r--r-- | strlib.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -3,7 +3,7 @@ ** 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 <stdio.h> @@ -388,6 +388,7 @@ static void add_s (lua_Object newp, lua_Object table, int n) else if (lua_isfunction(newp)) { lua_Object res; struct lbuff oldbuff; + int status; lua_beginblock(); if (lua_istable(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 */ oldbuff = lbuffer; lbuffer.b = NULL; lbuffer.max = lbuffer.size = 0; - lua_callfunction(newp); + status = lua_callfunction(newp); /* restore old buffer */ free(lbuffer.b); lbuffer = oldbuff; + if (status != 0) + lua_error(NULL); res = lua_getresult(1); addstr(lua_isstring(res) ? lua_getstring(res) : ""); lua_endblock(); |