Nothing wrong w the patch.
What has been unclear is whether lua <-> macros should
provide a configuration name space and store.
E.g. you are choosing to do bindings onto a macro store.
The alternative implementation is to rewrite macro methods
on top of a lua store.
Either way "works", there''s no clear basis for changing.
73 de Jeff
On Dec 24, 2007, at 4:00 AM, Ralf S. Engelschall wrote:
> RPM Package Manager, CVS Repository
> http://rpm5.org/cvs/
>
> ____________________________________________________________________________
>
> Server: rpm5.org Name: Ralf S. Engelschall
> Root: /v/rpm/cvs Email: rse@rpm5.org
> Module: rpm Date: 24-Dec-2007 10:00:08
> Branch: HEAD Handle: 2007122409000601
>
> Modified files:
> rpm CHANGES
> rpm/rpmio macro.c rpmlua.c rpmmacro.h
>
> Log:
> - provide RPM Lua function rpm.undefine() based on the C function
> rpmUndefineMacro
> - provide rpmUndefineMacro API function to complement the
> existing rpmDefineMacro API function
>
> Summary:
> Revision Changes Path
> 1.2012 +2 -0 rpm/CHANGES
> 2.160 +9 -0 rpm/rpmio/macro.c
> 2.31 +10 -0 rpm/rpmio/rpmlua.c
> 2.45 +10 -0 rpm/rpmio/rpmmacro.h
>
> ____________________________________________________________________________
>
> patch -p0 <<'@@ .'
> Index: rpm/CHANGES
>
> =
> =
> =
> =
> =
> =
> ======================================================================
> $ cvs diff -u -r1.2011 -r1.2012 CHANGES
> --- rpm/CHANGES 23 Dec 2007 22:50:05 -0000 1.2011
> +++ rpm/CHANGES 24 Dec 2007 09:00:06 -0000 1.2012
> @@ -1,4 +1,6 @@
> 5.0b3 -> 5.0b4:
> + - rse: provide RPM Lua function rpm.undefine() based on the C
> function rpmUndefineMacro
> + - rse: provide rpmUndefineMacro API function to complement the
> existing rpmDefineMacro API function
> - rse: add scripts/lua-dump.lua, a recursive dumper for Lua
> data structures
> - rse: fix parsing of the table key in RPM Lua function
> rpm.macros()
> - rse: add an RPM Lua function rpm.load() for loading external
> Lua scripts
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmio/macro.c
>
> =
> =
> =
> =
> =
> =
> ======================================================================
> $ cvs diff -u -r2.159 -r2.160 macro.c
> --- rpm/rpmio/macro.c 16 Dec 2007 22:54:40 -0000 2.159
> +++ rpm/rpmio/macro.c 24 Dec 2007 09:00:07 -0000 2.160
> @@ -2061,6 +2061,15 @@
> }
> /*@=mustmod@*/
>
> +/*@-mustmod@*/ /* LCL: mc is modified through mb->mc, mb is
> abstract */
> +int
> +rpmUndefineMacro(MacroContext mc, const char * macro)
> +{
> + (void) doUndefine(mc ? mc : rpmGlobalMacroContext, macro);
> + return 0;
> +}
> +/*@=mustmod@*/
> +
> void
> rpmLoadMacros(MacroContext mc, int level)
> {
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmio/rpmlua.c
>
> =
> =
> =
> =
> =
> =
> ======================================================================
> $ cvs diff -u -r2.30 -r2.31 rpmlua.c
> --- rpm/rpmio/rpmlua.c 23 Dec 2007 22:46:00 -0000 2.30
> +++ rpm/rpmio/rpmlua.c 24 Dec 2007 09:00:07 -0000 2.31
> @@ -696,6 +696,15 @@
> return 0;
> }
>
> +static int rpm_undefine(lua_State *L)
> + /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
> + /*@modifies L, rpmGlobalMacroContext, internalState @*/
> +{
> + const char *str = luaL_checkstring(L, 1);
> + (void) rpmUndefineMacro(NULL, str);
> + return 0;
> +}
> +
> static int rpm_interactive(lua_State *L)
> /*@globals fileSystem @*/
> /*@modifies L, fileSystem @*/
> @@ -918,6 +927,7 @@
> {"macros", rpm_macros},
> {"expand", rpm_expand},
> {"define", rpm_define},
> + {"undefine", rpm_undefine},
> {"register", rpm_register},
> {"unregister", rpm_unregister},
> {"call", rpm_call},
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmio/rpmmacro.h
>
> =
> =
> =
> =
> =
> =
> ======================================================================
> $ cvs diff -u -r2.44 -r2.45 rpmmacro.h
> --- rpm/rpmio/rpmmacro.h 18 Dec 2007 13:02:08 -0000 2.44
> +++ rpm/rpmio/rpmmacro.h 24 Dec 2007 09:00:07 -0000 2.45
> @@ -148,6 +148,16 @@
> /*@modifies mc, rpmGlobalMacroContext, internalState @*/;
>
> /**
> + * Undefine macro in context.
> + * @param mc macro context (NULL uses global context).
> + * @param macro macro name
> + * @return @todo Document.
> + */
> +int rpmUndefineMacro(/*@null@*/ MacroContext mc, const char * macro)
> + /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
> + /*@modifies mc, rpmGlobalMacroContext, internalState @*/;
> +
> +/**
> * Load macros from specific context into global context.
> * @param mc macro context (NULL does nothing).
> * @param level macro recursion level (0 is entry API)
> @@ .
> ______________________________________________________________________
> RPM Package Manager http://rpm5.org
> CVS Sources Repository rpm-cvs@rpm5.org
Received on Tue Dec 25 01:38:49 2007