RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm-5_0: rpm/ CHANGES rpm/rpmio/ macro.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Mon 21 Jan 2008 - 18:32:03 CET
Message-Id: <20080121173203.EE2E3348464@rpm5.org>
  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 18:32:03
  Branch: rpm-5_0                          Handle: 2008012117320300

  Modified files:           (Branch: rpm-5_0)
    rpm                     CHANGES
    rpm/rpmio               macro.c

  Log:
    - fix: permit %{lua:...} to recurse.

  Summary:
    Revision    Changes     Path
    1.2054.2.13 +1  -0      rpm/CHANGES
    2.171.2.2   +17 -3      rpm/rpmio/macro.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2054.2.12 -r1.2054.2.13 CHANGES
  --- rpm/CHANGES	18 Jan 2008 17:40:12 -0000	1.2054.2.12
  +++ rpm/CHANGES	21 Jan 2008 17:32:03 -0000	1.2054.2.13
  @@ -1,4 +1,5 @@
   5.0.0 -> 5.0.1:
  +    - jbj: fix: permit %{lua:...} to recurse.
       - jbj: unbreak rpm-python, preserve existing symbol in released versions.
       - jbj: fix several typos noticed by the translation project.
       - proyvind: Rename rpmcliImportPubkey() -> rpmtsImportPubkey() (from and for a hint of rpm.org API compatibility;)
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/macro.c
  ============================================================================
  $ cvs diff -u -r2.171.2.1 -r2.171.2.2 macro.c
  --- rpm/rpmio/macro.c	15 Jan 2008 14:19:19 -0000	2.171.2.1
  +++ rpm/rpmio/macro.c	21 Jan 2008 17:32:03 -0000	2.171.2.2
  @@ -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 18:32:04 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.