Index: scripts/coder_format/README
===================================================================
RCS file: scripts/coder_format/README
diff -N scripts/coder_format/README
--- scripts/coder_format/README	7 Apr 2007 16:08:33 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,9 +0,0 @@
-This is a standalone script developed by sun that only concentrates on
-formatting code and the style review.
-
-This is an alternative approach to the coder module.  Having two different
-modules with different approaches is, in some ways an advantage, since each
-becomes - in effect - a unit test upon the other. This is a great way for them
-to both improve, and maintain accuracy in what is a very detail oriented area!
-
-See http://drupal.org/node/126938.
Index: scripts/coder_format/README.txt
===================================================================
RCS file: scripts/coder_format/README.txt
diff -N scripts/coder_format/README.txt
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ scripts/coder_format/README.txt	16 Jan 2008 11:02:56 -0000
@@ -0,0 +1,85 @@
+/* $Id$ */
+
+-- SUMMARY --
+
+This is a standalone script developed by sun (http://drupal.org/user/54136) that
+only concentrates on re-formatting code and style review.
+
+Coder Format alters source code files directly. Although this script is
+state-of-the-art, be sure to backup your source files in front of executing this
+script. If executed on a directory, the script automatically creates backup
+copies of all changed files.
+
+This is an alternative approach to the Coder module. Having two different
+modules with different approaches is in some ways an advantage, since each
+becomes - in effect - a unit test upon the other. This is a great way for them
+to both improve, and maintain accuracy in what is a very detail oriented area!
+
+See http://drupal.org/node/126938.
+
+
+-- REQUIREMENTS --
+
+* PHP command line interpreter.
+* Path to includes/file.inc of a Drupal core codebase.
+
+
+-- USAGE --
+
+See coder_format.php.
+
+
+-- INSTALLATION (WINDOWS) --
+
+Coder Format provides a Windows Explorer context menu extension that allows you
+to run Coder Format on single PHP files or complete directory trees.
+
+WARNING: Do not proceed unless you know what you are doing!
+
+- Copy all files of this directory to a central location. If you like to,
+  c:\program files\coder_format\ is okay, too.
+
+- Open coder_format.reg in your preferred editor and replace all instances of
+
+  c:\\program files\\coder_format
+
+  with the path of your chosen central location. Be sure to escape backslashes
+  with another backslash (as shown above).
+
+- "Merge" coder_format.reg into your Windows Registry using the "Merge" command
+  in the context menu.
+
+- Open coder_format.cmd in your preferred editor and replace the path in
+  
+  set coderFormatPath=c:\program files\coder_format
+
+  with the path of your chosen central location. Afterwards, adjust the location
+  of file.inc in
+
+  set fileInc=c:\program files\coder_format\file.inc
+
+  according to your local Drupal installation, i.e.
+
+  set fileInc=c:\inetpub\www\path\to\drupal\includes\file.inc
+
+  It is also possible to copy file.inc from a Drupal 5 installation to the
+  central location and adjust the path accordingly.
+
+- Done. Context menus of PHP files and directories should include the following
+  commands now:
+
+  - Clean Coding Style...
+  - Unclean Coding Style... (directories only)
+
+
+-- CONTACT --
+
+Current maintainers:
+* Daniel F. Kudwien (sun) - dev@unleashedmind.com
+
+This project has been sponsored by:
+* UNLEASHED MIND
+  Specialized in consulting and planning of Drupal powered sites, UNLEASHED
+  MIND offers installation, development, theming, customization, and hosting
+  to get you started. Visit http://www.unleashedmind.com for more information.
+
Index: scripts/coder_format/coder_format-uninstall.reg
===================================================================
RCS file: scripts/coder_format/coder_format-uninstall.reg
diff -N scripts/coder_format/coder_format-uninstall.reg
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ scripts/coder_format/coder_format-uninstall.reg	6 Jun 2007 17:50:41 -0000
@@ -0,0 +1,10 @@
+Windows Registry Editor Version 5.00
+
+[-HKEY_CLASSES_ROOT\phpfile\shell\coder_format]
+
+[-HKEY_CLASSES_ROOT\Directory\shell\coder_format]
+[-HKEY_CLASSES_ROOT\Directory\shell\coder_format_undo]
+
+[-HKEY_CLASSES_ROOT\Folder\shell\coder_format]
+[-HKEY_CLASSES_ROOT\Folder\shell\coder_format_undo]
+
Index: scripts/coder_format/coder_format.cmd
===================================================================
RCS file: scripts/coder_format/coder_format.cmd
diff -N scripts/coder_format/coder_format.cmd
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ scripts/coder_format/coder_format.cmd	6 Jun 2007 17:46:03 -0000
@@ -0,0 +1,52 @@
+@echo off
+rem $Id$
+
+rem Define Coder Format shell invocation script path.
+set coderFormatPath=c:\program files\coder_format
+rem Define location of Drupal's file.inc.
+set fileInc=c:\program files\coder_format\file.inc
+
+
+:: ----- You should not need to edit anything below. ----- ::
+
+set oldpwd=%CD%
+cd /d "%coderFormatPath%"
+
+rem Simple file extension check, won't work with directories containing a dot.
+if '%1'=='--undo' goto undo-directory
+if '%~x1'=='' goto directory
+goto file
+
+:undo-directory
+rem Undo source code formattings performed by --batch-replace
+rem Process directory.
+if "%~2"=="" goto :EOF
+start "coder_format" /D "%coderFormatPath%" /B /WAIT php coder_format.php --undo "%~2" --file-inc "%fileInc%"
+goto processed
+
+:directory
+rem Recursively format all source code files in a directory.
+rem Process directory.
+if "%~1"=="" goto :EOF
+start "coder_format" /D "%coderFormatPath%" /B /WAIT php coder_format.php --batch-replace "%~1" --file-inc "%fileInc%"
+goto processed
+
+:file
+rem Format a single source code file.
+rem Define source and target files by command line arguments.
+set sourcefile=%~1
+if not '%~2'=='' (
+	set targetfile=%~2
+) else (
+	set targetfile=%~1
+)
+rem Process file.
+if "%sourcefile%"=="" goto :EOF
+if "%targetfile%"=="" goto :EOF
+start "coder_format" /D "%coderFormatPath%" /B /WAIT php coder_format.php "%sourcefile%" "%targetfile%" --file-inc "%fileInc%"
+
+
+:processed
+rem Jump back to original working directory.
+cd /d "%oldpwd%"
+
Index: scripts/coder_format/coder_format.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/scripts/coder_format/coder_format.inc,v
retrieving revision 1.2.4.2
diff -u -p -r1.2.4.2 coder_format.inc
--- scripts/coder_format/coder_format.inc	9 Jan 2008 13:31:12 -0000	1.2.4.2
+++ scripts/coder_format/coder_format.inc	16 Jan 2008 10:53:05 -0000
@@ -829,8 +829,8 @@ function coder_preprocessor_line_breaks_
   return array(
     '#title' => 'Convert Windows line breaks to Unix format.',
     '#weight' => 1,
-    '#search' => '/\r\n/',
-    '#replace' => '\n',
+    '#search' => "/\r\n/",
+    '#replace' => "\n",
   );
 }
 
