r54751 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54750‎ | r54751 | r54752 >
Date:21:30, 10 August 2009
Author:conrad
Status:deferred
Tags:
Comment:
How could I forget that x != x.lower().upper()
Modified paths:
  • /trunk/extensions/Transliterator/Transliterator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Transliterator/Transliterator.php
@@ -298,6 +298,7 @@
299299
300300 $sensitive = isset( $map["__sensitive__"] ); // Are we in case-sensitive mode, or not
301301 $ucfirst = false; // We are in case-sensitive mode and the first character of the current match was upper-case originally
 302+ $last_upper = null; // We have lower-cased the current letter, but we need to keep track of the original (dotted I for example)
302303 $withstart = false; // Have we inserted a start character into the current $current
303304
304305 $output = ""; // The output
@@ -354,12 +355,13 @@
355356 if ( $last_letter != $last_lower ) {
356357 $ucfirst = true;
357358 $letters[$last_match] = $last_lower;
 359+ $last_upper = $last_letter;
358360
359361 // Might be nice to output a ? if we don't understand
360362 } else if ( isset( $map[''] ) ) {
361363
362364 if ( $ucfirst ) {
363 - $output .= str_replace( '$1', mb_strtoupper( $last_letter ), $map[''] );
 365+ $output .= str_replace( '$1', $last_upper , $map[''] );
364366 $ucfirst = false;
365367 } else {
366368 $output .= str_replace( '$1', $last_letter, $map[''] );
@@ -371,7 +373,7 @@
372374 } else {
373375
374376 if ( $ucfirst ) {
375 - $output .= mb_strtoupper( $last_letter );
 377+ $output .= $last_upper;
376378 $ucfirst = false;
377379 } else {
378380 $output .= $last_letter;

Status & tagging log