finished commitdiff page
[phpgitweb.git] / htdocs / lib / Tools.class.php
index c0b01b0cd15b406e931145b479073f44b3b0589b..7e02c68e90406d60be7dabbd829e66de8a17ec59 100644 (file)
@@ -128,6 +128,19 @@ class Tools {
                return $offset;
        }
        
+       public static function replaceTabs($line) {
+               while(($pos = strpos($line, "\t")) !== false) {
+                       $spacecount = 8 - ($pos % 8);
+                       $i = 1;
+                       while($line[$pos + $i] == "\t") { //maybe a little bit faster ;)
+                               $i++;
+                               $spacecount += 8;
+                       }
+                       $line = substr($line, 0, $pos).str_repeat(' ', $spacecount).substr($line, $pos + $i);
+               }
+               return $line;
+       }
+       
 }
 
 ?>
\ No newline at end of file