PPRINT -- Postscript pretty-printer for C/C++/Verilog and text

DESCRIPTION

PPRINT generates source code listings in postscript. It italicizes comments, boldfaces typedefs, and bold-italicizes keywords. It generates line numbers and a cross reference of all typedefs, static and global functions, listing both definitions and references. Definitions are in bold.

PPRINT manages print-outs of multiple files by producing both global and local page numbers. At the end of the run, it prints out a table of contents, and index, and a reference of all globally accessible typedefs and classes.

PPRINT works with C files, C++ files, Verilog files, and text files. It figures out which language based on extension:

SuffixLanguage
.cC
.ccC++
.cppC++
.CPPC++
.CC++
.yYacc
.hC or C++, depending on whether -h_is_cc flag is set
.hC++
.vVerilog
.vhVerilog

Other extensions are interpreted as straight text. This is useful for merging in ascii documentation, other languages, README files, etc.

C and C++ files can be parsed using the preprocessor, in order to see definitions hidden by macros, to suppress cross-referencing code that that is #ifdef'd out, and to cross reference typedefs that occur in include files that are not being printed in the same run of pprint. This is slower, of course, since it has to run the preprocessor, and requires that the user provide the include path (actually the whole call to the C preprocessor) as an argument.

Using the preprocessor is optional -- pprint can handle most C and C++ files directly -- it just won't cross-reference or boldface typedefs defined in includes, unless the include files are also printed in the same run. The preprocessor may be needed if a preprocessor-blind reading of the code would be syntactically invalid. This can occur when ifdefs are used to disable incomplete code, or when ifdefs are used inside function definitions, and ignoring them might cause parentheses or braces to appear unbalanced.

EXAMPLES

     pprint src1/*.h src1/*.h src2/*.c src2/*.h | lpr
     pprint +h_is_cc README *.doc *.h *.cc       \
         +preprocess -cpp "g++ -E -I../include"  \
         >src_code.ps
     lpr src_code.ps
     pprint -line_numbers 0 text_file.txt | lpr
     pprint +landscape *.cc | lpr
     pprint +courier -size 5 *.cc | lpr

SWITCHES

SwitchDefaultDescription
-border 18 Border spacing to edge of page, in printer points
+clip (turn on), -clip (turn off)On Clip the text so it doesn't overrwrite the next column
-columns 2 Number of output columns
+courier (turn on), -courier (turn off)Off Print in landscape mode with a courier font, like a2ps, but with the cross-referencing, boldfacing, and italicizing.
-cpp "gcc -E" Command to use to run the C Preprocessor. This should include all include directories, and be enclosed in double-quotes.
-expand 100 Expand or shrink the value of spaces in column alignment. The value is expressed as a percentage. 100 keeps it the same. 50 will cut columns in half, 200 will double them.
+h_is_cc (turn on), -h_is_cc (turn off)Off Interpret .h files as C++
-header_size 4 Size of line numbers in printer points, relative to size
+landscape (turn on), -landscape (turn off)Off Print in landscape mode (sideways)
-line_numbers 5 Number of lines to skip in between printed line numbers A value of 0 means no line numbers are printed.
-linesep 0 Line-to-line separation in printer points
-loglevel 0 0=warnings only, 1=filenames, 2=pages
-npages 10000 Maximum number of pages to print (0 means infinite)
-number_size -2 Size of line numbers in printer points, relative to size
-offset 18 Distance between the source text, and the offset line numbers and line-wrap indicators, (+), in printer points
+preprocess (turn on), -preprocess (turn off)Off Run the C or C++ preprocessor on appropriate input files. To specify a preprocessor program and options, use -cpp. You will need to use the preprocessor if the code you are printing hides a large amount of invalid syntax with ifdefs. Pprint will emit lots of parse error messages, which will go away if you use the preprocessor.
-size 7 Size of text in printer points
-start 1 Page number at which to start printing, starting at 1
-tab 8 Tab width of input files, in characters
+wrap (turn on), -wrap (turn off)On Wrap around long lines of text
-wrap_indent 0 Number of printer points to indent wrapped lines

AUTHOR

Joshua Marantz (josh@ikos.com) Created 1/22/93

Last updated $Date: 1997/02/24 19:54:04 $

SAMPLE OUTPUT

DOWNLOADING

PPRINT is distributed in source code form. It has been tested on Suns, using SunOS 4.1.3 and Solaris 2.5. It is written in C, but has only been compiled with gcc. Please send back any patches to make this compile in other environments.

There is one known Unix dependency in the source code, other than include file details, which is the use of "popen" to run the C preprocessor on input files. Apart from that, I believe a PC port would be straightforward, requiring only fixing the names of include files, etc.

Download (40k tar.gz file)

Download (43k zip file)

OTHER PRETTY-PRINTERS

A2PS: A highly configurable, general purpose text-to-postscript converter

GNU Enscript: a free replacement for Adobe's Enscript