From 477a3e0e3cc64d346c72a645828eda0dd75cf832 Mon Sep 17 00:00:00 2001 From: cturner Date: Sun, 9 Mar 2003 17:53:35 +0000 Subject: [PATCH] add expand_macro CVS patchset: 6668 CVS date: 2003/03/09 17:53:35 --- perl-RPM2/RPM2.xs | 11 +++++++++++ perl-RPM2/test.pl | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/perl-RPM2/RPM2.xs b/perl-RPM2/RPM2.xs index b05c03375..83ca883a2 100644 --- a/perl-RPM2/RPM2.xs +++ b/perl-RPM2/RPM2.xs @@ -49,6 +49,17 @@ delete_macro(pkg, name) CODE: delMacro(NULL, name); +void +expand_macro(pkg, str) + char * pkg + char * str + PREINIT: + char *ret; + PPCODE: + ret = rpmExpand(str, NULL); + PUSHs(sv_2mortal(newSVpv(ret, 0))); + free(ret); + int rpmvercmp(one, two) char* one diff --git a/perl-RPM2/test.pl b/perl-RPM2/test.pl index 24c6a66d9..c3c7b4b03 100644 --- a/perl-RPM2/test.pl +++ b/perl-RPM2/test.pl @@ -11,7 +11,7 @@ use strict; use Test; use strict; -BEGIN { plan tests => 30 }; +BEGIN { plan tests => 33 }; use RPM2; ok(1); # If we made it this far, we're ok. @@ -111,3 +111,8 @@ else { ok(1); } +ok(RPM2->expand_macro("%%foo") eq "%foo"); +RPM2->add_macro("rpm2_test_macro", "testval $$"); +ok(RPM2->expand_macro("%rpm2_test_macro") eq "testval $$"); +RPM2->delete_macro("rpm2_test_macro"); +ok(RPM2->expand_macro("%rpm2_test_macro") eq "%rpm2_test_macro");