RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 21-Jan-2008 17:47:03
Branch: HEAD Handle: 2008012116470201
Modified files:
rpm CHANGES
rpm/rpmio macro.c
Log:
- jbj: fix: permit %{lua:...} to recurse.
Summary:
Revision Changes Path
1.2086 +1 -0 rpm/CHANGES
2.177 +17 -3 rpm/rpmio/macro.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2085 -r1.2086 CHANGES
--- rpm/CHANGES 21 Jan 2008 15:32:53 -0000 1.2085
+++ rpm/CHANGES 21 Jan 2008 16:47:02 -0000 1.2086
@@ -1,4 +1,5 @@
5.0.0 -> 5.1a1:
+ - jbj: fix: permit %{lua:...} to recurse.
- rse: allow to compile without <langinfo.h> and its nl_langinfo(3)
- rse: provide RPM Lua function posix.glob(<pattern>)
- rse: make older C compiler happy by not declaring a variable in the middle of a block in rpmconstant/constant.c
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/macro.c
============================================================================
$ cvs diff -u -r2.176 -r2.177 macro.c
--- rpm/rpmio/macro.c 20 Jan 2008 10:13:00 -0000 2.176
+++ rpm/rpmio/macro.c 21 Jan 2008 16:47:03 -0000 2.177
@@ -61,6 +61,7 @@
#include <rpmlog.h>
#ifdef WITH_LUA
+#define _RPMLUA_INTERNAL /* XXX lua->printbuf access */
#include <rpmlua.h>
#endif
@@ -1548,14 +1549,21 @@
#ifdef WITH_LUA
if (STREQ("lua", f, fn)) {
- rpmlua lua = NULL; /* Global state. */
+ rpmlua lua = rpmluaGetGlobalState();
+ rpmlua olua = memcpy(alloca(sizeof(*olua)), lua, sizeof(*olua));
const char *ls = s+sizeof("{lua:")-1;
const char *lse = se-sizeof("}")+1;
char *scriptbuf = (char *)xmalloc((lse-ls)+1);
const char *printbuf;
+
+ /* Reset the stateful output buffer bfore recursing down. */
+ lua->storeprint = 1;
+ lua->printbuf = NULL;
+ lua->printbufsize = 0;
+ lua->printbufused = 0;
+
memcpy(scriptbuf, ls, lse-ls);
scriptbuf[lse-ls] = '\0';
- rpmluaSetPrintBuffer(lua, 1);
if (rpmluaRunScript(lua, scriptbuf, NULL) == -1)
rc = 1;
printbuf = rpmluaGetPrintBuffer(lua);
@@ -1567,7 +1575,13 @@
mb->t += len;
mb->nb -= len;
}
- rpmluaSetPrintBuffer(lua, 0);
+
+ /* Restore the stateful output buffer after recursion. */
+ lua->storeprint = olua->storeprint;
+ lua->printbuf = olua->printbuf;
+ lua->printbufsize = olua->printbufsize;
+ lua->printbufused = olua->printbufused;
+
free(scriptbuf);
s = se;
continue;
@@ .
Received on Mon Jan 21 17:47:03 2008