]> granicus.if.org Git - postgresql/blob - src/tools/pgindent/indent.bsd.patch
Again update typedefs.list file in preparation for pgindent run
[postgresql] / src / tools / pgindent / indent.bsd.patch
1 diff -c -r bsd_indent/Makefile pg_bsd_indent/Makefile
2 *** bsd_indent/Makefile Wed Oct 26 17:13:34 2011
3 --- pg_bsd_indent/Makefile      Wed Oct 12 12:17:12 2011
4 ***************
5 *** 2,10 ****
6   # Makefile
7   #
8   #
9 ! TARGET = indent
10   XFLAGS = -Wall -D__RCSID="static char *rcsid=" -D__COPYRIGHT="static char *copyright="
11 ! CFLAGS = -g 
12   LIBS = 
13   
14   $(TARGET) : args.o indent.o io.o lexi.o parse.o pr_comment.o
15 --- 2,10 ----
16   # Makefile
17   #
18   #
19 ! TARGET = pg_bsd_indent
20   XFLAGS = -Wall -D__RCSID="static char *rcsid=" -D__COPYRIGHT="static char *copyright="
21 ! CFLAGS = -O
22   LIBS = 
23   
24   $(TARGET) : args.o indent.o io.o lexi.o parse.o pr_comment.o
25 ***************
26 *** 31,37 ****
27   clean:
28         rm -f *.o $(TARGET) log core
29   
30 ! install:
31 !       make clean
32 !       make CFLAGS=-O
33         install -s -o bin -g bin $(TARGET) /usr/local/bin
34 --- 31,35 ----
35   clean:
36         rm -f *.o $(TARGET) log core
37   
38 ! install: $(TARGET)
39         install -s -o bin -g bin $(TARGET) /usr/local/bin
40 diff -c -r bsd_indent/README pg_bsd_indent/README
41 *** bsd_indent/README   Wed Oct 26 17:13:34 2011
42 --- pg_bsd_indent/README        Mon Nov 14 19:30:24 2005
43 ***************
44 *** 1,3 ****
45 --- 1,13 ----
46
47 + This patch is from NetBSD current, 2005-11-14.  It contains all the
48 + patches need for its use in PostgreSQL.
49
50 + bjm
51
52 + ---------------------------------------------------------------------------
53
54
55
56   This is the C indenter, it originally came from the University of Illinois
57   via some distribution tape for PDP-11 Unix.  It has subsequently been
58   hacked upon by James Gosling @ CMU.  It isn't very pretty, and really needs
59 diff -c -r bsd_indent/args.c pg_bsd_indent/args.c
60 *** bsd_indent/args.c   Wed Oct 26 17:13:34 2011
61 --- pg_bsd_indent/args.c        Wed Oct 26 17:16:56 2011
62 ***************
63 *** 83,88 ****
64 --- 83,90 ----
65   #include <string.h>
66   #include "indent_globs.h"
67   
68 + #define INDENT_PG_VERSION     "1.1"
69
70   /* profile types */
71   #define       PRO_SPECIAL     1       /* special case */
72   #define       PRO_BOOL        2       /* boolean */
73 ***************
74 *** 99,106 ****
75 --- 101,113 ----
76   #define       STDIN           3       /* use stdin */
77   #define       KEY             4       /* type (keyword) */
78   
79 + #define       KEY_FILE                5       /* only used for args */
80 + #define VERSION                       6       /* only used for args */
81
82   char   *option_source = "?";
83   
84 + void add_typedefs_from_file(char *str);
85
86   /*
87    * N.B.: because of the way the table here is scanned, options whose names are
88    * substrings of other options must occur later; that is, with -lp vs -l, -lp
89 ***************
90 *** 118,123 ****
91 --- 125,136 ----
92                 "T", PRO_SPECIAL, 0, KEY, 0
93         },
94         {
95 +               "U", PRO_SPECIAL, 0, KEY_FILE, 0
96 +       },
97 +       {
98 +               "V", PRO_SPECIAL, 0, VERSION, 0
99 +       },
100 +       {
101                 "bacc", PRO_BOOL, false, ON, &blanklines_around_conditional_compilation
102         },
103         {
104 ***************
105 *** 425,430 ****
106 --- 438,456 ----
107                         }
108                         break;
109   
110 +               case KEY_FILE:
111 +                       if (*param_start == 0)
112 +                               goto need_param;
113 +                       add_typedefs_from_file(param_start);
114 +                       break;
115
116 +               case VERSION:
117 +                       {
118 +                               printf("pg_bsd_indent %s\n", INDENT_PG_VERSION);
119 +                               exit(0);
120 +                       }
121 +                       break;
122
123                 default:
124                         fprintf(stderr, "\
125   indent: set_option: internal error: p_special %d\n", p->p_special);
126 ***************
127 *** 459,461 ****
128 --- 485,508 ----
129                 exit(1);
130         }
131   }
132
133
134 + void
135 + add_typedefs_from_file(char *str)
136 + {
137 +       FILE *file;
138 +       char line[BUFSIZ];
139 +       
140 +       if ((file = fopen(param_start, "r")) == NULL)
141 +       {
142 +               fprintf(stderr, "indent: cannot open file %s\n", str);
143 +               exit(1);
144 +       }
145 +       while ((fgets(line, BUFSIZ, file)) != NULL)
146 +       {
147 +               /* Remove trailing whitespace */
148 +               *(line + strcspn(line, " \t\n\r")) = '\0';
149 +               addkey(strdup(line), 4);
150 +       }
151 +       fclose(file);
152 + }
153 Only in pg_bsd_indent: args.o
154 Only in pg_bsd_indent: indent.bsd.patch
155 Only in pg_bsd_indent: indent.o
156 diff -c -r bsd_indent/indent_globs.h pg_bsd_indent/indent_globs.h
157 *** bsd_indent/indent_globs.h   Wed Oct 26 17:13:34 2011
158 --- pg_bsd_indent/indent_globs.h        Mon Nov 14 19:30:24 2005
159 ***************
160 *** 239,245 ****
161           scomf,                        /* Same line comment font */
162           bodyf;                        /* major body font */
163   
164 ! #define STACK_SIZE 150
165   
166   EXTERN struct parser_state {
167         int     last_token;
168 --- 239,249 ----
169           scomf,                        /* Same line comment font */
170           bodyf;                        /* major body font */
171   
172 ! /*
173 !  * This controls the maximum number of 'else if' clauses supported.
174 !  * If it is exceeded, comments are placed in column 100.
175 !  */
176 ! #define STACK_SIZE 1000
177   
178   EXTERN struct parser_state {
179         int     last_token;
180 Only in pg_bsd_indent: io.o
181 diff -c -r bsd_indent/lexi.c pg_bsd_indent/lexi.c
182 *** bsd_indent/lexi.c   Wed Oct 26 17:13:34 2011
183 --- pg_bsd_indent/lexi.c        Mon Nov 14 19:30:24 2005
184 ***************
185 *** 93,99 ****
186         int     rwcode;
187   };
188   
189 ! struct templ specials[1000] =
190   {
191         {"switch", 1},
192         {"case", 2},
193 --- 93,99 ----
194         int     rwcode;
195   };
196   
197 ! struct templ specials[16384] =
198   {
199         {"switch", 1},
200         {"case", 2},
201 ***************
202 *** 622,629 ****
203                 else
204                         p++;
205         if (p >= specials + sizeof specials / sizeof specials[0])
206 !               return;         /* For now, table overflows are silently
207 !                                * ignored */
208         p->rwd = key;
209         p->rwcode = val;
210         p[1].rwd = 0;
211 --- 622,632 ----
212                 else
213                         p++;
214         if (p >= specials + sizeof specials / sizeof specials[0])
215 !       {
216 !               fprintf(stderr, "indent: typedef table overflow\n");
217 !               exit(1);
218 !       }
219
220         p->rwd = key;
221         p->rwcode = val;
222         p[1].rwd = 0;
223 Only in pg_bsd_indent: lexi.o
224 diff -c -r bsd_indent/parse.c pg_bsd_indent/parse.c
225 *** bsd_indent/parse.c  Wed Oct 26 17:13:34 2011
226 --- pg_bsd_indent/parse.c       Mon Nov 14 19:30:24 2005
227 ***************
228 *** 231,236 ****
229 --- 231,241 ----
230   
231         }                       /* end of switch */
232   
233 +       if (ps.tos >= STACK_SIZE) {
234 +           fprintf(stderr, "indent:  stack size overflow\n");
235 +           exit(1);
236 +       }
237 +       
238         reduce();               /* see if any reduction can be done */
239   
240   #ifdef debug
241 Only in pg_bsd_indent: parse.o
242 diff -c -r bsd_indent/pr_comment.c pg_bsd_indent/pr_comment.c
243 *** bsd_indent/pr_comment.c     Wed Oct 26 17:13:34 2011
244 --- pg_bsd_indent/pr_comment.c  Mon Nov 14 19:30:24 2005
245 ***************
246 *** 148,154 ****
247                 ps.box_com = true;
248                 ps.com_col = 1;
249         } else {
250 !               if (*buf_ptr == '-' || *buf_ptr == '*' || *buf_ptr == '\n') {
251                         ps.box_com = true;      /* a comment with a '-', '*'
252                                                  * or newline immediately
253                                                  * after the start comment is
254 --- 148,158 ----
255                 ps.box_com = true;
256                 ps.com_col = 1;
257         } else {
258 !               /*
259 !                * Don't process '\n' or every comment is treated as a
260 !                * block comment, meaning there is no wrapping.
261 !                */
262 !               if (*buf_ptr == '-' || *buf_ptr == '*') {
263                         ps.box_com = true;      /* a comment with a '-', '*'
264                                                  * or newline immediately
265                                                  * after the start comment is
266 ***************
267 *** 328,333 ****
268 --- 332,350 ----
269                                                         goto end_of_comment;
270                                         }
271                                 } while (*buf_ptr == ' ' || *buf_ptr == '\t');
272
273 +                               /*
274 +                                * If there is a blank comment line, we need to prefix
275 +                                * the line with the same three spaces that "/* " takes up.
276 +                                * Without this code, blank stared lines in comments have
277 +                                * three too-many characters on the line when wrapped.
278 +                                */
279 +                               if (s_com == e_com) {
280 +                                   *e_com++ = ' ';     /* add blanks for continuation */
281 +                                   *e_com++ = ' ';
282 +                                   *e_com++ = ' ';
283 +                                   now_col += 3;
284 +                               }
285                         } else
286                                 if (++buf_ptr >= buf_end)
287                                         fill_buffer();
288 Only in pg_bsd_indent: pr_comment.o