From 089c866bc2a77d63d7fef70c745a5b229cb05a4e Mon Sep 17 00:00:00 2001 From: svollbehr Date: Sat, 6 Mar 2010 18:17:56 +0000 Subject: [PATCH] Fix small bugs git-svn-id: http://php-reader.googlecode.com/svn/branches/zend@169 51a70ab9-7547-0410-9469-37e369ee0574 --- src/Zend/Io/Reader.php | 6 +++++- src/Zend/Io/StringWriter.php | 3 +++ src/Zend/Io/Writer.php | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Zend/Io/Reader.php b/src/Zend/Io/Reader.php index 8170052..444b98b 100644 --- a/src/Zend/Io/Reader.php +++ b/src/Zend/Io/Reader.php @@ -570,7 +570,11 @@ class Zend_Io_Reader } } - return substr($value, -2) == "\0\0" ? substr($value, 0, -2) : $value; + while (substr($value, -2) == "\0\0") { + $value = substr($value, 0, -2); + } + + return $value; } /** diff --git a/src/Zend/Io/StringWriter.php b/src/Zend/Io/StringWriter.php index 6ce98b7..b743a2f 100644 --- a/src/Zend/Io/StringWriter.php +++ b/src/Zend/Io/StringWriter.php @@ -69,6 +69,9 @@ class Zend_Io_StringWriter extends Zend_Io_Writer */ public function toString() { + if ($this->getSize() == 0) { + return ''; + } $offset = $this->getOffset(); $this->setOffset(0); $data = fread($this->getFileDescriptor(), $this->getSize()); diff --git a/src/Zend/Io/Writer.php b/src/Zend/Io/Writer.php index 1de4c75..9359f7c 100644 --- a/src/Zend/Io/Writer.php +++ b/src/Zend/Io/Writer.php @@ -492,7 +492,7 @@ class Zend_Io_Writer * @throws Zend_Io_Exception if length attribute is negative or * if the stream is closed */ - public final function writeHHex($length) + public final function writeHHex($value) { return $this->write(pack('H*', $value)); } @@ -506,7 +506,7 @@ class Zend_Io_Writer * @throws Zend_Io_Exception if length attribute is negative or * if the stream is closed */ - public final function writeLHex($length) + public final function writeLHex($value) { return $this->write(pack('h*', $value)); } @@ -519,7 +519,7 @@ class Zend_Io_Writer * @return Zend_Io_Writer * @throws Zend_Io_Exception if the stream is closed */ - public final function writeGuid() + public final function writeGuid($value) { $string = ''; $C = preg_split('/-/', $value);