diff options
author | Francois Pons <fpons@mandriva.com> | 2003-11-15 19:44:39 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2003-11-15 19:44:39 +0000 |
commit | 8bbe233e474ef694baececdb7ce4c6d10377be89 (patch) | |
tree | 02a4bc98793571f148e38e27d11232c0b654fae6 | |
parent | d4b0a478aebaa9db4a1627a3cc72f932a086b55d (diff) | |
download | perl-URPM-8bbe233e474ef694baececdb7ce4c6d10377be89.tar perl-URPM-8bbe233e474ef694baececdb7ce4c6d10377be89.tar.gz perl-URPM-8bbe233e474ef694baececdb7ce4c6d10377be89.tar.bz2 perl-URPM-8bbe233e474ef694baececdb7ce4c6d10377be89.tar.xz perl-URPM-8bbe233e474ef694baececdb7ce4c6d10377be89.zip |
fixed indentation and reworked code to be simpler
-rw-r--r-- | URPM.xs | 168 | ||||
-rw-r--r-- | URPM/Build.pm | 44 |
2 files changed, 101 insertions, 111 deletions
@@ -667,107 +667,105 @@ return_list_tag_modifier(Header header, int_32 tag_name) { char *s= buff; switch (tag_name) { case RPMTAG_FILEFLAGS: - if (list[i] & RPMFILE_CONFIG) *s++ = 'c'; - if (list[i] & RPMFILE_DOC) *s++ = 'd'; - if (list[i] & RPMFILE_GHOST) *s++ = 'g'; - if (list[i] & RPMFILE_LICENSE) *s++ = 'l'; - if (list[i] & RPMFILE_ICON) *s++ = 'i'; - if (list[i] & RPMFILE_MISSINGOK) *s++ = 'm'; - if (list[i] & RPMFILE_NOREPLACE) *s++ = 'n'; - if (list[i] & RPMFILE_SPECFILE) *s++ = 'S'; - if (list[i] & RPMFILE_README) *s++ = 'R'; - if (list[i] & RPMFILE_EXCLUDE) *s++ = 'e'; - if (list[i] & RPMFILE_UNPATCHED) *s++ = 'u'; - if (list[i] & RPMFILE_PUBKEY) *s++ = 'p'; - + if (list[i] & RPMFILE_CONFIG) *s++ = 'c'; + if (list[i] & RPMFILE_DOC) *s++ = 'd'; + if (list[i] & RPMFILE_GHOST) *s++ = 'g'; + if (list[i] & RPMFILE_LICENSE) *s++ = 'l'; + if (list[i] & RPMFILE_ICON) *s++ = 'i'; + if (list[i] & RPMFILE_MISSINGOK) *s++ = 'm'; + if (list[i] & RPMFILE_NOREPLACE) *s++ = 'n'; + if (list[i] & RPMFILE_SPECFILE) *s++ = 'S'; + if (list[i] & RPMFILE_README) *s++ = 'R'; + if (list[i] & RPMFILE_EXCLUDE) *s++ = 'e'; + if (list[i] & RPMFILE_UNPATCHED) *s++ = 'u'; + if (list[i] & RPMFILE_PUBKEY) *s++ = 'p'; break; default: return; } *s = '\0'; XPUSHs(sv_2mortal(newSVpv(buff, strlen(buff)))); - } + } PUTBACK; } void return_list_tag(Header header, int_32 tag_name) { - dSP; - if (header) { - int_32 *list = NULL; - uint_16 *list16; - int_32 count, type; - headerGetEntry(header, tag_name, &type, (void **) &list, &count); - if (list) { - if (count == 1 ) { - switch (type) { - case RPM_NULL_TYPE: - break; - case RPM_CHAR_TYPE: - XPUSHs(sv_2mortal(newSVpv((char *) list,strlen((char *) list)))); - break; - case RPM_INT8_TYPE: - break; - case RPM_INT16_TYPE: - list16 = list; - XPUSHs(sv_2mortal(newSViv(list16))); - break; - case RPM_INT32_TYPE: - XPUSHs(sv_2mortal(newSViv((int_32 *) list))); - break; + dSP; + if (header) { + int_32 *list = NULL; + uint_16 *list16; + int_32 count, type; + headerGetEntry(header, tag_name, &type, (void **) &list, &count); + if (list) { + if (count == 1 ) { + switch (type) { + case RPM_NULL_TYPE: + break; + case RPM_CHAR_TYPE: + XPUSHs(sv_2mortal(newSVpv((char *) list,strlen((char *) list)))); + break; + case RPM_INT8_TYPE: + break; + case RPM_INT16_TYPE: + list16 = list; + XPUSHs(sv_2mortal(newSViv(list16))); + break; + case RPM_INT32_TYPE: + XPUSHs(sv_2mortal(newSViv((int_32 *) list))); + break; /* - case RPM_INT64_TYPE: - break; + case RPM_INT64_TYPE: + break; */ - case RPM_STRING_TYPE: - XPUSHs(sv_2mortal(newSVpv((char *) list, strlen((char *) list)))); - - break; - case RPM_BIN_TYPE: - break; - case RPM_STRING_ARRAY_TYPE: - break; - case RPM_I18NSTRING_TYPE: - break; - } - } else { - int i; - for (i=0; i< count; i++) { - switch (type) { - case RPM_NULL_TYPE: - break; - case RPM_CHAR_TYPE: - XPUSHs(sv_2mortal(newSVpv((char *) list,strlen((char *) list)))); - break; - case RPM_INT8_TYPE: - break; - case RPM_INT16_TYPE: - list16 = list; - XPUSHs(sv_2mortal(newSViv(list16[i]))); - break; - case RPM_INT32_TYPE: - XPUSHs(sv_2mortal(newSViv((int_32 *) list[i]))); - break; + case RPM_STRING_TYPE: + XPUSHs(sv_2mortal(newSVpv((char *) list, strlen((char *) list)))); + break; + case RPM_BIN_TYPE: + break; + case RPM_STRING_ARRAY_TYPE: + break; + case RPM_I18NSTRING_TYPE: + break; + } + } else { + int i; + for (i=0; i< count; i++) { + switch (type) { + case RPM_NULL_TYPE: + break; + case RPM_CHAR_TYPE: + XPUSHs(sv_2mortal(newSVpv((char *) list,strlen((char *) list)))); + break; + case RPM_INT8_TYPE: + break; + case RPM_INT16_TYPE: + list16 = list; + XPUSHs(sv_2mortal(newSViv(list16[i]))); + break; + case RPM_INT32_TYPE: + XPUSHs(sv_2mortal(newSViv((int_32 *) list[i]))); + break; /* - case RPM_INT64_TYPE: - break; + case RPM_INT64_TYPE: + break; */ - case RPM_STRING_TYPE: - XPUSHs(sv_2mortal(newSVpv((char *) list[i], strlen((char *) list[i])))); - break; - case RPM_BIN_TYPE: - break; - case RPM_STRING_ARRAY_TYPE: - XPUSHs(sv_2mortal(newSVpv((char *) list[i],strlen((char *) list[i])))); - break; - case RPM_I18NSTRING_TYPE: - break; - } - } - } + case RPM_STRING_TYPE: + XPUSHs(sv_2mortal(newSVpv((char *) list[i], strlen((char *) list[i])))); + break; + case RPM_BIN_TYPE: + break; + case RPM_STRING_ARRAY_TYPE: + XPUSHs(sv_2mortal(newSVpv((char *) list[i],strlen((char *) list[i])))); + break; + case RPM_I18NSTRING_TYPE: + break; + } + } } - } - PUTBACK; + } + } + PUTBACK; } diff --git a/URPM/Build.pm b/URPM/Build.pm index 797d5f0..02e5866 100644 --- a/URPM/Build.pm +++ b/URPM/Build.pm @@ -48,14 +48,14 @@ sub parse_rpms_build_headers { $filename = $cache{$key}{file}; } else { ($id, undef) = $urpm->parse_rpm($_); - defined $id or do { - if ($options{dontdie}) { - print STDERR "bad rpm $_\n"; - next; - } else { - die "bad rpm $_\n"; - } - }; + unless (defined $id) { + if ($options{dontdie}) { + print STDERR "bad rpm $_\n"; + next; + } else { + die "bad rpm $_\n"; + } + } my $pkg = $urpm->{depslist}[$id]; @@ -339,18 +339,14 @@ sub compute_deps { #- split : split ratio (default 400000). sub build_hdlist { my ($urpm, %options) = @_; - my ($dir, $start, $end, $ratio, $split, @idlist); + my ($dir, $ratio, $split, @idlist); $dir = $options{dir} || ($ENV{TMPDIR} || "/tmp") . "/.build_hdlist"; -d $dir or die "no directory $dir\n"; - if (@{$options{idlist}}) { - @idlist = @{$options{idlist}}; - } else { - $start = $options{start} || 0; - $end = $options{end} || $#{$urpm->{depslist}}; - @idlist = ($start .. $end); - } + @idlist = @{$options{idlist}} > 0 ? @{$options{idlist}} : + ($options{start} || 0 .. $options{end} || $#{$urpm->{depslist}}); + @idlist or return; #- compression ratio are not very high, sample for cooker #- gives the following (main only and cache fed up): @@ -385,16 +381,12 @@ sub build_hdlist { #- ratio : compression ratio (default 9). sub build_synthesis { my ($urpm, %options) = @_; - my ($start, $end, $ratio, @idlist); - - if (@{$options{idlist}} > 0) { - @idlist = @{$options{idlist}}; - } else { - $start = $options{start} || 0; - $end = $options{end} || $#{$urpm->{depslist}}; - $start > $end and return; - @idlist = ($start .. $end); - } + my ($ratio, @idlist); + + @idlist = @{$options{idlist}} > 0 ? @{$options{idlist}} : + ($options{start} || 0 .. $options{end} || $#{$urpm->{depslist}}); + @idlist or return; + $ratio = $options{ratio} || 9; $options{synthesis} || defined $options{fd} or die "invalid parameters given"; |