diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-07-07 14:37:58 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-07-07 14:37:58 +0000 |
commit | c5580572a15003e3c2fb1d9cbd7c2baafe14bb5a (patch) | |
tree | 0d476e736e7ff30fa920c6ce32919f41c0a27bf7 /wp-includes/gettext.php | |
parent | d3ab0af45aaa6a0135b497df0d7657635de900ab (diff) | |
download | wordpress-mu-c5580572a15003e3c2fb1d9cbd7c2baafe14bb5a.tar.gz wordpress-mu-c5580572a15003e3c2fb1d9cbd7c2baafe14bb5a.tar.xz wordpress-mu-c5580572a15003e3c2fb1d9cbd7c2baafe14bb5a.zip |
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@643 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/gettext.php')
-rw-r--r-- | wp-includes/gettext.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/wp-includes/gettext.php b/wp-includes/gettext.php index ad605cf..cd08044 100644 --- a/wp-includes/gettext.php +++ b/wp-includes/gettext.php @@ -61,15 +61,12 @@ class gettext_reader { * @return Integer from the Stream */ function readint() { - $stream = $this->STREAM->read(4); if ($this->BYTEORDER == 0) { // low endian - $unpacked = unpack('V',$stream); - return array_shift($unpacked); + return array_shift(unpack('V', $this->STREAM->read(4))); } else { // big endian - $unpacked = unpack('N',$stream); - return array_shift($unpacked); + return array_shift(unpack('N', $this->STREAM->read(4))); } } @@ -97,7 +94,7 @@ class gettext_reader { */ function gettext_reader($Reader, $enable_cache = true) { // If there isn't a StreamReader, turn on short circuit mode. - if (! $Reader) { + if (! $Reader || isset($Reader->error) ) { $this->short_circuit = true; return; } @@ -105,16 +102,16 @@ class gettext_reader { // Caching can be turned off $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; // $MAGIC2 = (int)0xde120495; //bug $MAGIC2 = (int) - 569244523; $this->STREAM = $Reader; $magic = $this->readint(); - if ($magic == $MAGIC1) { + if ($magic == ($MAGIC1 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms $this->BYTEORDER = 0; - } elseif ($magic == $MAGIC2) { + } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) { $this->BYTEORDER = 1; } else { $this->error = 1; // not MO file @@ -282,7 +279,7 @@ class gettext_reader { } else { $header = $this->get_translation_string(0); } - if (eregi("plural-forms: (.*)\n", $header, $regs)) + if (eregi("plural-forms: ([^\n]*)\n", $header, $regs)) $expr = $regs[1]; else $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; @@ -308,7 +305,7 @@ class gettext_reader { $plural = 0; eval("$string"); - if ($plural >= $total) $plural = 0; + if ($plural >= $total) $plural = $total - 1; return $plural; } |