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

Dpkg::Arch: Add a new set_host_gnu_type()

This function makes it possible to get get_raw_host_arch() out from the
block containing the local $gcc_host_gnu_type variable, reducing the
nesting level.
Guillem Jover лет назад: 10
Родитель
Сommit
78b312b01d
1 измененных файлов с 34 добавлено и 26 удалено
  1. 34 26
      scripts/Dpkg/Arch.pm

+ 34 - 26
scripts/Dpkg/Arch.pm

@@ -131,6 +131,14 @@ sub get_build_arch()
 	return $gcc_host_gnu_type;
     }
 
+    sub set_host_gnu_type
+    {
+        my ($host_gnu_type) = @_;
+
+        $gcc_host_gnu_type = $host_gnu_type;
+    }
+}
+
 =item $arch = get_raw_host_arch()
 
 Get the raw host Debian architecture, without taking into account variables
@@ -138,37 +146,37 @@ from the environment.
 
 =cut
 
-    sub get_raw_host_arch()
-    {
-        state $host_arch;
-
-	return $host_arch if defined $host_arch;
-
-	$gcc_host_gnu_type = get_gcc_host_gnu_type();
+sub get_raw_host_arch()
+{
+    state $host_arch;
 
-	if ($gcc_host_gnu_type eq '') {
-	    warning(g_("couldn't determine gcc system type, falling back to " .
-	               'default (native compilation)'));
-	} else {
-	    my (@host_archtriplet) = gnutriplet_to_debtriplet($gcc_host_gnu_type);
-	    $host_arch = debtriplet_to_debarch(@host_archtriplet);
+    return $host_arch if defined $host_arch;
 
-	    if (defined $host_arch) {
-		$gcc_host_gnu_type = debtriplet_to_gnutriplet(@host_archtriplet);
-	    } else {
-		warning(g_('unknown gcc system type %s, falling back to ' .
-		           'default (native compilation)'), $gcc_host_gnu_type);
-		$gcc_host_gnu_type = '';
-	    }
-	}
+    $gcc_host_gnu_type = get_gcc_host_gnu_type();
 
-	if (!defined($host_arch)) {
-	    # Switch to native compilation.
-	    $host_arch = get_raw_build_arch();
-	}
+    if ($gcc_host_gnu_type eq '') {
+        warning(g_("couldn't determine gcc system type, falling back to " .
+                   'default (native compilation)'));
+    } else {
+        my (@host_archtriplet) = gnutriplet_to_debtriplet($gcc_host_gnu_type);
+        $host_arch = debtriplet_to_debarch(@host_archtriplet);
+
+        if (defined $host_arch) {
+            $gcc_host_gnu_type = debtriplet_to_gnutriplet(@host_archtriplet);
+        } else {
+            warning(g_('unknown gcc system type %s, falling back to ' .
+                       'default (native compilation)'), $gcc_host_gnu_type);
+            $gcc_host_gnu_type = '';
+        }
+        set_host_gnu_type($gcc_host_gnu_type);
+    }
 
-	return $host_arch;
+    if (!defined($host_arch)) {
+        # Switch to native compilation.
+        $host_arch = get_raw_build_arch();
     }
+
+    return $host_arch;
 }
 
 =item $arch = get_host_arch()