counter for gsub only when there is a table (to keep full compatibility)

This commit is contained in:
Roberto Ierusalimschy 1997-06-19 15:49:40 -03:00
parent 6bb2cac3db
commit c8897f2b08
1 changed files with 4 additions and 3 deletions

View File

@ -3,7 +3,7 @@
** String library to LUA ** String library to LUA
*/ */
char *rcs_strlib="$Id: strlib.c,v 1.44 1997/06/18 21:20:45 roberto Exp roberto $"; char *rcs_strlib="$Id: strlib.c,v 1.45 1997/06/19 17:45:28 roberto Exp roberto $";
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -390,10 +390,11 @@ static void add_s (lua_Object newp, lua_Object table, int n)
struct lbuff oldbuff; struct lbuff oldbuff;
int status; int status;
lua_beginblock(); lua_beginblock();
if (lua_istable(table)) if (lua_istable(table)) {
lua_pushobject(table); lua_pushobject(table);
lua_pushnumber(n);
}
push_captures(); push_captures();
lua_pushnumber(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;