Skip to content

Commit 8c9f7c1

Browse files
committed
YB: add src/tools/pg_bsd_indent as of be31ac2
Take the state of src/tools/pg_bsd_indent as of commit be31ac2. The next commit that touches src/tools/pg_bsd_indent (3691edf) breaks build, so this commit is chosen. Cherry-picking each individual commit leading up to this stage is nontrivial due to interaction with not-yet-supported Meson and the touching of many files for trivial style updates, so this way is much simpler. Followups will take care of any other changes needed outside of this directory.
1 parent 01f94ab commit 8c9f7c1

Some content is hidden

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

62 files changed

+5869
-0
lines changed

src/tools/pg_bsd_indent/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/pg_bsd_indent
2+
# Generated by test suite
3+
/log/
4+
/tmp_check/

src/tools/pg_bsd_indent/Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# src/tools/pg_bsd_indent/Makefile
4+
#
5+
# Copyright (c) 2017-2025, PostgreSQL Global Development Group
6+
#
7+
#-------------------------------------------------------------------------
8+
9+
PGFILEDESC = "pg_bsd_indent - indent C code nicely"
10+
PGAPPICON = win32
11+
12+
subdir = src/tools/pg_bsd_indent
13+
top_builddir = ../../..
14+
include $(top_builddir)/src/Makefile.global
15+
16+
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
17+
18+
OBJS = \
19+
$(WIN32RES) \
20+
args.o \
21+
err.o \
22+
indent.o \
23+
io.o \
24+
lexi.o \
25+
parse.o \
26+
pr_comment.o
27+
28+
$(OBJS): CFLAGS += $(PERMIT_MISSING_VARIABLE_DECLARATIONS)
29+
30+
all: pg_bsd_indent
31+
32+
pg_bsd_indent: $(OBJS) | submake-libpgport
33+
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
34+
35+
install: all installdirs
36+
$(INSTALL_PROGRAM) pg_bsd_indent$(X) '$(DESTDIR)$(bindir)/pg_bsd_indent$(X)'
37+
38+
installdirs:
39+
$(MKDIR_P) '$(DESTDIR)$(bindir)'
40+
41+
uninstall:
42+
rm -f '$(DESTDIR)$(bindir)/pg_bsd_indent$(X)'
43+
44+
clean distclean:
45+
rm -f pg_bsd_indent$(X) $(OBJS)
46+
rm -rf log/ tmp_check/
47+
48+
check: pg_bsd_indent
49+
$(prove_check)
50+
51+
installcheck:
52+
$(prove_installcheck)
53+
54+
# Provide this alternate test name to allow testing pg_bsd_indent
55+
# without building all of the surrounding Postgres installation.
56+
.PHONY: test
57+
58+
test: pg_bsd_indent
59+
$(prove_installcheck)

