- Timestamp:
- 04.09.2006 10:53:26 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 modified
-
File/Bittorrent/Decode.php (modified) (1 diff)
-
File/Bittorrent/Encode.php (modified) (3 diffs)
-
Tests/FileBittorrent.php (added)
-
package2.xml (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/File/Bittorrent/Decode.php
r55 r62 365 365 { 366 366 $pos_e = strpos($this->_source, 'e', $this->_position); 367 $return = intval(substr($this->_source, $this->_position, $pos_e - $this->_position)); 367 // The return value showld be automatically casted to float if the intval would 368 // overflow. The "+ 0" accomplishes exactly that, using the internal casting 369 // logic of PHP 370 $return = substr($this->_source, $this->_position, $pos_e - $this->_position) + 0; 368 371 $this->_position = $pos_e + 1; 369 372 return $return; -
trunk/File/Bittorrent/Encode.php
r42 r62 78 78 case is_null($mixed): 79 79 return $this->encode_string(''); 80 break;81 80 case 'string': 82 81 return $this->encode_string($mixed); 83 break;84 82 case 'integer': 85 return $this->encode_int($mixed);86 break;83 case 'double': 84 return $this->encode_int(round($mixed)); 87 85 case 'array': 88 86 return $this->encode_array($mixed); 89 break;90 87 default: 91 PEAR::raiseError('File_Bittorrent_Encode ()::encode() - Unsupported type.', null, null, "Variable must be one of 'string', 'integer' or 'array'");88 PEAR::raiseError('File_Bittorrent_Encode::encode() - Unsupported type.', null, null, "Variable must be one of 'string', 'integer', 'double' or 'array'"); 92 89 } 93 90 } … … 105 102 function encode_string($str) 106 103 { 107 return s printf('%s:%s', strlen($str), $str);104 return strlen($str) . ':' . $str; 108 105 } 109 106 … … 120 117 function encode_int($int) 121 118 { 122 return sprintf('i%se', $int);119 return 'i' . $int . 'e'; 123 120 } 124 121 -
trunk/package2.xml
r61 r62 23 23 <active>yes</active> 24 24 </developer> 25 <date>2006-0 7-02</date>26 <time> 19:28:43</time>25 <date>2006-09-04</date> 26 <time>00:00:00</time> 27 27 <version> 28 <release>1.0. 1</release>29 <api> 57</api>28 <release>1.0.2</release> 29 <api>62</api> 30 30 </version> 31 31 <stability> … … 35 35 <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license> 36 36 <notes> 37 * Updated dependencies to PEAR 1.4.2 / PHP 4.4. 38 * Fixed _addDir return value. Bug #7406. 39 * Changed announce_list behaviour. Bug #8085. 37 * Alexiev fixed bug #5836 38 * Added test for info hash 40 39 </notes> 41 40 <contents> … … 254 253 </notes> 255 254 </release> 255 <release> 256 <date>2006-09-04</date> 257 <version> 258 <release>1.0.2</release> 259 <api>62</api> 260 </version> 261 <stability> 262 <release>stable</release> 263 <api>stable</api> 264 </stability> 265 <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license> 266 <notes> 267 * Alexiev fixed bug #5836 268 * Added test for info hash 269 </notes> 270 </release> 256 271 </changelog> 257 272 </package>