Просмотр исходного кода

dpkg-checkbuilddeps: Split check_line into build_depends and build_conflicts

The functions have less in common than what it looks like. Splitting the
functions actually reduces the line count.
Guillem Jover лет назад: 12
Родитель
Сommit
74e7ba89e0
1 измененных файлов с 18 добавлено и 30 удалено
  1. 18 30
      scripts/dpkg-checkbuilddeps.pl

+ 18 - 30
scripts/dpkg-checkbuilddeps.pl

@@ -189,39 +189,27 @@ sub parse_status {
 # in as the 4th parameter. If not set, dpkg will be queried for the build
 # architecture.
 sub build_depends {
-	return check_line(1, @_);
+    my ($dep_list, $facts) = @_;
+
+    $dep_list->simplify_deps($facts);
+    if ($dep_list->is_empty()) {
+        return ();
+    } else {
+        return $dep_list->get_deps();
+    }
 }
 
-# This function is exactly like unmet_build_depends, except it
+# This function is exactly like build_depends(), except it
 # checks for build conflicts, and returns a list of the packages
 # that are installed and are conflicted with.
 sub build_conflicts {
-	return check_line(0, @_);
-}
-
-# This function does all the work. The first parameter is 1 to check build
-# deps, and 0 to check build conflicts.
-sub check_line {
-	my $build_depends=shift;
-	my $dep_list=shift;
-	my $facts=shift;
-
-	my @unmet=();
-
-	if ($build_depends) {
-		$dep_list->simplify_deps($facts);
-		if ($dep_list->is_empty()) {
-			return ();
-		} else {
-			return $dep_list->get_deps();
-		}
-	} else { # Build-Conflicts
-		my @conflicts = ();
-		foreach my $dep ($dep_list->get_deps()) {
-			if ($dep->get_evaluation($facts)) {
-				push @conflicts, $dep;
-			}
-		}
-		return @conflicts;
-	}
+    my ($dep_list, $facts) = @_;
+
+    my @conflicts = ();
+    foreach my $dep ($dep_list->get_deps()) {
+        if ($dep->get_evaluation($facts)) {
+            push @conflicts, $dep;
+        }
+    }
+    return @conflicts;
 }