mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-06-19 19:59:20 +01:00
currency: Refactor http_get_file to avoid duplicating preg_match
Check special cases and return early.
This commit is contained in:
parent
48834cf197
commit
19ff1dadd1
@ -69,17 +69,7 @@ function find_even_max( $lines, $regex_match, $regex_replace )
|
|||||||
|
|
||||||
function http_get_file( $url )
|
function http_get_file( $url )
|
||||||
{
|
{
|
||||||
if ( ! preg_match( "/sourceforge/", $url ) &&
|
if ( preg_match( "/mpfr/", $url ) )
|
||||||
! preg_match( "/mpfr/", $url ) &&
|
|
||||||
! preg_match( "/psmisc/", $url ) )
|
|
||||||
{
|
|
||||||
exec( "curl --location --silent --max-time 30 $url", $dir );
|
|
||||||
|
|
||||||
$s = implode( "\n", $dir );
|
|
||||||
$dir = strip_tags( $s );
|
|
||||||
return explode( "\n", $dir );
|
|
||||||
}
|
|
||||||
else if ( preg_match( "/mpfr/", $url ) )
|
|
||||||
{
|
{
|
||||||
# There seems to be a problem with the mpfs certificate
|
# There seems to be a problem with the mpfs certificate
|
||||||
exec( "curl --location --silent --insecure --max-time 30 $url", $dir );
|
exec( "curl --location --silent --insecure --max-time 30 $url", $dir );
|
||||||
@ -87,11 +77,19 @@ function http_get_file( $url )
|
|||||||
$dir = strip_tags( $s );
|
$dir = strip_tags( $s );
|
||||||
return explode( "\n", $dir );
|
return explode( "\n", $dir );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if ( preg_match( "/sourceforge/", $url ) ||
|
||||||
|
preg_match( "/psmisc/", $url ) )
|
||||||
{
|
{
|
||||||
exec( "lynx -dump $url 2>/dev/null", $lines );
|
exec( "lynx -dump $url 2>/dev/null", $lines );
|
||||||
return $lines;
|
return $lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exec( "curl --location --silent --max-time 30 $url", $dir );
|
||||||
|
|
||||||
|
$s = implode( "\n", $dir );
|
||||||
|
$dir = strip_tags( $s );
|
||||||
|
return explode( "\n", $dir );
|
||||||
}
|
}
|
||||||
|
|
||||||
function max_parent( $dirpath, $prefix )
|
function max_parent( $dirpath, $prefix )
|
||||||
|
Loading…
Reference in New Issue
Block a user