Bläddra i källkod

Dpkg::Deps: Add new deps_concat function

Guillem Jover 13 år sedan
förälder
incheckning
638b42441d
1 ändrade filer med 24 tillägg och 2 borttagningar
  1. 24 2
      scripts/Dpkg/Deps.pm

+ 24 - 2
scripts/Dpkg/Deps.pm

@@ -1,4 +1,5 @@
 # Copyright © 2007-2009 Raphaël Hertzog <hertzog@debian.org>
+# Copyright © 2012 Guillem Jover <guillem@debian.org>
 #
 # This program is free software; you may redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -48,7 +49,7 @@ All the deps_* functions are exported by default.
 use strict;
 use warnings;
 
-our $VERSION = "1.01";
+our $VERSION = "1.02";
 
 use Dpkg::Version;
 use Dpkg::Arch qw(get_host_arch get_build_arch);
@@ -56,7 +57,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
 
 use base qw(Exporter);
-our @EXPORT = qw(deps_parse deps_eval_implication deps_compare);
+our @EXPORT = qw(deps_concat deps_parse deps_eval_implication deps_compare);
 
 # Some factorized function
 
@@ -241,6 +242,19 @@ sub deps_eval_implication {
     return undef;
 }
 
+=item my $dep = deps_concat(@dep_list)
+
+This function concatenates multiple dependency lines into a single line,
+joining them with ", " if appropriate, and always returning a valid string.
+
+=cut
+
+sub deps_concat {
+    my (@dep_list) = @_;
+
+    return join(', ', grep { defined $_ } @dep_list);
+}
+
 =item my $dep = deps_parse($line, %options)
 
 This function parses the dependency line and returns an object, either a
@@ -1316,6 +1330,14 @@ sub _evaluate_simple_dep {
 
 =head1 CHANGES
 
+=head2 Version 1.02
+
+=over
+
+=item * Add new Dpkg::deps_concat() function.
+
+=back
+
 =head2 Version 1.01
 
 =over