Index: /trunk/doc/misc/.perltidyrc
===================================================================
--- /trunk/doc/misc/.perltidyrc	(revision 2377)
+++ /trunk/doc/misc/.perltidyrc	(revision 2377)
@@ -0,0 +1,34 @@
+# indent 4 spaces
+-i=4
+
+# continuation indenting is also 4 spaces
+-ci=4
+
+# maximum line length
+-l=110
+
+# edit in place but backup the file first
+-b
+
+# cuddled elses
+-ce
+
+# line up the closing parentheses with the begining of the statement
+-lp
+
+# Cish tight containers
+-bt=2
+-pt=2
+-sbt=2
+
+# place the brace on the right after a multiline expression
+-bar
+
+# don't indent closing tokens
+-cti=0
+
+# no spaces before semicolons in Cish for loops
+-nsfs
+
+# no outdenting long quotes
+-nolq
Index: /trunk/doc/misc/parseErrorCodes.pl
===================================================================
--- /trunk/doc/misc/parseErrorCodes.pl	(revision 2377)
+++ /trunk/doc/misc/parseErrorCodes.pl	(revision 2377)
@@ -0,0 +1,97 @@
+#!/usr/bin/perl
+
+# Provides functions for handling long command line options
+use Getopt::Long;
+
+my @ErrorCodes        = ();
+my @ErrorDescriptions = ();
+
+my $data = "psErrorCodes.dat";
+
+# Assign variables based on the presence of command line options to the script
+GetOptions(
+    "data=s"  => \$data,
+    "verbose" => \$verbose,
+    "help"    => \$help
+);
+
+if ($help) {
+    print "Usage: parseErrorCodes ", "[--data=$data] ", "[--help] ",
+      "[--verbose] filename [filename ...]\n\n";
+    exit(0);
+}
+
+print "Using data file '$data'\n" if $verbose;
+unless ( open( DATAFILE, "<", $data ) ) {
+    die "Can not open data file $data.";
+}
+
+print "Datafile:\n" if $verbose;
+while (<DATAFILE>) {
+    chop;
+    if (/^\s*\#/) {
+        print "C $_\n" if $verbose;
+    }
+    else {
+        if (/^\s*(\w+)\s+([\%\w].*)/) {
+            my $ErrorCode        = $1;
+            my $ErrorDescription = $2;
+            print "  $ErrorCode: '$ErrorDescription'\n" if $verbose;
+            push( @ErrorCodes,        $ErrorCode );
+            push( @ErrorDescriptions, $ErrorDescription );
+        } else {
+            print "I $_\n" if $verbose;
+        }
+    }
+}
+close(DATAFILE);
+
+my $found = $#ErrorCodes + 1;
+print "\nFound $found error codes.\n" if $verbose;
+
+foreach (@ARGV) {
+    my $filename = $_;
+    my @result   = ();
+
+    die "Failed to open input file"
+      if !open( INFILE, "<", $filename );
+
+    print "\nOutput File:\n" if $verbose;
+    while (<INFILE>) {
+        chop;
+        push( @result, $_ );
+        if (/^\s*\/\/~Start(.*)$/) {
+            $line = $1;
+            for ( $n = 0 ; $n < $found ; $n++ ) {
+                $_ = $line;
+                s/\$1/$ErrorCodes[$n]/g;
+                s/\$2/$ErrorDescriptions[$n]/g;
+                s/\$n/$n/g;
+                push( @result, $_ );
+                print "$_\n" if $verbose;
+            }
+
+            $break = 0;
+            while ( ( $break == 0 ) && ( $_ = <INFILE> ) ) {
+                if (/^\s*\/\/~End/) {
+                    $break = 1;
+                }
+            }
+            chop;
+            push( @result, $_ );
+        }
+    }
+
+    close(INFILE);
+
+    die "Failed to overwrite input file"
+      if !open( OUTFILE, ">", $filename );
+
+    foreach (@result) {
+        print OUTFILE "$_\n";
+        print "$_\n" if $verbose;
+    }
+
+    close(OUTFILE);
+
+}
Index: /trunk/doc/misc/perlCodeConventions.tex
===================================================================
--- /trunk/doc/misc/perlCodeConventions.tex	(revision 2376)
+++ /trunk/doc/misc/perlCodeConventions.tex	(revision 2377)
@@ -1,4 +1,6 @@
-%%% $Id: perlCodeConventions.tex,v 1.18 2004-11-16 21:20:22 jhoblitt Exp $
+%%% $Id: perlCodeConventions.tex,v 1.19 2004-11-16 22:15:07 jhoblitt Exp $
 \documentclass[panstarrs]{panstarrs}
+
+\usepackage{verbatim}
 
 % basic document variables
@@ -12,5 +14,5 @@
 \organization{Institute for Astronomy}
 \version{DR01}
-\docnumber{PSDC-430-010-DR}
+\docnumber{PSDC-430-010}
 
 \begin{document}
@@ -726,4 +728,5 @@
 the compound statement; the closing brace should begin a line and be
 indented to the beginning of the compound statement.
+\end{itemize}
 
 \subsection{return Statements}
@@ -1170,5 +1173,4 @@
 \end{verbatim}
 
-\end{document}
 %------------------------------------------------------------------------------
 \appendix				%Begin Appendices
@@ -1179,121 +1181,8 @@
 \label{SourceExample} 
 
