diff options
author | Tom Lane | 2017-06-21 18:26:21 +0000 |
---|---|---|
committer | Tom Lane | 2017-06-21 18:26:21 +0000 |
commit | 8ff6d4ec7840b0af56f1207073f44b7f2afae96d (patch) | |
tree | 3e2f7dc12bb906186a40f0f0b256db1597c9ce05 /src/tools/pgindent/indent.bsd.patch | |
parent | 9ef2dbefc7fb3ac22e1528bc22a41a5c6c6a9539 (diff) |
Adjust pgindent script to use pg_bsd_indent 2.0.
Update version-checking code and list of switches. Delete obsolete
quasi-support for using GNU indent. Remove a lot of no-longer-needed
workarounds for bugs of the old version, and improve comments for
the hacks that remain. Update run_build() subroutine to fetch the
pg_bsd_indent code from the newly established git repo for it.
In passing, fix pgindent to not overwrite files that require no changes;
this makes it a bit more friendly to run on a built tree.
Adjust relevant documentation.
Remove indent.bsd.patch; it's not relevant anymore (and was obsolete
long ago anyway). Likewise remove pgcppindent, since we're no longer
in the business of shipping C++ code.
Piotr Stefaniak is responsible for most of the algorithmic changes
to the pgindent script; I did the rest.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
Diffstat (limited to 'src/tools/pgindent/indent.bsd.patch')
-rw-r--r-- | src/tools/pgindent/indent.bsd.patch | 288 |
1 files changed, 0 insertions, 288 deletions
diff --git a/src/tools/pgindent/indent.bsd.patch b/src/tools/pgindent/indent.bsd.patch deleted file mode 100644 index 1d7f64bc3d8..00000000000 --- a/src/tools/pgindent/indent.bsd.patch +++ /dev/null @@ -1,288 +0,0 @@ -diff -c -r bsd_indent/Makefile pg_bsd_indent/Makefile -*** bsd_indent/Makefile Wed Oct 26 17:13:34 2011 ---- pg_bsd_indent/Makefile Wed Oct 12 12:17:12 2011 -*************** -*** 2,10 **** - # Makefile - # - # -! TARGET = indent - XFLAGS = -Wall -D__RCSID="static char *rcsid=" -D__COPYRIGHT="static char *copyright=" -! CFLAGS = -g - LIBS = - - $(TARGET) : args.o indent.o io.o lexi.o parse.o pr_comment.o ---- 2,10 ---- - # Makefile - # - # -! TARGET = pg_bsd_indent - XFLAGS = -Wall -D__RCSID="static char *rcsid=" -D__COPYRIGHT="static char *copyright=" -! CFLAGS = -O - LIBS = - - $(TARGET) : args.o indent.o io.o lexi.o parse.o pr_comment.o -*************** -*** 31,37 **** - clean: - rm -f *.o $(TARGET) log core - -! install: -! make clean -! make CFLAGS=-O - install -s -o bin -g bin $(TARGET) /usr/local/bin ---- 31,35 ---- - clean: - rm -f *.o $(TARGET) log core - -! install: $(TARGET) - install -s -o bin -g bin $(TARGET) /usr/local/bin -diff -c -r bsd_indent/README pg_bsd_indent/README -*** bsd_indent/README Wed Oct 26 17:13:34 2011 ---- pg_bsd_indent/README Mon Nov 14 19:30:24 2005 -*************** -*** 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 -diff -c -r bsd_indent/args.c pg_bsd_indent/args.c -*** bsd_indent/args.c Wed Oct 26 17:13:34 2011 ---- pg_bsd_indent/args.c Wed Oct 26 17:16:56 2011 -*************** -*** 83,88 **** ---- 83,90 ---- - #include <string.h> - #include "indent_globs.h" - -+ #define INDENT_PG_VERSION "1.1" -+ - /* profile types */ - #define PRO_SPECIAL 1 /* special case */ - #define PRO_BOOL 2 /* boolean */ -*************** -*** 99,106 **** ---- 101,113 ---- - #define STDIN 3 /* use stdin */ - #define KEY 4 /* type (keyword) */ - -+ #define KEY_FILE 5 /* only used for args */ -+ #define VERSION 6 /* only used for args */ -+ - char *option_source = "?"; - -+ void add_typedefs_from_file(char *str); -+ - /* - * N.B.: because of the way the table here is scanned, options whose names are - * substrings of other options must occur later; that is, with -lp vs -l, -lp -*************** -*** 118,123 **** ---- 125,136 ---- - "T", PRO_SPECIAL, 0, KEY, 0 - }, - { -+ "U", PRO_SPECIAL, 0, KEY_FILE, 0 -+ }, -+ { -+ "V", PRO_SPECIAL, 0, VERSION, 0 -+ }, -+ { - "bacc", PRO_BOOL, false, ON, &blanklines_around_conditional_compilation - }, - { -*************** -*** 425,430 **** ---- 438,456 ---- - } - break; - -+ case KEY_FILE: -+ if (*param_start == 0) -+ goto need_param; -+ add_typedefs_from_file(param_start); -+ break; -+ -+ case VERSION: -+ { -+ printf("pg_bsd_indent %s\n", INDENT_PG_VERSION); -+ exit(0); -+ } -+ break; -+ - default: - fprintf(stderr, "\ - indent: set_option: internal error: p_special %d\n", p->p_special); -*************** -*** 459,461 **** ---- 485,508 ---- - exit(1); - } - } -+ -+ -+ void -+ add_typedefs_from_file(char *str) -+ { -+ FILE *file; -+ char line[BUFSIZ]; -+ -+ if ((file = fopen(param_start, "r")) == NULL) -+ { -+ fprintf(stderr, "indent: cannot open file %s\n", str); -+ exit(1); -+ } -+ while ((fgets(line, BUFSIZ, file)) != NULL) -+ { -+ /* Remove trailing whitespace */ -+ *(line + strcspn(line, " \t\n\r")) = '\0'; -+ addkey(strdup(line), 4); -+ } -+ fclose(file); -+ } -Only in pg_bsd_indent: args.o -Only in pg_bsd_indent: indent.bsd.patch -Only in pg_bsd_indent: indent.o -diff -c -r bsd_indent/indent_globs.h pg_bsd_indent/indent_globs.h -*** bsd_indent/indent_globs.h Wed Oct 26 17:13:34 2011 ---- pg_bsd_indent/indent_globs.h Mon Nov 14 19:30:24 2005 -*************** -*** 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; -Only in pg_bsd_indent: io.o -diff -c -r bsd_indent/lexi.c pg_bsd_indent/lexi.c -*** bsd_indent/lexi.c Wed Oct 26 17:13:34 2011 ---- pg_bsd_indent/lexi.c Mon Nov 14 19:30:24 2005 -*************** -*** 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; -Only in pg_bsd_indent: lexi.o -diff -c -r bsd_indent/parse.c pg_bsd_indent/parse.c -*** bsd_indent/parse.c Wed Oct 26 17:13:34 2011 ---- pg_bsd_indent/parse.c Mon Nov 14 19:30:24 2005 -*************** -*** 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 -Only in pg_bsd_indent: parse.o -diff -c -r bsd_indent/pr_comment.c pg_bsd_indent/pr_comment.c -*** bsd_indent/pr_comment.c Wed Oct 26 17:13:34 2011 ---- pg_bsd_indent/pr_comment.c Mon Nov 14 19:30:24 2005 -*************** -*** 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(); -Only in pg_bsd_indent: pr_comment.o |