src/tools/pg_bsd_indent/README

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
src/tools/pg_bsd_indent/README
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, configure the surrounding Postgres source tree,
9+
then run "make" in this directory.
10+
Optionally, run "make test" for some simple tests.
11+
12+
You'll need to install pg_bsd_indent somewhere in your PATH before
13+
using it. Most likely, if you're a developer, you don't want to
14+
put it in the same place as where the surrounding Postgres build
15+
gets installed. Therefore, do this part with something like
16+
17+
make install prefix=/usr/local
18+
19+
If you are using Meson to build, the standard build targets will
20+
build pg_bsd_indent and also test it, but there is not currently
21+
provision for installing it anywhere. Manually copy the built
22+
executable from build/src/tools/pg_bsd_indent/pg_bsd_indent to
23+
wherever you want to put it.
24+
25+
26+
If you happen to be hacking upon the indent source code, the closest
27+
approximation to the existing indentation style seems to be
28+
29+
./pg_bsd_indent -i4 -l79 -di12 -nfc1 -nlp -sac somefile.c
30+
31+
although this has by no means been rigorously adhered to.
32+
(What was that saw about the shoemaker's children?)
33+
We're not planning to re-indent to Postgres style, because that
34+
would make it difficult to compare to the FreeBSD sources.
35+
36+
----------
37+
38+
The FreeBSD originals of the files in this directory bear the
39+
"4-clause" version of the BSD license. We have removed the
40+
"advertising" clauses, as per UC Berkeley's directive here:
41+
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
42+
which reads:
43+
44+
July 22, 1999
45+
46+
To All Licensees, Distributors of Any Version of BSD:
47+
48+
As you know, certain of the Berkeley Software Distribution ("BSD") source
49+
code files require that further distributions of products containing all or
50+
portions of the software, acknowledge within their advertising materials
51+
that such products contain software developed by UC Berkeley and its
52+
contributors.
53+
54+
Specifically, the provision reads:
55+
56+
" * 3. All advertising materials mentioning features or use of this software
57+
* must display the following acknowledgement:
58+
* This product includes software developed by the University of
59+
* California, Berkeley and its contributors."
60+
61+
Effective immediately, licensees and distributors are no longer required to
62+
include the acknowledgement within advertising materials. Accordingly, the
63+
foregoing paragraph of those BSD Unix files containing it is hereby deleted
64+
in its entirety.
65+
66+
William Hoskins
67+
Director, Office of Technology Licensing
68+
University of California, Berkeley
69+
70+
----------
71+
72+
What follows is the README file as maintained by FreeBSD indent.
73+
74+
----------
75+
76+
$FreeBSD: head/usr.bin/indent/README 105244 2002-10-16 13:58:39Z charnier $
77+
78+
This is the C indenter, it originally came from the University of Illinois
79+
via some distribution tape for PDP-11 Unix. It has subsequently been
80+
hacked upon by James Gosling @ CMU. It isn't very pretty, and really needs
81+
to be completely redone, but it is probably the nicest C pretty printer
82+
around.
83+
84+
Further additions to provide "Kernel Normal Form" were contributed
85+
by the folks at Sun Microsystems.
86+
87+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
88+
> From mnetor!yunexus!oz@uunet.UU.NET Wed Mar 9 15:30:55 1988
89+
> Date: Tue, 8 Mar 88 18:36:25 EST
90+
> From: yunexus!oz@uunet.UU.NET (Ozan Yigit)
91+
> To: bostic@okeeffe.berkeley.edu
92+
> Cc: ccvaxa!willcox@uunet.UU.NET, jag@sun.com, rsalz@uunet.UU.NET
93+
> In-Reply-To: Keith Bostic's message of Tue, 16 Feb 88 16:09:06 PST
94+
> Subject: Re: Indent...
95+
96+
Thank you for your response about indent. I was wrong in my original
97+
observation (or mis-observation :-). UCB did keep the Illinois
98+
copyright intact.
99+
100+
The issue still is whether we can distribute indent, and if we can, which
101+
version. David Willcox (the author) states that:
102+
103+
| Several people have asked me on what basis I claim that indent is in
104+
| the public domain. I knew I would be sorry I made that posting.
105+
|
106+
| Some history. Way back in 1976, the project I worked on at the
107+
| University of Illinois Center for Advanced Computation had a huge
108+
| battle about how to format C code. After about a week of fighting, I
109+
| got disgusted and wrote a program, which I called indent, to reformat C
110+
| code. It had a bunch of different options that would let you format
111+
| the output the way you liked. In particular, all of the different
112+
| formats being championed were supported.
113+
|
114+
| It was my first big C program. It was ugly. It wasn't designed, it
115+
| just sort of grew. But it pretty much worked, and it stopped most of
116+
| the fighting.
117+
|
118+
| As a matter of form, I included a University of Illinois Copyright
119+
| notice. However, my understanding was that, since the work was done
120+
| on an ARPA contract, it was in the public domain.
121+
|
122+
| Time passed. Some years later, indent showed up on one of the early
123+
| emacs distributions.
124+
|
125+
| Later still, someone from UC Berkeley called the UofI and asked if
126+
| indent was in the public domain. They wanted to include it in their
127+
| UNIX distributions, along with the emacs stuff. I was no longer at the
128+
| UofI, but Rob Kolstad, who was, asked me about it. I told him I didn't
129+
| care if they used it, and since then it has been on the BSD distributions.
130+
|
131+
| Somewhere along the way, several other unnamed people have had their
132+
| hands in it. It was converted to understand version 7 C. (The
133+
| original was version 6.) It was converted from its original filter
134+
| interface to its current "blow away the user's file" interface.
135+
| The $HOME/.indent.pro file parsing was added. Some more formatting
136+
| options were added.
137+
|
138+
| The source I have right now has two copyright notices. One is the
139+
| original from the UofI. One is from Berkeley.
140+
|
141+
| I am not a lawyer, and I certainly do not understand copyright law. As
142+
| far as I am concerned, the bulk of this program, everything covered by
143+
| the UofI copyright, is in the public domain, and worth every penny.
144+
| Berkeley's copyright probably should only cover their changes, and I
145+
| don't know their feelings about sending it out.
146+
147+
In any case, there appears to be none at UofI to clarify/and change
148+
that copyright, but I am confident (based on the statements of its
149+
author) that the code, as it stands with its copyright, is
150+
distributable, and will not cause any legal problems.
151+
152+
Hence, the issue reduces to *which* one to distribute through
153+
comp.sources.unix. I would suggest that with the permission of you
154+
folks (given that you have parts copyrighted), we distribute the 4.3
155+
version of indent, which appears to be the most up-to-date version. I
156+
happen to have just about every known version of indent, including the
157+
very original submission from the author to a unix tape, later the
158+
G-Emacs version, any 4.n version, sun version and the Unipress
159+
version. I still think we should not have to "go-back-in-time" and
160+
re-do all the work you people have done.
161+
162+
I hope to hear from you as to what you think about this. You may of
163+
course send 4.3 version to the moderator directly, or you can let me
164+
know of your permission, and I will send the sources, or you can let
165+
me know that 4.3 version is off-limits, in which case we would probably
166+
have to revert to an older version. One way or another, I hope to get
167+
a version of indent to comp.sources.unix.
168+
169+
regards.. oz
170+
171+
cc: ccvaxa!willcox
172+
sun.com!jar
173+
uunet!rsalz
174+

0 commit comments

Comments
 (0)