Index: FCKeditor/trunk/_dev/fixlineends.php
===================================================================
--- FCKeditor/trunk/_dev/fixlineends.php	(revision 1562)
+++ FCKeditor/trunk/_dev/fixlineends.php	(revision 1563)
@@ -2,26 +2,26 @@
 <?php
 /*
- * FCKreleaser - FCKeditor Releaser - http://www.fckeditor.net
- * Copyright (C) 2003-2007 Frederico Caldeira Knabben
- *
- * == BEGIN LICENSE ==
- *
- * Licensed under the terms of any of the following licenses at your
- * choice:
- *
- *  - GNU General Public License Version 2 or later (the "GPL")
- *    http://www.gnu.org/licenses/gpl.html
- *
- *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
- *    http://www.gnu.org/licenses/lgpl.html
- *
- *  - Mozilla Public License Version 1.1 or later (the "MPL")
- *    http://www.mozilla.org/MPL/MPL-1.1.html
- *
- * == END LICENSE ==
- *
- * Script for automatic line-ending corrections.
- * Requires PHP5 to run: http://www.gophp5.org/ ;)
- */
+* FCKreleaser - FCKeditor Releaser - http://www.fckeditor.net
+* Copyright (C) 2003-2007 Frederico Caldeira Knabben
+*
+* == BEGIN LICENSE ==
+*
+* Licensed under the terms of any of the following licenses at your
+* choice:
+*
+*  - GNU General Public License Version 2 or later (the "GPL")
+*    http://www.gnu.org/licenses/gpl.html
+*
+*  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+*    http://www.gnu.org/licenses/lgpl.html
+*
+*  - Mozilla Public License Version 1.1 or later (the "MPL")
+*    http://www.mozilla.org/MPL/MPL-1.1.html
+*
+* == END LICENSE ==
+*
+* Script for automatic line-ending corrections.
+* Requires PHP5 to run: http://www.gophp5.org/ ;)
+*/
 
 error_reporting(E_ALL);
@@ -90,4 +90,9 @@
 $eofstripwhite = false;
 /**
+ * Strip whitespace from the end of line
+ * @var boolean $eolstripwhite
+ */
+$eolstripwhite = false;
+/**
  * Force new line character at the end of file
  * @var boolean $eofnewline
@@ -121,5 +126,5 @@
  * -1 to disable
  *  0 to fix only current directory
- * 
+ *
  * @var integer $maxdepth
  */
@@ -130,5 +135,5 @@
  * example:
  * --excluderegex = "/(\.\w+)$/"
- * 
+ *
  * @var string $excluderegex
  */
@@ -140,4 +145,10 @@
  */
 $windows = (strtolower(substr(PHP_OS, 0, 3)) == "win");
+
+/**
+ * Count saved bytes
+ * @var integer $saved_bytes
+ */
+$saved_bytes = 0;
 
 /**
@@ -201,9 +212,10 @@
  * @param string $path relative or absolute path name to file
  * @param string $nl name of a constant that holds new line character (CRLF|CR|LF)
- * @return bool 
+ * @return bool
  */
 function fixFile($path, $nl) {
 
     $contents = file($path);
+    $size = filesize($path);
     if ($contents === false) {
         echo "\rERROR: couldn't read the " . $path . " file". "\n";
@@ -312,4 +324,11 @@
                 break;
         }
+        if ($GLOBALS['eolstripwhite']) {
+            $before = strlen($line);
+            $line = preg_replace("/(?:\x09|\x20)+((?:\r|\n)+)$/", "$1", $line);
+            if (strlen($line) != $before) {
+                $modified = true;
+            }
+        }
         $new_content .= $line;
     }
@@ -325,5 +344,16 @@
                 fwrite($fp, $new_content);
                 flock($fp, LOCK_UN);
-                echo "\rMODIFIED to " . $nl . ": " . $path . "\n";
+                echo "\rMODIFIED to " . $nl . ": " . $path ;
+                if ($GLOBALS['eolstripwhite']) {
+                    $saved = $size - strlen($new_content);
+                    $GLOBALS['saved_bytes'] += $saved;
+                    if ($saved>0) {
+                        echo " (saved " . $saved . "B)";
+                    }
+                    else if ($saved<0) {
+                        echo " (" . abs($saved) . "B added)";
+                    }
+                }
+                echo "\n";
             } else {
                 echo "\rERROR: couldn't lock the " . $path . " file". "\n";
@@ -417,11 +447,10 @@
 function printHelp() {
     $help = <<<HELP
-    
+
 SYNOPSIS
        php fixlineends.php [options] PATH [PATH2...]
-       grep [options] [-e PATTERN | -f FILE] [FILE...]
 
 DESCRIPTION
-       Traverse recursively all the paths given and fix line endings 
+       Traverse recursively all the paths given and fix line endings
        in each file.
 
@@ -429,20 +458,23 @@
        --eofnewline
             force new line character at the end of file
-       
+
        --eofstripwhite
             strip whitespace from the end of file
-       
+
+       --eolstripwhite
+            strip whitespace from the end of line (spaces, tabs)
+
        --excluderegex=regex
             use regex to exclude files, preg_match() format expected
-            
+
        --help
             display this help and exit
-            
+
        --noarchive
             if set to true, archive files are skipped (Windows only)
-       
+
        --nodotfiles
             if set to true, dot files are skipped
-            
+
        --nohidden
             if set to true, hidden files are skipped (Windows only)
@@ -450,21 +482,21 @@
        --nosystem
             if set to true, system files are skipped (Windows only)
-            
+
        --maxdepth
-            fix line ends only if file is N or fewer levels below 
-            the command line argument; Use --max-depth=0 to omit 
+            fix line ends only if file is N or fewer levels below
+            the command line argument; Use --max-depth=0 to omit
             subdirectories
-            
+
 EXAMPLES
-            php fixlineends.php --eofstripwhite --eofnewline --maxdepth=1 
+            php fixlineends.php --eofstripwhite --eofnewline --maxdepth=1
                 --nodotfiles --excluderegex=/\_private/ .
-       
-       This command fixes line endings in current directory and in 
+
+       This command fixes line endings in current directory and in
        subdirectories placed one level below. Dot files are skipped.
        Paths that match "_private" are skipped. White chars are stripped
        at the end of file. New line character is added to the end of file
        (if required).
-       
-       
+
+
 HELP;
     echo $help;
@@ -513,5 +545,5 @@
                 $GLOBALS['excluderegex'] = $arg[1];
                 break;
-                
+
             case '--eofnewline':
                 $GLOBALS['eofnewline'] = true;
@@ -520,4 +552,8 @@
             case '--eofstripwhite':
                 $GLOBALS['eofstripwhite'] = true;
+                break;
+
+            case '--eolstripwhite':
+                $GLOBALS['eolstripwhite'] = true;
                 break;
         }
@@ -554,8 +590,8 @@
 
     if ($windows) {
-        $longoptions = array("eofstripwhite", "eofnewline", "help", "noarchive", "nohidden", "nosystem", "nodotfiles", "maxdepth=", "excluderegex=");
+        $longoptions = array("eofstripwhite", "eofnewline", "eolstripwhite", "help", "noarchive", "nohidden", "nosystem", "nodotfiles", "maxdepth=", "excluderegex=");
     }
     else {
-        $longoptions = array("eofstripwhite", "eofnewline", "help", "nodotfiles", "maxdepth=", "excluderegex=");
+        $longoptions = array("eofstripwhite", "eofnewline", "eolstripwhite", "help", "nodotfiles", "maxdepth=", "excluderegex=");
     }
 
@@ -579,2 +615,8 @@
 
 print "\rDone!".str_repeat(" ",40)."\n";
+if ($saved_bytes>0) {
+    echo "saved " . $saved_bytes . "B";
+}
+else if ($saved_bytes<0) {
+    echo abs($saved_bytes) . "B added";
+}
