add expand_macro
authorcturner <devnull@localhost>
Sun, 9 Mar 2003 17:53:35 +0000 (17:53 +0000)
committercturner <devnull@localhost>
Sun, 9 Mar 2003 17:53:35 +0000 (17:53 +0000)
CVS patchset: 6668
CVS date: 2003/03/09 17:53:35

perl-RPM2/RPM2.xs
perl-RPM2/test.pl

index b05c033..83ca883 100644 (file)
@@ -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
index 24c6a66..c3c7b4b 100644 (file)
@@ -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");