blob: e10b9973f64a29ed2f23574deeea99cfb18f378e [file] [log] [blame]
src/tools/pgindent/indent.bsd.patch
This patch contains several fixes to NetBSD's indent and should be
applied before using pgindent.
---------------------------------------------------------------------------
Index: README
===================================================================
RCS file: /cvsroot/src/usr.bin/indent/README,v
retrieving revision 1.1
diff -c -r1.1 README
*** README 9 Apr 1993 12:59:06 -0000 1.1
--- README 15 Nov 2005 00:25:43 -0000
***************
*** 1,3 ****
--- 1,13 ----
+
+ This patch is from NetBSD current, 2005-11-14. It contains all the
+ patches need for its use in PostgreSQL.
+
+ bjm
+
+ ---------------------------------------------------------------------------
+
+
+
This is the C indenter, it originally came from the University of Illinois
via some distribution tape for PDP-11 Unix. It has subsequently been
hacked upon by James Gosling @ CMU. It isn't very pretty, and really needs
Index: indent_globs.h
===================================================================
RCS file: /cvsroot/src/usr.bin/indent/indent_globs.h,v
retrieving revision 1.8
diff -c -r1.8 indent_globs.h
*** indent_globs.h 7 Aug 2003 11:14:08 -0000 1.8
--- indent_globs.h 15 Nov 2005 00:25:44 -0000
***************
*** 239,245 ****
scomf, /* Same line comment font */
bodyf; /* major body font */
! #define STACK_SIZE 150
EXTERN struct parser_state {
int last_token;
--- 239,249 ----
scomf, /* Same line comment font */
bodyf; /* major body font */
! /*
! * This controls the maximum number of 'else if' clauses supported.
! * If it is exceeded, comments are placed in column 100.
! */
! #define STACK_SIZE 1000
EXTERN struct parser_state {
int last_token;
Index: lexi.c
===================================================================
RCS file: /cvsroot/src/usr.bin/indent/lexi.c,v
retrieving revision 1.12
diff -c -r1.12 lexi.c
*** lexi.c 7 Aug 2003 11:14:09 -0000 1.12
--- lexi.c 15 Nov 2005 00:25:44 -0000
***************
*** 93,99 ****
int rwcode;
};
! struct templ specials[1000] =
{
{"switch", 1},
{"case", 2},
--- 93,99 ----
int rwcode;
};
! struct templ specials[16384] =
{
{"switch", 1},
{"case", 2},
***************
*** 622,629 ****
else
p++;
if (p >= specials + sizeof specials / sizeof specials[0])
! return; /* For now, table overflows are silently
! * ignored */
p->rwd = key;
p->rwcode = val;
p[1].rwd = 0;
--- 622,632 ----
else
p++;
if (p >= specials + sizeof specials / sizeof specials[0])
! {
! fprintf(stderr, "indent: typedef table overflow\n");
! exit(1);
! }
!
p->rwd = key;
p->rwcode = val;
p[1].rwd = 0;
Index: parse.c
===================================================================
RCS file: /cvsroot/src/usr.bin/indent/parse.c,v
retrieving revision 1.7
diff -c -r1.7 parse.c
*** parse.c 7 Aug 2003 11:14:09 -0000 1.7
--- parse.c 15 Nov 2005 00:25:44 -0000
***************
*** 231,236 ****
--- 231,241 ----
} /* end of switch */
+ if (ps.tos >= STACK_SIZE) {
+ fprintf(stderr, "indent: stack size overflow\n");
+ exit(1);
+ }
+
reduce(); /* see if any reduction can be done */
#ifdef debug
Index: pr_comment.c
===================================================================
RCS file: /cvsroot/src/usr.bin/indent/pr_comment.c,v
retrieving revision 1.9
diff -c -r1.9 pr_comment.c
*** pr_comment.c 7 Aug 2003 11:14:09 -0000 1.9
--- pr_comment.c 15 Nov 2005 00:25:44 -0000
***************
*** 148,154 ****
ps.box_com = true;
ps.com_col = 1;
} else {
! if (*buf_ptr == '-' || *buf_ptr == '*' || *buf_ptr == '\n') {
ps.box_com = true; /* a comment with a '-', '*'
* or newline immediately
* after the start comment is
--- 148,158 ----
ps.box_com = true;
ps.com_col = 1;
} else {
! /*
! * Don't process '\n' or every comment is treated as a
! * block comment, meaning there is no wrapping.
! */
! if (*buf_ptr == '-' || *buf_ptr == '*') {
ps.box_com = true; /* a comment with a '-', '*'
* or newline immediately
* after the start comment is
***************
*** 328,333 ****
--- 332,350 ----
goto end_of_comment;
}
} while (*buf_ptr == ' ' || *buf_ptr == '\t');
+
+ /*
+ * If there is a blank comment line, we need to prefix
+ * the line with the same three spaces that "/* " takes up.
+ * Without this code, blank stared lines in comments have
+ * three too-many characters on the line when wrapped.
+ */
+ if (s_com == e_com) {
+ *e_com++ = ' '; /* add blanks for continuation */
+ *e_com++ = ' ';
+ *e_com++ = ' ';
+ now_col += 3;
+ }
} else
if (++buf_ptr >= buf_end)
fill_buffer();