This version of indent should clean compile under BSD UNIX cc or any ANSI C
compiler, under any operating system (BSD UNIX, DOS and OS2 definatly).
It is backward compatible with all previous versions except that:
Profile files are no longer hidden files under UNIX,
Arguments must now be separated from options with a ':' e.g. -c:33
Option names can't start with an 'n'
Option -bl is now called -nbr.
Options -cci:n and -cli:n now take a number of spaces as an argument, rather
than a fractional tab stop.
These changes were made to simplify the argument parsing and improve
portability. (See Vanilla C port, below).
Peter Hadfield ([email protected]
This is the ReadMe file that came with the first version of indent that I
managed to recompile. Sorry, can't remember where it came from. PH.
This is the C indenter, it originally came from the University of Illinois via
some distribution tape for PDP-11 UNIX. It has subsequently been hacked upon
by James Gosling @ CMU. It isn't very pretty, and really needs to be
completely redone, but it is probably the nicest C pretty printer around.
Further additions to provide "Kernel Normal Form" were contributed by the
folks at Sun Microsystems.
> From [email protected]
Wed Mar 9 15:30:55 1988
> Date: Tue, 8 Mar 88 18:36:25 EST
> From: [email protected]
> To: [email protected]
> Cc: [email protected]
, [email protected]
, [email protected]
> In-Reply-To: Keith Bostic's message of Tue, 16 Feb 88 16:09:06 PST
> Subject: Re: Indent...
Thank you for your response about indent. I was wrong in my original
observation (or mis-observation :-). UCB did keep the Illinois copyright
The issue still is whether we can distribute indent, and if we can, which
version. David Willcox (the author) states that:
Several people have asked me on what basis I claim that indent is in the
public domain. I knew I would be sorry I made that posting.
Some history. Way back in 1976, the project I worked on at the University
of Illinois Centre for Advanced Computation had a huge battle about how to
format C code. After about a week of fighting, I got disgusted and wrote a
program, which I called indent, to reformat C code. It had a bunch of
different options that would let you format the output the way you liked. In
particular, all of the different formats being championed were supported.
It was my first big C program. It was ugly. It wasn't designed, it just
sort of grew. But it pretty much worked, and it stopped most of the
As a matter of form, I included a University of Illinois Copyright notice.
However, my understanding was that, since the work was done on an ARPA
contract, it was in the public domain.
Time passed. Some years later, indent showed up on one of the early emacs
Later still, someone from UC Berkeley called the UofI and asked if indent
was in the public domain. They wanted to include it in their UNIX
distributions, along with the emacs stuff. I was no longer at the UofI, but
Rob Kolstad, who was, asked me about it. I told him I didn't care if they
used it, and since then it has been on the BSD distributions.
Somewhere along the way, several other unnamed people have had their hands
in it. It was converted to understand version 7 C. (The original was
version 6.) It was converted from its original filter interface to its
current "blow away the user's file" interface. The $HOME/.indent.pro file
parsing was added. Some more formatting options were added.
The source I have right now has two copyright notices. One is the original
from the UofI. One is from Berkeley.
I am not a lawyer, and I certainly do not understand copyright law. As far as
I am concerned, the bulk of this program, everything covered by the UofI
copyright, is in the public domain, and worth every penny. Berkeley's
copyright probably should only cover their changes, and I don't know their
feelings about sending it out.
In any case, there appears to be noone at UofI to clarify/and change that
copyright, but I am confident (based on the statements of its author) that the
code, as it stands with its copyright, is distributable, and will not cause
any legal problems.
Hence, the issue reduces to *which* one to distribute through
comp.sources.unix. I would suggest that with the permission of you folks
(given that you have parts copyrighted), we distribute the 4.3 version of
indent, which appears to be the most up-to-date version. I happen to have just
about every known version of indent, including the very original submission
from the author to a UNIX tape, later the G-Emacs version, any 4.n version,
sun version and the Unipress version. I still think we should not have to
"go-back-in-time" and re-do all the work you people have done.
I hope to hear from you as to what you think about this. You may of course
send 4.3 version to the moderator directly, or you can let me know of your
permission, and I will send the sources, or you can let me know that 4.3
version is off-limits, in which case we would probably have to revert to an
older version. One way or another, I hope to get a version of indent to
VANILLA C (AND DOS) PORT
Peter Hadfield, 4-04-93.
Ported to Vanilla C, now clean compiles with all the warnings turned on (SUN
BSD UNIX cc & gcc & DOS Borland C++ (set to strict ANSI C)). Source code
cleaned up and encapsulation improved.
Command line option scanning rewritten. Option names cannot now start with a
'n', options and their arguments must be separated by a ':'. This greatly
simplified the argument parsing routine.
Several files can be specified on the command line or a list of files can be
specified. The infile, outfile operation was not very useful and it was too
easy to shoot yourself in the foot.
Options -tabu and -tabu added. Option -bl is now -nbr for consistency. Options
-cli:n now takes an integer number of spaces, rather than a float (this
simplifies command line processing).
indent.pro is no longer a UNIX hidden file for DOS compatibility.
Usage and current option display added.
Added option -cp and support for spaces between '#' and if, else and endif.
Added C++ support by merging the C++ compatible code found in
Options -cci:n now take a number of spaces as an argument, rather than
a fractional tab stop.
indent.doc generated from indent.1 with: nroff -man indent.1
Added (most of) the improvements made by Jon Saxton who ported indent to OS2.
Part of his readme file follows:
> OS/2 implementor's note
> There seems to have been three streams of development for this program.
> The original indent came from the University of Illinois where it was
> apparently written in 1976. Some work was done by James Gosling and the
> people at Sun Microsystems. The program became part of the BSD UNIX
> distribution at some time not later than 1985. At around that time it was
> ported to DOS by Bruce Mallett and various fixes were done by Bruce
> Mallett and James Thompson. James Thompson also implemented the handling
> of tabs at spacings other than 8 (surely a most worthwhile enhancement;
> who programs in C with tabs set at 8 anyway?)
> While all this good stuff was going on, other (unnamed) people upgraded
> the original program to handle C++ syntax as well as ordinary C and
> apparently fixed a few minor annoyances which were extant in the version
> from which the DOS implementation was derived.
> Then of course, the GNU project people of the Free Software Foundation
> have been doing things with sources apparently derived from the BSD
> I have not looked at the GNU version of indent. I started with the BSD C++
> formatter sources from comp.misc.sources volume 21 and modified them for
> compilation with Microsoft C386 under OS/2 2.0. That gave me a working
> baseline version to which I made the following modifications:
> 1 Changed some of the file names to allow compilation with Microsoft C
> version 6.00A which objects to files whose names do not conform to
> DOS's 8.3 format.
> 2 Built new makefiles for OS/2 2.0 and for OS/2 1.X. (The DOS version
> is created by post-processing the OS/2 1.X version.)
> Note that when you use Makefile.1x you'll see some warning messages
> concerning the truncation of variable names. You may safely ignore
> them. The messages do not appear when compiling the 32-bit version.
> 2 Added James Thompson's tab stuff.
> 3 Fixed a bug which was causing //-style comments to be followed by an
> extra newline or an extra space depending on context.
> 4 Corrected the stack overflow problem in the OS/2 1.x and DOS
> versions. (This seems to have been independently discovered and fixed
> twice previously but the sources contained no trace of the fix.)
> 5 Patched the manual source to reflect the new -tabs option and generated
> a human-readable version.
> Finally, I put the sources through the indenter to clean up the mess.
> More recently still, I built the program using the IBM C Set/2 tools after
> modifying the 2.0 Makefile. I also:
> 6 Fixed a bug notified by Steve Comen which was causing over length //
> comments to be split incorrectly.
> 8 Modified the action of the -tabs:N specifier. If N is 2 or less then
> indent will not use tab characters in the output. This patch had the
> side-effect of avoiding a potential divide-by-zero fault which would
> have arisen if someone had said -tabs:0.
> Now, if I have done the job properly, the current source should combine
> both the BSD development streams. Furthermore, it should compile under
> OS/2 1.x for OS/2 and DOS, under OS/2 2.0 for the 32-bit 'flat' model
> using either the Microsoft C386 compiler or the IBM C Set/2 compiler and
> on the original BSD UNIX platform.
> I am indebted to Steve Comen and his colleagues for help with testing and
> verifying the BSD compatibility and for several patches.
> Now all that remains to be done is to incorporate the nicer features of
> this version into the GNU one. Any volunteers?
> Jon Saxton
> April 1992