Updated PEAR and PEAR packages.
[timetracker.git] / WEB-INF / lib / pear / System.php
index c27d446..9ff3fed 100644 (file)
@@ -9,7 +9,6 @@
  * @author     Tomas V.V.Cox <cox@idecnet.com>
  * @copyright  1997-2009 The Authors
  * @license    http://opensource.org/licenses/bsd-license.php New BSD License
- * @version    CVS: $Id: System.php 313024 2011-07-06 19:51:24Z dufuz $
  * @link       http://pear.php.net/package/PEAR
  * @since      File available since Release 0.1
  */
@@ -51,7 +50,7 @@ $GLOBALS['_System_temp_files'] = array();
 * @author     Tomas V.V. Cox <cox@idecnet.com>
 * @copyright  1997-2006 The PHP Group
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
-* @version    Release: 1.9.4
+* @version    Release: 1.10.1
 * @link       http://pear.php.net/package/PEAR
 * @since      Class available since Release 0.1
 * @static
@@ -65,12 +64,27 @@ class System
      * @param    string  $short_options  the allowed option short-tags
      * @param    string  $long_options   the allowed option long-tags
      * @return   array   the given options and there values
-     * @static
-     * @access private
      */
-    function _parseArgs($argv, $short_options, $long_options = null)
+    public static function _parseArgs($argv, $short_options, $long_options = null)
     {
         if (!is_array($argv) && $argv !== null) {
+            /*
+            // Quote all items that are a short option
+            $av = preg_split('/(\A| )--?[a-z0-9]+[ =]?((?<!\\\\)((,\s*)|((?<!,)\s+))?)/i', $argv, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
+            $offset = 0;
+            foreach ($av as $a) {
+                $b = trim($a[0]);
+                if ($b{0} == '"' || $b{0} == "'") {
+                    continue;
+                }
+
+                $escape = escapeshellarg($b);
+                $pos = $a[1] + $offset;
+                $argv = substr_replace($argv, $escape, $pos, strlen($b));
+                $offset += 2;
+            }
+            */
+
             // Find all items, quoted or otherwise
             preg_match_all("/(?:[\"'])(.*?)(?:['\"])|([^\s]+)/", $argv, $av);
             $argv = $av[1];
@@ -81,6 +95,7 @@ class System
                 $argv[$k] = trim($a) ;
             }
         }
+
         return Console_Getopt::getopt2($argv, $short_options, $long_options);
     }
 
@@ -90,10 +105,8 @@ class System
      *
      * @param mixed $error a PEAR error or a string with the error message
      * @return bool false
-     * @static
-     * @access private
      */
-    function raiseError($error)
+    protected static function raiseError($error)
     {
         if (PEAR::isError($error)) {
             $error = $error->getMessage();
@@ -124,10 +137,8 @@ class System
      * @param    integer $aktinst    starting deep of the lookup
      * @param    bool    $silent     if true, do not emit errors.
      * @return   array   the structure of the dir
-     * @static
-     * @access   private
      */
-    function _dirToStruct($sPath, $maxinst, $aktinst = 0, $silent = false)
+    protected static function _dirToStruct($sPath, $maxinst, $aktinst = 0, $silent = false)
     {
         $struct = array('dirs' => array(), 'files' => array());
         if (($dir = @opendir($sPath)) === false) {
@@ -170,7 +181,7 @@ class System
      * @static
      * @see System::_dirToStruct()
      */
-    function _multipleToStruct($files)
+    protected static function _multipleToStruct($files)
     {
         $struct = array('dirs' => array(), 'files' => array());
         settype($files, 'array');
@@ -196,7 +207,7 @@ class System
      * @static
      * @access   public
      */
-    function rm($args)
+    public static function rm($args)
     {
         $opts = System::_parseArgs($args, 'rf'); // "f" does nothing but I like it :-)
         if (PEAR::isError($opts)) {
@@ -239,10 +250,8 @@ class System
      * The -p option will create parent directories
      * @param    string  $args    the name of the director(y|ies) to create
      * @return   bool    True for success
-     * @static
-     * @access   public
      */
-    function mkDir($args)
+    public static function mkDir($args)
     {
         $opts = System::_parseArgs($args, 'pm:');
         if (PEAR::isError($opts)) {
@@ -310,10 +319,8 @@ class System
      *
      * @param    string  $args   the arguments
      * @return   boolean true on success
-     * @static
-     * @access   public
      */
-    function &cat($args)
+    public static function &cat($args)
     {
         $ret = null;
         $files = array();
@@ -384,10 +391,8 @@ class System
      * @param   string  $args  The arguments
      * @return  mixed   the full path of the created (file|dir) or false
      * @see System::tmpdir()
-     * @static
-     * @access  public
      */
-    function mktemp($args = null)
+    public static function mktemp($args = null)
     {
         static $first_time = true;
         $opts = System::_parseArgs($args, 't:d');
@@ -436,11 +441,8 @@ class System
     /**
      * Remove temporary files created my mkTemp. This function is executed
      * at script shutdown time
-     *
-     * @static
-     * @access private
      */
-    function _removeTmpFiles()
+    public static function _removeTmpFiles()
     {
         if (count($GLOBALS['_System_temp_files'])) {
             $delete = $GLOBALS['_System_temp_files'];
@@ -456,10 +458,9 @@ class System
      * Note: php.ini-recommended removes the "E" from the variables_order setting,
      * making unavaible the $_ENV array, that s why we do tests with _ENV
      *
-     * @static
      * @return string The temporary directory on the system
      */
-    function tmpdir()
+    public static function tmpdir()
     {
         if (OS_WINDOWS) {
             if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
@@ -489,10 +490,9 @@ class System
      * @param mixed  $fallback Value to return if $program is not found
      *
      * @return mixed A string with the full path or false if not found
-     * @static
      * @author Stig Bakken <ssb@php.net>
      */
-    function which($program, $fallback = false)
+    public static function which($program, $fallback = false)
     {
         // enforce API
         if (!is_string($program) || '' == $program) {
@@ -504,13 +504,11 @@ class System
             $path_elements[] = dirname($program);
             $program = basename($program);
         } else {
-            // Honor safe mode
-            if (!ini_get('safe_mode') || !$path = ini_get('safe_mode_exec_dir')) {
-                $path = getenv('PATH');
-                if (!$path) {
-                    $path = getenv('Path'); // some OSes are just stupid enough to do this
-                }
+            $path = getenv('PATH');
+            if (!$path) {
+                $path = getenv('Path'); // some OSes are just stupid enough to do this
             }
+
             $path_elements = explode(PATH_SEPARATOR, $path);
         }
 
@@ -522,17 +520,14 @@ class System
             if (strpos($program, '.') !== false) {
                 array_unshift($exe_suffixes, '');
             }
-            // is_executable() is not available on windows for PHP4
-            $pear_is_executable = (function_exists('is_executable')) ? 'is_executable' : 'is_file';
         } else {
             $exe_suffixes = array('');
-            $pear_is_executable = 'is_executable';
         }
 
         foreach ($exe_suffixes as $suff) {
             foreach ($path_elements as $dir) {
                 $file = $dir . DIRECTORY_SEPARATOR . $program . $suff;
-                if (@$pear_is_executable($file)) {
+                if (is_executable($file)) {
                     return $file;
                 }
             }
@@ -561,10 +556,8 @@ class System
      *
      * @param  mixed Either array or string with the command line
      * @return array Array of found files
-     * @static
-     *
      */
-    function find($args)
+    public static function find($args)
     {
         if (!is_array($args)) {
             $args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);