aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-06-18 17:20:40 +0000
committerThierry Vignaud <tv@mageia.org>2012-06-18 17:20:40 +0000
commit9465024cfe24c271496e481e64f0fb06f6c0cfb1 (patch)
treec83d8adc3adfd3d1cfc8abfeab761a53fd65b298
parentf1112e1809236c33d9dcf1f4fd60b77fbaa5435c (diff)
downloadperl-URPM-9465024cfe24c271496e481e64f0fb06f6c0cfb1.tar
perl-URPM-9465024cfe24c271496e481e64f0fb06f6c0cfb1.tar.gz
perl-URPM-9465024cfe24c271496e481e64f0fb06f6c0cfb1.tar.bz2
perl-URPM-9465024cfe24c271496e481e64f0fb06f6c0cfb1.tar.xz
perl-URPM-9465024cfe24c271496e481e64f0fb06f6c0cfb1.zip
(push_rflags) factorize code
-rw-r--r--URPM.xs33
1 files changed, 15 insertions, 18 deletions
diff --git a/URPM.xs b/URPM.xs
index 9be7186..5b61c4c 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -1374,6 +1374,19 @@ rpmtag_from_string(char *tag)
else croak("unknown tag [%s]", tag);
}
+static void push_rflags(URPM__Package pkg, int gimme) {
+ dSP;
+ if (gimme == G_ARRAY && pkg->rflags != NULL) {
+ char *s = pkg->rflags;
+ char *eos;
+ while ((eos = strchr(s, '\t')) != NULL) {
+ mXPUSHs(newSVpv(s, eos-s));
+ s = eos + 1;
+ }
+ mXPUSHs(newSVpv(s, 0));
+ }
+}
+
MODULE = URPM PACKAGE = URPM::Package PREFIX = Pkg_
void
@@ -2355,15 +2368,7 @@ Pkg_rflags(pkg)
PREINIT:
I32 gimme = GIMME_V;
PPCODE:
- if (gimme == G_ARRAY && pkg->rflags != NULL) {
- char *s = pkg->rflags;
- char *eos;
- while ((eos = strchr(s, '\t')) != NULL) {
- mXPUSHs(newSVpv(s, eos-s));
- s = eos + 1;
- }
- mXPUSHs(newSVpv(s, 0));
- }
+ push_rflags(pkg, gimme);
void
Pkg_set_rflags(pkg, ...)
@@ -2389,15 +2394,7 @@ Pkg_set_rflags(pkg, ...)
}
new_rflags[total_len - 1] = 0; /* but mark end-of-string correctly */
- if (gimme == G_ARRAY && pkg->rflags != NULL) {
- char *s = pkg->rflags;
- char *eos;
- while ((eos = strchr(s, '\t')) != NULL) {
- mXPUSHs(newSVpv(s, eos-s));
- s = eos + 1;
- }
- mXPUSHs(newSVpv(s, 0));
- }
+ push_rflags(pkg, gimme);
free(pkg->rflags);
pkg->rflags = new_rflags;