r76651 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76650‎ | r76651 | r76652 >
Date:23:31, 13 November 2010
Author:aaron
Status:ok
Tags:
Comment:
Minor cleanups
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -33,7 +33,7 @@
3434 // An IPv6 block is an IP address and a prefix (d1 to d128)
3535 define( 'RE_IPV6_WORD', '([0-9A-Fa-f]{1,4})' );
3636 define( 'RE_IPV6_PREFIX', '(12[0-8]|1[01][0-9]|[1-9]?\d)');
37 -// An IPv6 address is made up of 8 words. However, the "::" abbreviations can be used.
 37+// An IPv6 address is made up of 8 words. However, the "::" abbreviation can be used.
3838 define( 'RE_IPV6_ADD',
3939 '(' . // starts with "::" (includes the address "::")
4040 '(::|:(:' . RE_IPV6_WORD . '){1,7})' .
@@ -175,12 +175,12 @@
176176 ? $CIDRStart - 1
177177 : strlen( $ip ) - 1;
178178 // If the '::' is at the beginning...
179 - if( $abbrevPos == 0 ) {
 179+ if ( $abbrevPos == 0 ) {
180180 $repeat = '0:';
181181 $extra = ( $ip == '::' ) ? '0' : ''; // for the address '::'
182182 $pad = 9; // 7+2 (due to '::')
183183 // If the '::' is at the end...
184 - } elseif( $abbrevPos == ( $addressEnd - 1 ) ) {
 184+ } elseif ( $abbrevPos == ( $addressEnd - 1 ) ) {
185185 $repeat = ':0';
186186 $extra = '';
187187 $pad = 9; // 7+2 (due to '::')
@@ -277,7 +277,7 @@
278278
279279 // ip2long accepts incomplete addresses, as well as some addresses
280280 // followed by garbage characters. Check that it's really valid.
281 - if( $ip != long2ip( $n ) ) {
 281+ if ( $ip != long2ip( $n ) ) {
282282 return false;
283283 }
284284
@@ -376,7 +376,7 @@
377377 */
378378 public static function toUnsigned( $ip ) {
379379 if ( self::isIPv6( $ip ) ) {
380 - $n = wfBaseConvert( self::IPv6ToRawHex( $ip ), 16, 10 );
 380+ $n = self::toUnsigned6( $ip );
381381 } else {
382382 $n = ip2long( $ip );
383383 if ( $n < 0 ) {
@@ -394,7 +394,7 @@
395395 * Convert a network specification in CIDR notation
396396 * to an integer network and a number of bits
397397 * @param string $range IP with CIDR prefix
398 - * @return array(int, int)
 398+ * @return array(int or string, int)
399399 */
400400 public static function parseCIDR( $range ) {
401401 if ( self::isIPv6( $range ) ) {
@@ -520,7 +520,7 @@
521521 * 2001:0db8:85a3::7344/96 CIDR
522522 * 2001:0db8:85a3::7344 - 2001:0db8:85a3::7344 Explicit range
523523 * 2001:0db8:85a3::7344/96 Single IP
524 - * @return array(string, int)
 524+ * @return array(string, string)
525525 */
526526 private static function parseRange6( $range ) {
527527 # Expand any IPv6 IP

Status & tagging log