Skip to content

Commit 4e831f4

Browse files
committed
Import pg_bsd_indent sources.
This brings in an exact copy of the pg_bsd_indent repo as of commit d301442799cea44e5ccb04331afc537764ec77c5 (2020-12-28). Discussion: https://postgr.es/m/3935719.1675967430@sss.pgh.pa.us Discussion: https://postgr.es/m/20200812223409.6di3y2qsnvynao7a@alap3.anarazel.de
1 parent dab07e8 commit 4e831f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+5737
-0
lines changed

src/tools/pg_bsd_indent/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Global excludes across all subdirectories
2+
*.o
3+
*.obj
4+
*.exe
5+
6+
# Local excludes in root directory
7+
/pg_bsd_indent
8+
/*.out
9+
/*.list
10+
/tests.diff

src/tools/pg_bsd_indent/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile for pg_bsd_indent
4+
#
5+
# Copyright (c) 2017, PostgreSQL Global Development Group
6+
#
7+
#-------------------------------------------------------------------------
8+
9+
PGFILEDESC = "pg_bsd_indent - indent C code nicely"
10+
PGAPPICON = win32
11+
12+
PROGRAM = pg_bsd_indent
13+
OBJS = args.o err.o indent.o io.o lexi.o parse.o pr_comment.o $(WIN32RES)
14+
15+
# clean junk left behind by "make test"
16+
EXTRA_CLEAN = *.out *.list tests.diff
17+
18+
PG_CONFIG = pg_config
19+
PGXS := $(shell $(PG_CONFIG) --pgxs)
20+
include $(PGXS)
21+
22+
# pgxs.mk assumes too much about what "make check" means, so call it "test"
23+
.PHONY: test
24+
25+
test: $(PROGRAM)
26+
@rm -f tests.diff
27+
@cp $(srcdir)/tests/*.list .
28+
@for testsrc in $(srcdir)/tests/*.0; do \
29+
test=`basename "$$testsrc" .0`; \
30+
./$(PROGRAM) $$testsrc $$test.out -P$(srcdir)/tests/$$test.pro || echo FAILED >>$$test.out; \
31+
diff -u $$testsrc.stdout $$test.out >>tests.diff 2>&1 || true; \
32+
done
33+
@cat tests.diff
34+
@test '!' -s tests.diff
35+
@echo Tests complete.

src/tools/pg_bsd_indent/README

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
2+
$FreeBSD: head/usr.bin/indent/README 105244 2002-10-16 13:58:39Z charnier $
3+
4+
This is the C indenter, it originally came from the University of Illinois
5+
via some distribution tape for PDP-11 Unix. It has subsequently been
6+
hacked upon by James Gosling @ CMU. It isn't very pretty, and really needs
7+
to be completely redone, but it is probably the nicest C pretty printer
8+
around.
9+
10+
Further additions to provide "Kernel Normal Form" were contributed
11+
by the folks at Sun Microsystems.
12+
13+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14+
> From mnetor!yunexus!oz@uunet.UU.NET Wed Mar 9 15:30:55 1988
15+
> Date: Tue, 8 Mar 88 18:36:25 EST
16+
> From: yunexus!oz@uunet.UU.NET (Ozan Yigit)
17+
> To: bostic@okeeffe.berkeley.edu
18+
> Cc: ccvaxa!willcox@uunet.UU.NET, jag@sun.com, rsalz@uunet.UU.NET
19+
> In-Reply-To: Keith Bostic's message of Tue, 16 Feb 88 16:09:06 PST
20+
> Subject: Re: Indent...
21+
22+
Thank you for your response about indent. I was wrong in my original
23+
observation (or mis-observation :-). UCB did keep the Illinois
24+
copyright intact.
25+
26+
The issue still is whether we can distribute indent, and if we can, which
27+
version. David Willcox (the author) states that:
28+
29+
| Several people have asked me on what basis I claim that indent is in
30+
| the public domain. I knew I would be sorry I made that posting.
31+
|
32+
| Some history. Way back in 1976, the project I worked on at the
33+
| University of Illinois Center for Advanced Computation had a huge
34+
| battle about how to format C code. After about a week of fighting, I
35+
| got disgusted and wrote a program, which I called indent, to reformat C
36+
| code. It had a bunch of different options that would let you format
37+
| the output the way you liked. In particular, all of the different
38+
| formats being championed were supported.
39+
|
40+
| It was my first big C program. It was ugly. It wasn't designed, it
41+
| just sort of grew. But it pretty much worked, and it stopped most of
42+
| the fighting.
43+
|
44+
| As a matter of form, I included a University of Illinois Copyright
45+
| notice. However, my understanding was that, since the work was done
46+
| on an ARPA contract, it was in the public domain.
47+
|
48+
| Time passed. Some years later, indent showed up on one of the early
49+
| emacs distributions.
50+
|
51+
| Later still, someone from UC Berkeley called the UofI and asked if
52+
| indent was in the public domain. They wanted to include it in their
53+
| UNIX distributions, along with the emacs stuff. I was no longer at the
54+
| UofI, but Rob Kolstad, who was, asked me about it. I told him I didn't
55+
| care if they used it, and since then it has been on the BSD distributions.
56+
|
57+
| Somewhere along the way, several other unnamed people have had their
58+
| hands in it. It was converted to understand version 7 C. (The
59+
| original was version 6.) It was converted from its original filter
60+
| interface to its current "blow away the user's file" interface.
61+
| The $HOME/.indent.pro file parsing was added. Some more formatting
62+
| options were added.
63+
|
64+
| The source I have right now has two copyright notices. One is the
65+
| original from the UofI. One is from Berkeley.
66+
|
67+
| I am not a lawyer, and I certainly do not understand copyright law. As
68+
| far as I am concerned, the bulk of this program, everything covered by
69+
| the UofI copyright, is in the public domain, and worth every penny.
70+
| Berkeley's copyright probably should only cover their changes, and I
71+
| don't know their feelings about sending it out.
72+
73+
In any case, there appears to be none at UofI to clarify/and change
74+
that copyright, but I am confident (based on the statements of its
75+
author) that the code, as it stands with its copyright, is
76+
distributable, and will not cause any legal problems.
77+
78+
Hence, the issue reduces to *which* one to distribute through
79+
comp.sources.unix. I would suggest that with the permission of you
80+
folks (given that you have parts copyrighted), we distribute the 4.3
81+
version of indent, which appears to be the most up-to-date version. I
82+
happen to have just about every known version of indent, including the
83+
very original submission from the author to a unix tape, later the
84+
G-Emacs version, any 4.n version, sun version and the Unipress
85+
version. I still think we should not have to "go-back-in-time" and
86+
re-do all the work you people have done.
87+
88+
I hope to hear from you as to what you think about this. You may of
89+
course send 4.3 version to the moderator directly, or you can let me
90+
know of your permission, and I will send the sources, or you can let
91+
me know that 4.3 version is off-limits, in which case we would probably
92+
have to revert to an older version. One way or another, I hope to get
93+
a version of indent to comp.sources.unix.
94+
95+
regards.. oz
96+
97+
cc: ccvaxa!willcox
98+
sun.com!jar
99+
uunet!rsalz
100+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
pg_bsd_indent
2+
3+
This is a lightly modified version of the "indent" program maintained
4+
by the FreeBSD project. The modifications are mostly to make it portable
5+
to non-BSD-ish platforms, though we do have one formatting switch we
6+
couldn't convince upstream to take.
7+
8+
To build it, you will need a Postgres installation, version 9.5 or newer.
9+
(Once built, the program doesn't depend on that installation.)
10+
11+
To build, just say "make"; or if pg_config from your Postgres installation
12+
isn't in your PATH, say
13+
make PG_CONFIG=path/to/pg_config
14+
Optionally, run "make test" for some simple sanity checks.
15+
16+
To install, copy pg_bsd_indent to somewhere in your usual PATH.
17+
(If you say "make install", it will try to put it in your Postgres
18+
installation directory, which is most likely not what you want for
19+
long-term use.)
20+
21+
TODO: add build support and instructions for Windows
22+
23+
24+
If you happen to be hacking upon the indent source code, the closest
25+
approximation to the existing indentation style seems to be
26+
27+
./pg_bsd_indent -i4 -l79 -di12 -nfc1 -nlp -sac somefile.c
28+
29+
although this has by no means been rigorously adhered to.
30+
(What was that saw about the shoemaker's children?)

0 commit comments

Comments
 (0)