Changeset 19ff1da


Ignore:
Timestamp:
07/03/2023 09:22:17 AM (12 months ago)
Author:
Xi Ruoyao <xry111@…>
Branches:
12.0, 12.0-rc1, 12.1, 12.1-rc1, multilib, renodr/libudev-from-systemd, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/update-glibc
Children:
bf7d328
Parents:
48834cf
Message:

currency: Refactor http_get_file to avoid duplicating preg_match

Check special cases and return early.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lfs-latest-git.php

    r48834cf r19ff1da  
    7070function http_get_file( $url )
    7171{
    72   if ( ! preg_match( "/sourceforge/", $url ) &&
    73        ! preg_match( "/mpfr/",        $url ) &&
    74        ! preg_match( "/psmisc/",      $url ) )
    75   {
    76     exec( "curl --location --silent --max-time 30 $url", $dir );
    77 
    78     $s   = implode( "\n", $dir );
    79     $dir = strip_tags( $s );
    80     return explode( "\n", $dir );
    81   }
    82   else if ( preg_match( "/mpfr/", $url ) )
     72  if ( preg_match( "/mpfr/", $url ) )
    8373  {
    8474    # There seems to be a problem with the mpfs certificate
     
    8878    return explode( "\n", $dir );
    8979  }
    90   else
     80
     81  if ( preg_match( "/sourceforge/", $url ) ||
     82       preg_match( "/psmisc/",      $url ) )
    9183  {
    9284    exec( "lynx -dump $url 2>/dev/null", $lines );
    9385    return $lines;
    9486  }
     87
     88  exec( "curl --location --silent --max-time 30 $url", $dir );
     89
     90  $s   = implode( "\n", $dir );
     91  $dir = strip_tags( $s );
     92  return explode( "\n", $dir );
    9593}
    9694
Note: See TracChangeset for help on using the changeset viewer.