-And here's the C source; \file{psUtils.h} provides \code{psAlloc/psFree}.
-
-\begin{verbatim}
-/*
- * This file implements an example of formatting a file of C code
- *
- * It isn't a very good piece of code
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <time.h>
-#include "psUtils.h"
-#include "psBuffer.h"
-
-typedef enum { CRNL, NL } NLType;
-
-static char *getNewline(NLType type);   // return a suitable newline
-
-static psBuffer *buf = NULL;            // I/O buffer
-
-/*****************************************************************************/
-/*
- * Create/destroy psBuffers
- */
-psBuffer *psBufferAlloc(void)
-{
-    psBuffer *buf = psAlloc(sizeof(psBuffer));
-    buf->n = 0;
-
-    return buf;
-}
-
-void psBufferFree(psBuffer *buf,         // buffer to delete
-                 int deep)              // NOTUSED. Do a deep delete
-{
-    if (buf == NULL) {
-        return;
-    }
-    
-    if (buf->n > 0) {
-        (void)fputs(buf->buf, stdout);
-    }
-    
-    psFree(buf);
-}
-
-/*****************************************************************************/
-/*
- * Append to a string to a psBuffer
- */
-void psBufferAppend(psBuffer *restrict buf, // psBuffer to append to
-                    const char *restrict str) // string to add
-{
-    assert(str != NULL);
-    const int len = strlen(str);
-
-    if (buf->n + len >= PS_BUFSIZE) {   // XXX Handle this better
-        fprintf(stderr, "Sorry; too many bytes. Bye bye\n");
-        abort();
-        exit(1);                        // NOTREACHED
-    }
-
-    (void)strcat(&buf->buf[buf->n], str);
-    buf->n += len;
-}    
-
-/*****************************************************************************/
-/*
- * Now do the work
- */
-int main(void)
-{
-    buf = psBufferAlloc();
-    long t;                               // current time
-
-    while(t = (long)time(NULL), t%3 == 2) {}
-    
-    if (t%3 == 0) {
-        psBufferAppend(buf, "Hello");
-    } else if (t%3 == 1) {
-        psBufferAppend(buf, "Aloha");
-    }
-    psBufferAppend(buf, " World!");
-
-    psBufferAppend(buf, getNewline(NL));
-
-    psBufferFree(buf, 0);
-
-    return 0;
-}
-
-/*****************************************************************************/
-/*
- * Return a desired line terminator
- */
-static char *getNewline(NLType type)    // what sort of newline?
-{
-    char *newline;                      // newline to add
-    switch (type) {
-      case CRNL:
-        newline = "\r\n";
-        break;
-
-      case NL:
-        newline = "\n";
-        break;
-
-      default:
-        newline = "NL";                     // FIXME
-        break;
-    }
-
-    return newline;
-}
-\end{verbatim}
+An example of \file{parseErrorCode.pl} that conforms with the Perl code
+convention.
+
+\verbatiminput{parseErrorCodes.pl}
 
 %------------------------------------------------------------------------------
@@ -1302,51 +1191,14 @@
 \label{perltidy}
 
-The purpose of a coding standard is to improve coding efficiency, not
-to hinder it.  Since people are inherently falible, 100\% adherence to
-the standard is an impossible goal for human-generated code.
-Furthermore, laziness and slopiness are human nature.  To minimize the
-amount of effort spent in keeping software in line with a coding
-standard is to use automatic re-formatting tools to enforce the
-standard.  Various software tools exist to perform these tasks.  One
-of these is \code{astyle}, an open-source tool which takes a variety
-of options which allow the use to tailor the coding standard to suit
-their preferences.  We have determined the following collection of
-astyle options which achieve the many of the coding standard
-guidelines specified above.  Note that any of the listed options
-(always in the 'long' form) may be specified in the user's
-\code{.astylerc} file by dropping the leading dash.
-
-\begin{itemize}
-\item \code{--mode=c} - This option tells \code{astyle} to recognize
-  the source code as C code.
-
-\item \code{--indent-switches} - This option tells \code{astyle} to
-  indent the \code{case} statements in a \code{switch}.  Do not also
-  specify \code{--indent-cases}.
-
-\item \code{--indent-labels} - This option tells \code{astyle} to add
-  indentation to labels so they are indented one level less than the
-  current level.
-
-\item \code{--min-conditional-indent=0} - This option tells
-  \code{astyle} not to add indentation to successive lines of
-  multiple-line conditional statements.
-
-\item \code{--max-instatement-indent=20} - This option tells
-  \code{astyle} to limit the total amount of indentation to 20 spaces.
-
-\item \code{--pad=oper} - This option tells \code{astyle} to add
-  padding about binary operators.
-
-\item \code{--brackets=break} - This option tells \code{astyle} to
-  break brackets from their pre-block statements, dropping them to the
-  next line.
-
-\item \code{--convert-tabs} - This option tells \code{astyle} to
-  convert tabs into the equivalent number of space characters.
-
-\item \code{--indent=spaces=4} - This option tells \code{astyle} to
-  use 4 spaces per indent level.
-\end{itemize}
+\code{pertidy} is a Perl specific code ``beautifier'' with functionality
+similar to \code{indent} or \code{astyle}.  It is freely avalible from
+\code{http://perltidy.sourceforge.net/}.
+
+\code{pertidy} can be configured with either command line switches or a
+\file{.perltidyrc} file in your home directory.
+
+Example \file{.perltidyrc} file to acheive the Perl code convention:
+
+\verbatiminput{.perltidyrc}
 
 \bibliographystyle{plain}
