Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit02c43ff

Browse files
committed
Fix recent problems with BSD indent, including indenting past 80
columns, shifting comment to the right when more than 150 'else if'clauses were used, and update typedefs for 8.1.X.NetBSD patched updated, with documentation.
1 parent1bdf124 commit02c43ff

File tree

4 files changed

+426
-65
lines changed

4 files changed

+426
-65
lines changed

‎src/tools/find_typedef

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
# Remember, debugging symbols are your friends.
1313
#
1414

15-
if ["$#"-ne 1-o!-d"$1" ]
16-
thenecho"Usage:$0 postgres_binary_directory"1>&2
15+
if ["$#"-eq 0-o!-d"$1" ]
16+
thenecho"Usage:$0 postgres_binary_directory [...]"1>&2
1717
exit 1
1818
fi
1919

20-
objdump --stabs"$1"/*|
21-
grep"LSYM"|
22-
awk'{print $7}'|
23-
grep':t'|
24-
sed's/^\([^:]*\).*$/\1/'|
25-
grep -v''|# some typedefs have spaces, remove them
20+
for DIR
21+
do
22+
objdump --stabs"$DIR"/*|
23+
grep"LSYM"|
24+
awk'{print $7}'|
25+
grep':t'|
26+
sed's/^\([^:]*\).*$/\1/'|
27+
grep -v''# some typedefs have spaces, remove them
28+
done|
2629
sort|
27-
uniq
30+
uniq|
31+
sed's/\(.*\)/-T\1 \\/'

‎src/tools/pgindent/README

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
This can format all PostgreSQL *.c and *.h files, but excludes *.y, and *.l
22
files.
33

4-
Getthe list of typedef's included in pgindent by running this on the
5-
pgsql/bin and pgsql/lib directories:
4+
To use it, first getthe list of typedef'sto beincluded in pgindent by
5+
running this on thepgsql/bin and pgsql/lib directories:
66

7-
/src/tools/find_typedef /usr/local/pgsql/bin /usr/local/pgsql/lib
7+
src/tools/find_typedef /usr/local/pgsql/bin /usr/local/pgsql/lib
88

99
and update the list in pgindent. This requires the binaries have debug
1010
symbols.
@@ -13,20 +13,12 @@ From the top directory, run:
1313

1414
find . -name '*.[ch]' -type f -print | grep -v 's_lock.h' | xargs -n100 pgindent
1515

16-
The stock BSD indent has two bugs. First, a comment after the word 'else'
17-
causes the rest of the file to be ignored. Second, it silently ignores
18-
typedefs after getting the first 100.
19-
20-
Both problems are worked-around in this script. We also include a patch
21-
for the second bug in:
22-
23-
/src/tools/pgindent/indent.bsd.patch
24-
25-
Even with the workaround, installation of the patch produces better
26-
output. You can get a patched BSD indent from ftp://ftp.postgresql.org/pub/dev.
16+
We have standardized on NetBSD's indent. We have fixed a few bugs which
17+
requre the NetBSD source to be patched with indent.bsd.patch patch. A
18+
fully patched version is available at ftp://ftp.postgresql.org/pub/dev.
2719

2820
GNU indent, version 2.2.6, has several problems, and is not recommended.
29-
These bugs become pretty major when you are doing >400k lines of code.
21+
These bugs become pretty major when you are doing >500k lines of code.
3022
If you don't believe me, take a directory and make a copy. Run pgindent
3123
on the copy using GNU indent, and do a diff -r. You will see what I
3224
mean. GNU indent does some things better, but mangles too.

‎src/tools/pgindent/indent.bsd.patch

Lines changed: 162 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,174 @@
11

2-
Thisincreases the number of typedef'sunderstood by BSDindentfrom 100
3-
to 4096. The second patch allows it to understand 0x7fU and 0LL constants.
2+
Thispatch contains several fixes to NetBSD's indentand should be
3+
applied before using pgindent.
44

55
---------------------------------------------------------------------------
66

7-
*** ./lexi.c.origMon Sep 8 17:55:47 1997
8-
--- ./lexi.cMon Sep 8 17:02:10 1997
7+
Index: README
8+
===================================================================
9+
RCS file: /cvsroot/src/usr.bin/indent/README,v
10+
retrieving revision 1.1
11+
diff -c -r1.1 README
12+
*** README9 Apr 1993 12:59:06 -00001.1
13+
--- README15 Nov 2005 00:25:43 -0000
914
***************
10-
*** 58,64 ****
11-
int rwcode;
15+
*** 1,3 ****
16+
--- 1,13 ----
17+
+
18+
+ This patch is from NetBSD current, 2005-11-14. It contains all the
19+
+ patches need for its use in PostgreSQL.
20+
+
21+
+ bjm
22+
+
23+
+ ---------------------------------------------------------------------------
24+
+
25+
+
26+
+
27+
This is the C indenter, it originally came from the University of Illinois
28+
via some distribution tape for PDP-11 Unix. It has subsequently been
29+
hacked upon by James Gosling @ CMU. It isn't very pretty, and really needs
30+
Index: indent_globs.h
31+
===================================================================
32+
RCS file: /cvsroot/src/usr.bin/indent/indent_globs.h,v
33+
retrieving revision 1.8
34+
diff -c -r1.8 indent_globs.h
35+
*** indent_globs.h7 Aug 2003 11:14:08 -00001.8
36+
--- indent_globs.h15 Nov 2005 00:25:44 -0000
37+
***************
38+
*** 239,245 ****
39+
scomf,/* Same line comment font */
40+
bodyf;/* major body font */
41+
42+
! #define STACK_SIZE 150
43+
44+
EXTERN struct parser_state {
45+
int last_token;
46+
--- 239,249 ----
47+
scomf,/* Same line comment font */
48+
bodyf;/* major body font */
49+
50+
! /*
51+
! * This controls the maximum number of 'else if' clauses supported.
52+
! * If it is exceeded, comments are placed in column 100.
53+
! */
54+
! #define STACK_SIZE 1000
55+
56+
EXTERN struct parser_state {
57+
int last_token;
58+
Index: lexi.c
59+
===================================================================
60+
RCS file: /cvsroot/src/usr.bin/indent/lexi.c,v
61+
retrieving revision 1.12
62+
diff -c -r1.12 lexi.c
63+
*** lexi.c7 Aug 2003 11:14:09 -00001.12
64+
--- lexi.c15 Nov 2005 00:25:44 -0000
65+
***************
66+
*** 93,99 ****
67+
int rwcode;
1268
};
1369

14-
! struct templ specials[100] =
70+
! struct templ specials[1000] =
1571
{
16-
"switch", 1,
17-
"case", 2,
18-
---58,64 ----
19-
int rwcode;
72+
{"switch", 1},
73+
{"case", 2},
74+
---93,99 ----
75+
int rwcode;
2076
};
2177

22-
! struct templ specials[4096] =
78+
! struct templ specials[16384] =
2379
{
24-
"switch", 1,
25-
"case", 2,
80+
{"switch", 1},
81+
{"case", 2},
82+
***************
83+
*** 622,629 ****
84+
else
85+
p++;
86+
if (p >= specials + sizeof specials / sizeof specials[0])
87+
! return;/* For now, table overflows are silently
88+
! * ignored */
89+
p->rwd = key;
90+
p->rwcode = val;
91+
p[1].rwd = 0;
92+
--- 622,632 ----
93+
else
94+
p++;
95+
if (p >= specials + sizeof specials / sizeof specials[0])
96+
! {
97+
! fprintf(stderr, "indent: typedef table overflow\n");
98+
! exit(1);
99+
! }
100+
!
101+
p->rwd = key;
102+
p->rwcode = val;
103+
p[1].rwd = 0;
104+
Index: parse.c
105+
===================================================================
106+
RCS file: /cvsroot/src/usr.bin/indent/parse.c,v
107+
retrieving revision 1.7
108+
diff -c -r1.7 parse.c
109+
*** parse.c7 Aug 2003 11:14:09 -00001.7
110+
--- parse.c15 Nov 2005 00:25:44 -0000
111+
***************
112+
*** 231,236 ****
113+
--- 231,241 ----
114+
115+
}/* end of switch */
116+
117+
+ if (ps.tos >= STACK_SIZE) {
118+
+ fprintf(stderr, "indent: stack size overflow\n");
119+
+ exit(1);
120+
+ }
121+
+
122+
reduce();/* see if any reduction can be done */
123+
124+
#ifdef debug
125+
Index: pr_comment.c
126+
===================================================================
127+
RCS file: /cvsroot/src/usr.bin/indent/pr_comment.c,v
128+
retrieving revision 1.9
129+
diff -c -r1.9 pr_comment.c
130+
*** pr_comment.c7 Aug 2003 11:14:09 -00001.9
131+
--- pr_comment.c15 Nov 2005 00:25:44 -0000
132+
***************
133+
*** 148,154 ****
134+
ps.box_com = true;
135+
ps.com_col = 1;
136+
} else {
137+
! if (*buf_ptr == '-' || *buf_ptr == '*' || *buf_ptr == '\n') {
138+
ps.box_com = true;/* a comment with a '-', '*'
139+
* or newline immediately
140+
* after the start comment is
141+
--- 148,158 ----
142+
ps.box_com = true;
143+
ps.com_col = 1;
144+
} else {
145+
! /*
146+
! * Don't process '\n' or every comment is treated as a
147+
! * block comment, meaning there is no wrapping.
148+
! */
149+
! if (*buf_ptr == '-' || *buf_ptr == '*') {
150+
ps.box_com = true;/* a comment with a '-', '*'
151+
* or newline immediately
152+
* after the start comment is
26153
***************
27-
*** 186,192 ****
28-
*e_token++ = *buf_ptr++;
29-
}
30-
}
31-
! if (*buf_ptr == 'L' || *buf_ptr == 'l')
32-
*e_token++ = *buf_ptr++;
33-
}
34-
else
35-
--- 186,203 ----
36-
*e_token++ = *buf_ptr++;
37-
}
38-
}
39-
! if (*buf_ptr == 'F' || *buf_ptr == 'f') {
40-
! /* float constant */
41-
! *e_token++ = *buf_ptr++;
42-
! } else {
43-
! /* integer constant (U, L, UL, LL, ULL) */
44-
! if (*buf_ptr == 'U' || *buf_ptr == 'u')
45-
! *e_token++ = *buf_ptr++;
46-
! if (*buf_ptr == 'L' || *buf_ptr == 'l')
47-
! *e_token++ = *buf_ptr++;
48-
! if (*buf_ptr == 'L' || *buf_ptr == 'l')
49-
! *e_token++ = *buf_ptr++;
50-
! }
51-
}
52-
else
53-
while (chartype[*buf_ptr] == alphanum) {/* copy it over */
154+
*** 328,333 ****
155+
--- 332,350 ----
156+
goto end_of_comment;
157+
}
158+
} while (*buf_ptr == ' ' || *buf_ptr == '\t');
159+
+
160+
+ /*
161+
+ * If there is a blank comment line, we need to prefix
162+
+ * the line with the same three spaces that "/* " takes up.
163+
+ * Without this code, blank stared lines in comments have
164+
+ * three too-many characters on the line when wrapped.
165+
+ */
166+
+ if (s_com == e_com) {
167+
+ *e_com++ = ' ';/* add blanks for continuation */
168+
+ *e_com++ = ' ';
169+
+ *e_com++ = ' ';
170+
+ now_col += 3;
171+
+ }
172+
} else
173+
if (++buf_ptr >= buf_end)
174+
fill_buffer();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp