Code review for patch to show definition of index columns in \d on index.
[PostgreSQL.git] / src / tools / pgindent / indent.bsd.patch
blob257eeeb2deedc2345c493b69fa187709af99beff
1 $PostgreSQL$
3 This patch contains several fixes to NetBSD's indent and should be
4 applied before using pgindent.
6 ---------------------------------------------------------------------------
8 Index: README
9 ===================================================================
10 RCS file: /cvsroot/src/usr.bin/indent/README,v
11 retrieving revision 1.1
12 diff -c -r1.1 README
13 *** README 9 Apr 1993 12:59:06 -0000 1.1
14 --- README 15 Nov 2005 00:25:43 -0000
15 ***************
16 *** 1,3 ****
17 --- 1,13 ----
19 + This patch is from NetBSD current, 2005-11-14. It contains all the
20 + patches need for its use in PostgreSQL.
22 + bjm
24 + ---------------------------------------------------------------------------
28 This is the C indenter, it originally came from the University of Illinois
29 via some distribution tape for PDP-11 Unix. It has subsequently been
30 hacked upon by James Gosling @ CMU. It isn't very pretty, and really needs
31 Index: indent_globs.h
32 ===================================================================
33 RCS file: /cvsroot/src/usr.bin/indent/indent_globs.h,v
34 retrieving revision 1.8
35 diff -c -r1.8 indent_globs.h
36 *** indent_globs.h 7 Aug 2003 11:14:08 -0000 1.8
37 --- indent_globs.h 15 Nov 2005 00:25:44 -0000
38 ***************
39 *** 239,245 ****
40 scomf, /* Same line comment font */
41 bodyf; /* major body font */
43 ! #define STACK_SIZE 150
45 EXTERN struct parser_state {
46 int last_token;
47 --- 239,249 ----
48 scomf, /* Same line comment font */
49 bodyf; /* major body font */
51 ! /*
52 ! * This controls the maximum number of 'else if' clauses supported.
53 ! * If it is exceeded, comments are placed in column 100.
54 ! */
55 ! #define STACK_SIZE 1000
57 EXTERN struct parser_state {
58 int last_token;
59 Index: lexi.c
60 ===================================================================
61 RCS file: /cvsroot/src/usr.bin/indent/lexi.c,v
62 retrieving revision 1.12
63 diff -c -r1.12 lexi.c
64 *** lexi.c 7 Aug 2003 11:14:09 -0000 1.12
65 --- lexi.c 15 Nov 2005 00:25:44 -0000
66 ***************
67 *** 93,99 ****
68 int rwcode;
71 ! struct templ specials[1000] =
73 {"switch", 1},
74 {"case", 2},
75 --- 93,99 ----
76 int rwcode;
79 ! struct templ specials[16384] =
81 {"switch", 1},
82 {"case", 2},
83 ***************
84 *** 622,629 ****
85 else
86 p++;
87 if (p >= specials + sizeof specials / sizeof specials[0])
88 ! return; /* For now, table overflows are silently
89 ! * ignored */
90 p->rwd = key;
91 p->rwcode = val;
92 p[1].rwd = 0;
93 --- 622,632 ----
94 else
95 p++;
96 if (p >= specials + sizeof specials / sizeof specials[0])
97 ! {
98 ! fprintf(stderr, "indent: typedef table overflow\n");
99 ! exit(1);
102 p->rwd = key;
103 p->rwcode = val;
104 p[1].rwd = 0;
105 Index: parse.c
106 ===================================================================
107 RCS file: /cvsroot/src/usr.bin/indent/parse.c,v
108 retrieving revision 1.7
109 diff -c -r1.7 parse.c
110 *** parse.c 7 Aug 2003 11:14:09 -0000 1.7
111 --- parse.c 15 Nov 2005 00:25:44 -0000
112 ***************
113 *** 231,236 ****
114 --- 231,241 ----
116 } /* end of switch */
118 + if (ps.tos >= STACK_SIZE) {
119 + fprintf(stderr, "indent: stack size overflow\n");
120 + exit(1);
123 reduce(); /* see if any reduction can be done */
125 #ifdef debug
126 Index: pr_comment.c
127 ===================================================================
128 RCS file: /cvsroot/src/usr.bin/indent/pr_comment.c,v
129 retrieving revision 1.9
130 diff -c -r1.9 pr_comment.c
131 *** pr_comment.c 7 Aug 2003 11:14:09 -0000 1.9
132 --- pr_comment.c 15 Nov 2005 00:25:44 -0000
133 ***************
134 *** 148,154 ****
135 ps.box_com = true;
136 ps.com_col = 1;
137 } else {
138 ! if (*buf_ptr == '-' || *buf_ptr == '*' || *buf_ptr == '\n') {
139 ps.box_com = true; /* a comment with a '-', '*'
140 * or newline immediately
141 * after the start comment is
142 --- 148,158 ----
143 ps.box_com = true;
144 ps.com_col = 1;
145 } else {
146 ! /*
147 ! * Don't process '\n' or every comment is treated as a
148 ! * block comment, meaning there is no wrapping.
149 ! */
150 ! if (*buf_ptr == '-' || *buf_ptr == '*') {
151 ps.box_com = true; /* a comment with a '-', '*'
152 * or newline immediately
153 * after the start comment is
154 ***************
155 *** 328,333 ****
156 --- 332,350 ----
157 goto end_of_comment;
159 } while (*buf_ptr == ' ' || *buf_ptr == '\t');
161 + /*
162 + * If there is a blank comment line, we need to prefix
163 + * the line with the same three spaces that "/* " takes up.
164 + * Without this code, blank stared lines in comments have
165 + * three too-many characters on the line when wrapped.
166 + */
167 + if (s_com == e_com) {
168 + *e_com++ = ' '; /* add blanks for continuation */
169 + *e_com++ = ' ';
170 + *e_com++ = ' ';
171 + now_col += 3;
173 } else
174 if (++buf_ptr >= buf_end)
175 fill_buffer();