@@ -838,8 +838,8 @@ function coder_preprocessor_line_breaks_
   return array(
     '#title' => 'Convert Macintosh line breaks to Unix format.',
     '#weight' => 2,
-    '#search' => '/\r/',
-    '#replace' => '\n',
+    '#search' => "/\r/",
+    '#replace' => "\n",
   );
 }
 
@@ -899,7 +899,7 @@ function coder_preprocessor_switch_dupli
  */
 function coder_postprocessor_cvs_id() {
   return array(
-    '#title' => 'If the CVS keyword $Id: coder_format.inc,v 1.2.4.2 2008/01/09 13:31:12 douggreen Exp $ already exists, append a new line after it.',
+    '#title' => 'If the CVS keyword Id already exists, append a new line after it.',
     '#search' => '@^(//.*\$Id.*\$)$@m',
     '#replace' => "$1\n",
   );
@@ -958,7 +958,7 @@ function coder_postprocessor_array_rearr
     // ((.+ => .+, ){3,}) matches all array items, except the last one.
     // (.+ => ([^\(\)]+)) matches the last array item, excluding.
     //   arrays or functions (starting with a left parenthesis) (not supported yet).
-    '#search' => '/^([\040\t]*)(.*?array\()((.+ => .+, ){3,})(.+ => ([^\(\)]+))\)/m',
+    #'#search' => '/^([\040\t]*)(.*?array\()((.+ => .+, ){3,})(.+ => ([^\(\)]+))\)/m',
     '#replace_callback' => 'coder_replace_array_rearrange',
   );
 }
