Changes from trunk/wp-includes/pomo/streams.php at r10584 to branches/2.8/wp-includes/pomo/streams.php at r11627
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.8/wp-includes/pomo/streams.php
r10584 r11627 4 4 * Based on the classes from Danilo Segan <danilo@kvota.net> 5 5 * 6 * @version $Id: streams.php 33 2009-02-16 09:33:39Z nbachiyski $6 * @version $Id: streams.php 138 2009-06-23 13:22:09Z nbachiyski $ 7 7 * @package pomo 8 8 * @subpackage streams … … 18 18 var $_str; 19 19 20 function POMO_StringReader($str = '') { 21 $this->_str = $str; 22 $this->_pos = 0; 23 } 20 function POMO_StringReader($str = '') { 21 $this->_str = $str; 22 $this->_pos = 0; 23 $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr'); 24 } 24 25 25 function read($bytes) { 26 $data = substr($this->_str, $this->_pos, $bytes); 27 $this->_pos += $bytes; 28 if (strlen($this->_str)<$this->_pos) 29 $this->_pos = strlen($this->_str); 26 function _substr($string, $start, $length) { 27 if ($this->is_overloaded) { 28 return mb_substr($string,$start,$length,'ascii'); 29 } else { 30 return substr($string,$start,$length); 31 } 32 } 33 34 function _strlen($string) { 35 if ($this->is_overloaded) { 36 return mb_strlen($string,'ascii'); 37 } else { 38 return strlen($string); 39 } 40 } 30 41 31 return $data; 32 } 42 function read($bytes) { 43 $data = $this->_substr($this->_str, $this->_pos, $bytes); 44 $this->_pos += $bytes; 45 if ($this->_strlen($this->_str) < $this->_pos) $this->_pos = $this->_strlen($this->_str); 46 return $data; 47 } 33 48 34 function seekto($pos) { 35 $this->_pos = $pos; 36 if (strlen($this->_str)<$this->_pos) 37 $this->_pos = strlen($this->_str); 38 return $this->_pos; 39 } 49 function seekto($pos) { 50 $this->_pos = $pos; 51 if ($this->_strlen($this->_str) < $this->_pos) $this->_pos = $this->_strlen($this->_str); 52 return $this->_pos; 53 } 40 54 41 42 43 55 function pos() { 56 return $this->_pos; 57 } 44 58 45 46 returnstrlen($this->_str);47 59 function length() { 60 return $this->_strlen($this->_str); 61 } 48 62 49 63 } … … 54 68 class POMO_CachedFileReader extends POMO_StringReader { 55 69 function POMO_CachedFileReader($filename) { 70 parent::POMO_StringReader(); 56 71 $this->_str = file_get_contents($filename); 57 72 if (false === $this->_str) 58 73 return false; 59 $this-> pos = 0;74 $this->_pos = 0; 60 75 } 61 76 } … … 97 112 function readint32() { 98 113 $bytes = $this->read(4); 99 if (4 != strlen($bytes))114 if (4 != $this->_strlen($bytes)) 100 115 return false; 101 116 $endian_letter = ('big' == $this->endian)? 'N' : 'V'; … … 113 128 function readint32array($count) { 114 129 $bytes = $this->read(4 * $count); 115 if (4*$count != strlen($bytes))130 if (4*$count != $this->_strlen($bytes)) 116 131 return false; 117 132 $endian_letter = ('big' == $this->endian)? 'N' : 'V';
Note: See TracChangeset
for help on using the changeset viewer.