aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2013-01-29 17:55:42 +0000
committerThierry Vignaud <tv@mageia.org>2013-01-29 17:55:42 +0000
commitdeab9f7e2e2c1f07a24fe2b8fe05e377e7d21736 (patch)
tree1541e736141baa38dc5d68fd9b1d1130826d3316
parent4f3c5fb048666aeda7294cae8dabafa82f63f222 (diff)
downloadperl-URPM-deab9f7e2e2c1f07a24fe2b8fe05e377e7d21736.tar
perl-URPM-deab9f7e2e2c1f07a24fe2b8fe05e377e7d21736.tar.gz
perl-URPM-deab9f7e2e2c1f07a24fe2b8fe05e377e7d21736.tar.bz2
perl-URPM-deab9f7e2e2c1f07a24fe2b8fe05e377e7d21736.tar.xz
perl-URPM-deab9f7e2e2c1f07a24fe2b8fe05e377e7d21736.zip
(return_list_tag) simplify/factorize
-rw-r--r--URPM.xs23
1 files changed, 12 insertions, 11 deletions
diff --git a/URPM.xs b/URPM.xs
index 624c6f1..cc19f3d 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -543,31 +543,28 @@ return_list_tag(const URPM__Package pkg, rpmTag tag_name) {
}
}
} else {
- char *name;
- char *version;
- char *release;
- char *arch;
- char *eos;
+ char *name, *version, *release, *arch, *eos, *data = NULL;
+ int len;
switch (tag_name) {
case RPMTAG_NAME:
{
get_fullname_parts(pkg, &name, &version, &release, &arch, &eos);
- if (version - name < 1) croak("invalid fullname");
- mXPUSHs(newSVpv(name, version-name - 1));
+ data = name;
+ len = version-name;
}
break;
case RPMTAG_VERSION:
{
get_fullname_parts(pkg, &name, &version, &release, &arch, &eos);
- if (release - version < 1) croak("invalid fullname");
- mXPUSHs(newSVpv(version, release-version - 1));
+ data = version;
+ len = release-version;
}
break;
case RPMTAG_RELEASE:
{
get_fullname_parts(pkg, &name, &version, &release, &arch, &eos);
- if (arch - release < 1) croak("invalid fullname");
- mXPUSHs(newSVpv(release, arch-release - 1));
+ data = release;
+ len = arch-release;
}
break;
case RPMTAG_ARCH:
@@ -583,6 +580,10 @@ return_list_tag(const URPM__Package pkg, rpmTag tag_name) {
croak("unexpected tag %s", tag_name);
break;
}
+ if (data) {
+ if (len < 1) croak("invalid fullname");
+ mXPUSHs(newSVpv(data, len - 1));
+ }
}
PUTBACK;
}