Index: scripts/coder_format/coder_format.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/scripts/coder_format/coder_format.php,v
retrieving revision 1.2.4.1
diff -u -p -r1.2.4.1 coder_format.php
--- scripts/coder_format/coder_format.php	9 Jan 2008 13:31:12 -0000	1.2.4.1
+++ scripts/coder_format/coder_format.php	16 Jan 2008 10:54:52 -0000
@@ -49,40 +49,44 @@ if (!empty($_SERVER['argv'])) {
   // Remove self-reference.
   array_shift($_SERVER['argv']);
   
+  $files    = array();
   $undo     = false;
   $file_inc = null;
   
-  foreach ($_SERVER['argv'] as $arg) {
-    switch ($arg) {
+  for ($c = 0, $cc = count($_SERVER['argv']); $c < $cc; ++$c) {
+    switch ($_SERVER['argv'][$c]) {
       case '--undo':
-        $op   = array_shift($_SERVER['argv']);
-        $root = array_shift($_SERVER['argv']);
+        ++$c;
+        $root = $_SERVER['argv'][$c];
         $undo = true;
-        coder_format_recursive($root, true);
         break;
         
       case '--batch-replace':
-        $op   = array_shift($_SERVER['argv']);
-        $root = array_shift($_SERVER['argv']);
+        ++$c;
+        $root = $_SERVER['argv'][$c];
         break;
         
       case '--file-inc':
-        array_shift($_SERVER['argv']);
-        $file_inc = array_shift($_SERVER['argv']);
+        ++$c;
+        $file_inc = $_SERVER['argv'][$c];
+        break;
+      
+      default:
+        $files[] = $_SERVER['argv'][$c];
         break;
     }
   }
   
   if (isset($root)) {
     coder_format_recursive($root, $undo, $file_inc);
-    exit;
   }
-  
-  // Process a single file.
-  $sourcefile = array_shift($_SERVER['argv']);
-  $targetfile = array_shift($_SERVER['argv']);
-  
-  coder_format_file($sourcefile, $targetfile);
+  else {
+    // Process a single file
+    $sourcefile = $files[0];
+    $targetfile = $files[1];
+    
+    coder_format_file($sourcefile, $targetfile);
+  }
 }
 
 
Index: scripts/coder_format/coder_format.reg
===================================================================
RCS file: scripts/coder_format/coder_format.reg
diff -N scripts/coder_format/coder_format.reg
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ scripts/coder_format/coder_format.reg	6 Jun 2007 17:50:31 -0000
@@ -0,0 +1,32 @@
+Windows Registry Editor Version 5.00
+
+[HKEY_CLASSES_ROOT\phpfile\shell\coder_format]
+@="&Clean Coding Style..."
+
+[HKEY_CLASSES_ROOT\phpfile\shell\coder_format\command]
+@="c:\\program files\\coder_format\\coder_format.cmd \"%1\""
+
+[HKEY_CLASSES_ROOT\Directory\shell\coder_format]
+@="&Clean Coding Style..."
+
+[HKEY_CLASSES_ROOT\Directory\shell\coder_format\command]
+@="c:\\program files\\coder_format\\coder_format.cmd \"%1\""
+
+[HKEY_CLASSES_ROOT\Directory\shell\coder_format_undo]
+@="&Unclean Coding Style..."
+
+[HKEY_CLASSES_ROOT\Directory\shell\coder_format_undo\command]
+@="c:\\program files\\coder_format\\coder_format.cmd --undo \"%1\""
+
+[HKEY_CLASSES_ROOT\Folder\shell\coder_format]
+@="&Clean Coding Style..."
+
+[HKEY_CLASSES_ROOT\Folder\shell\coder_format\command]
+@="c:\\program files\\coder_format\\coder_format.cmd \"%1\""
+
+[HKEY_CLASSES_ROOT\Folder\shell\coder_format_undo]
+@="&Unclean Coding Style..."
+
+[HKEY_CLASSES_ROOT\Folder\shell\coder_format_undo\command]
+@="c:\\program files\\coder_format\\coder_format.cmd --undo \"%1\""
+
