Changeset 4004

Show
Ignore:
Timestamp:
07/06/06 22:36:44 (3 years ago)
Author:
ryan
Message:

Update to php-gettext 1.0.7+. fixes #1727

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.0/wp-includes/gettext.php

    r2882 r4004  
    6262   */ 
    6363  function readint() { 
    64       $stream = $this->STREAM->read(4); 
    6564      if ($this->BYTEORDER == 0) { 
    6665        // low endian 
    67         $unpacked = unpack('V',$stream); 
    68         return array_shift($unpacked); 
     66        return array_shift(unpack('V', $this->STREAM->read(4))); 
    6967      } else { 
    7068        // big endian 
    71         $unpacked = unpack('N',$stream); 
    72         return array_shift($unpacked); 
     69        return array_shift(unpack('N', $this->STREAM->read(4))); 
    7370      } 
    7471    } 
     
    9895  function gettext_reader($Reader, $enable_cache = true) { 
    9996    // If there isn't a StreamReader, turn on short circuit mode. 
    100     if (! $Reader) { 
     97    if (! $Reader || isset($Reader->error) ) { 
    10198      $this->short_circuit = true; 
    10299      return; 
     
    106103    $this->enable_cache = $enable_cache; 
    107104 
    108     // $MAGIC1 = (int)0x950412de; //bug in PHP 5 
     105    // $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 
    109106    $MAGIC1 = (int) - 1794895138; 
    110107    // $MAGIC2 = (int)0xde120495; //bug 
     
    113110    $this->STREAM = $Reader; 
    114111    $magic = $this->readint(); 
    115     if ($magic == $MAGIC1) { 
     112    if ($magic == ($MAGIC1 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms 
    116113      $this->BYTEORDER = 0; 
    117     } elseif ($magic == $MAGIC2) { 
     114    } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) { 
    118115      $this->BYTEORDER = 1; 
    119116    } else { 
     
    283280        $header = $this->get_translation_string(0); 
    284281      } 
    285       if (eregi("plural-forms: (.*)\n", $header, $regs)) 
     282      if (eregi("plural-forms: ([^\n]*)\n", $header, $regs)) 
    286283        $expr = $regs[1]; 
    287284      else 
     
    309306 
    310307    eval("$string"); 
    311     if ($plural >= $total) $plural = 0
     308    if ($plural >= $total) $plural = $total - 1
    312309    return $plural; 
    313310  } 
  • branches/2.0/wp-includes/streams.php

    r2554 r4004  
    106106    if ($bytes) { 
    107107      fseek($this->_fd, $this->_pos); 
    108       $data = fread($this->_fd, $bytes); 
     108 
     109      // PHP 5.1.1 does not read more than 8192 bytes in one fread() 
     110      // the discussions at PHP Bugs suggest it's the intended behaviour 
     111      while ($bytes > 0) { 
     112        $chunk  = fread($this->_fd, $bytes); 
     113        $data  .= $chunk; 
     114        $bytes -= strlen($chunk); 
     115      } 
    109116      $this->_pos = ftell($this->_fd); 
    110117