Yet Another cabe Pretty Printer

Jay R. Ashworth jra at baylink.com
Thu Jun 24 11:04:20 PDT 2004


to add to your collection.  It tends to lean towards doing a better job
of code that does not have standalone comments on the IF line, so
people who use vi will likely like it somewhat better than people who
use dcabe.

It expects both the filename and the table name as arguments, so that
you can do things like

$ cd $PFDIR
$ for i in *
> do
> jcabe $i $i/prc.*
> done

and create entire documentation books.  Yes, you can specify the table
name with or without.

=================================8<===================================
# jcabe -- doesn't everyone have their own?
#
# usage: jcabe filename tablebasename

file=`basename $1`
shift
while test $1
do
    # allow tablename either way
    prc=`basename $1 | sed 's,prc.,,'`

    cd ${PFDIR:-/appl}/filepro/$file

    cat prc.$1 |
        # do the syntactical translations
        sed     \
                -e 's/:/        IF /'\
                -e 's/:/ THEN /'\
                -e 's/IF  THEN//'\
                -e 's//:/g'\
                -e 's/:$//' |
        # number the logical lines
        grep -n "." |
        # split logical to physical
        fold -s -w 75 |
        # and hang-indent the continuations
        sed     -e '/^[0-9]*:/!s/^/              /' |
        # then pretty print, cause it's all about the humans
        pr -h "$prc Processing Table for File $file "
    shift
done
=================================8<===================================

I'm digging in hard again this week, and found a need for this again --
I can suss the code a lot better 55 lines at a time.

One mod I might make to this would be to make it page break smarter; I
tend to separate major routines in my code with 

::':

which could be translated into a pagebreak.

Hope someone finds it useful.

Cheers,
-- jra
-- 
Jay R. Ashworth                                                jra at baylink.com
Designer                          Baylink                             RFC 2100
Ashworth & Associates        The Things I Think                        '87 e24
St Petersburg FL USA      http://baylink.pitas.com             +1 727 647 1274

                2004 Stanley Cup Champion Tampa Bay Lightning


More information about the Filepro-list mailing list