mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 14:35:07 +00:00
Update to php-gettext 1.0.7+. fixes #1727
git-svn-id: http://svn.automattic.com/wordpress/trunk@4003 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2df0ebe996
commit
553a53efb7
@ -61,15 +61,12 @@ class gettext_reader {
|
|||||||
* @return Integer from the Stream
|
* @return Integer from the Stream
|
||||||
*/
|
*/
|
||||||
function readint() {
|
function readint() {
|
||||||
$stream = $this->STREAM->read(4);
|
|
||||||
if ($this->BYTEORDER == 0) {
|
if ($this->BYTEORDER == 0) {
|
||||||
// low endian
|
// low endian
|
||||||
$unpacked = unpack('V',$stream);
|
return array_shift(unpack('V', $this->STREAM->read(4)));
|
||||||
return array_shift($unpacked);
|
|
||||||
} else {
|
} else {
|
||||||
// big endian
|
// big endian
|
||||||
$unpacked = unpack('N',$stream);
|
return array_shift(unpack('N', $this->STREAM->read(4)));
|
||||||
return array_shift($unpacked);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +94,7 @@ class gettext_reader {
|
|||||||
*/
|
*/
|
||||||
function gettext_reader($Reader, $enable_cache = true) {
|
function gettext_reader($Reader, $enable_cache = true) {
|
||||||
// If there isn't a StreamReader, turn on short circuit mode.
|
// If there isn't a StreamReader, turn on short circuit mode.
|
||||||
if (! $Reader) {
|
if (! $Reader || isset($Reader->error) ) {
|
||||||
$this->short_circuit = true;
|
$this->short_circuit = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -105,16 +102,16 @@ class gettext_reader {
|
|||||||
// Caching can be turned off
|
// Caching can be turned off
|
||||||
$this->enable_cache = $enable_cache;
|
$this->enable_cache = $enable_cache;
|
||||||
|
|
||||||
// $MAGIC1 = (int)0x950412de; //bug in PHP 5
|
// $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
|
||||||
$MAGIC1 = (int) - 1794895138;
|
$MAGIC1 = (int) - 1794895138;
|
||||||
// $MAGIC2 = (int)0xde120495; //bug
|
// $MAGIC2 = (int)0xde120495; //bug
|
||||||
$MAGIC2 = (int) - 569244523;
|
$MAGIC2 = (int) - 569244523;
|
||||||
|
|
||||||
$this->STREAM = $Reader;
|
$this->STREAM = $Reader;
|
||||||
$magic = $this->readint();
|
$magic = $this->readint();
|
||||||
if ($magic == $MAGIC1) {
|
if ($magic == ($MAGIC1 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms
|
||||||
$this->BYTEORDER = 0;
|
$this->BYTEORDER = 0;
|
||||||
} elseif ($magic == $MAGIC2) {
|
} elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) {
|
||||||
$this->BYTEORDER = 1;
|
$this->BYTEORDER = 1;
|
||||||
} else {
|
} else {
|
||||||
$this->error = 1; // not MO file
|
$this->error = 1; // not MO file
|
||||||
@ -282,7 +279,7 @@ class gettext_reader {
|
|||||||
} else {
|
} else {
|
||||||
$header = $this->get_translation_string(0);
|
$header = $this->get_translation_string(0);
|
||||||
}
|
}
|
||||||
if (eregi("plural-forms: (.*)\n", $header, $regs))
|
if (eregi("plural-forms: ([^\n]*)\n", $header, $regs))
|
||||||
$expr = $regs[1];
|
$expr = $regs[1];
|
||||||
else
|
else
|
||||||
$expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
|
$expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
|
||||||
@ -308,7 +305,7 @@ class gettext_reader {
|
|||||||
$plural = 0;
|
$plural = 0;
|
||||||
|
|
||||||
eval("$string");
|
eval("$string");
|
||||||
if ($plural >= $total) $plural = 0;
|
if ($plural >= $total) $plural = $total - 1;
|
||||||
return $plural;
|
return $plural;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,14 @@ class FileReader {
|
|||||||
function read($bytes) {
|
function read($bytes) {
|
||||||
if ($bytes) {
|
if ($bytes) {
|
||||||
fseek($this->_fd, $this->_pos);
|
fseek($this->_fd, $this->_pos);
|
||||||
$data = fread($this->_fd, $bytes);
|
|
||||||
|
// PHP 5.1.1 does not read more than 8192 bytes in one fread()
|
||||||
|
// the discussions at PHP Bugs suggest it's the intended behaviour
|
||||||
|
while ($bytes > 0) {
|
||||||
|
$chunk = fread($this->_fd, $bytes);
|
||||||
|
$data .= $chunk;
|
||||||
|
$bytes -= strlen($chunk);
|
||||||
|
}
|
||||||
$this->_pos = ftell($this->_fd);
|
$this->_pos = ftell($this->_fd);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user