From 360429e1d17947c17659cd57dbaaba5c10fcbd6a Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 26 Oct 2011 17:23:33 -0400 Subject: [PATCH] Fix pg_bsd_indent bug where newlines were not being trimmed from typedef lines. Update pg_bsd_indent required version to 1.1 (and update ftp site). Problem reported by Magnus. --- src/bin/pg_basebackup/pg_basebackup.c | 17 ++++++------ src/tools/pgindent/indent.bsd.patch | 37 +++++++++++++-------------- src/tools/pgindent/pgindent | 5 ++-- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 68e40f478f..9100d75fb6 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -379,11 +379,10 @@ progress_report(int tablespacenum, const char *filename) char totalsize_str[32]; /* - * Avoid overflowing past 100% or the full size. This may make the - * total size number change as we approach the end of the backup - * (the estimate will always be wrong if WAL is included), but - * that's better than having the done column be bigger than the - * total. + * Avoid overflowing past 100% or the full size. This may make the total + * size number change as we approach the end of the backup (the estimate + * will always be wrong if WAL is included), but that's better than having + * the done column be bigger than the total. */ if (percent > 100) percent = 100; @@ -391,9 +390,9 @@ progress_report(int tablespacenum, const char *filename) totalsize = totaldone / 1024; /* - * Separate step to keep platform-dependent format code out of translatable - * strings. And we only test for INT64_FORMAT availability in snprintf, - * not fprintf. + * Separate step to keep platform-dependent format code out of + * translatable strings. And we only test for INT64_FORMAT availability + * in snprintf, not fprintf. */ snprintf(totaldone_str, sizeof(totaldone_str), INT64_FORMAT, totaldone / 1024); snprintf(totalsize_str, sizeof(totalsize_str), INT64_FORMAT, totalsize); @@ -410,7 +409,7 @@ progress_report(int tablespacenum, const char *filename) ngettext("%s/%s kB (100%%), %d/%d tablespace %35s", "%s/%s kB (100%%), %d/%d tablespaces %35s", tablespacecount), - totaldone_str, totalsize_str, tablespacenum, tablespacecount, ""); + totaldone_str, totalsize_str, tablespacenum, tablespacecount, ""); else fprintf(stderr, ngettext("%s/%s kB (%d%%), %d/%d tablespace (%-30.30s)", diff --git a/src/tools/pgindent/indent.bsd.patch b/src/tools/pgindent/indent.bsd.patch index a7d1453389..1d7f64bc3d 100644 --- a/src/tools/pgindent/indent.bsd.patch +++ b/src/tools/pgindent/indent.bsd.patch @@ -1,5 +1,5 @@ diff -c -r bsd_indent/Makefile pg_bsd_indent/Makefile -*** bsd_indent/Makefile Mon Nov 14 19:30:11 2005 +*** bsd_indent/Makefile Wed Oct 26 17:13:34 2011 --- pg_bsd_indent/Makefile Wed Oct 12 12:17:12 2011 *************** *** 2,10 **** @@ -38,7 +38,7 @@ diff -c -r bsd_indent/Makefile pg_bsd_indent/Makefile ! 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 12 11:51:58 2011 +*** bsd_indent/README Wed Oct 26 17:13:34 2011 --- pg_bsd_indent/README Mon Nov 14 19:30:24 2005 *************** *** 1,3 **** @@ -57,15 +57,15 @@ diff -c -r bsd_indent/README pg_bsd_indent/README 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 Mon Nov 14 19:30:00 2005 ---- pg_bsd_indent/args.c Wed Oct 12 12:30:06 2011 +*** 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 #include "indent_globs.h" -+ #define INDENT_PG_VERSION "1.0" ++ #define INDENT_PG_VERSION "1.1" + /* profile types */ #define PRO_SPECIAL 1 /* special case */ @@ -125,7 +125,7 @@ diff -c -r bsd_indent/args.c pg_bsd_indent/args.c indent: set_option: internal error: p_special %d\n", p->p_special); *************** *** 459,461 **** ---- 485,509 ---- +--- 485,508 ---- exit(1); } } @@ -145,17 +145,16 @@ diff -c -r bsd_indent/args.c pg_bsd_indent/args.c + while ((fgets(line, BUFSIZ, file)) != NULL) + { + /* Remove trailing whitespace */ -+ if (strstr(line, " \t\n\r") != NULL) -+ *strstr(line, " \t\n\r") = '\0'; ++ *(line + strcspn(line, " \t\n\r")) = '\0'; + addkey(strdup(line), 4); + } + fclose(file); + } -Only in pg_bsd_indent/: args.o -Only in bsd_indent/: indent.bsd.patch -Only in pg_bsd_indent/: indent.o +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 12 11:51:58 2011 +*** 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 **** @@ -178,9 +177,9 @@ diff -c -r bsd_indent/indent_globs.h pg_bsd_indent/indent_globs.h EXTERN struct parser_state { int last_token; -Only in pg_bsd_indent/: io.o +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 12 11:51:58 2011 +*** 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 **** @@ -221,9 +220,9 @@ diff -c -r bsd_indent/lexi.c pg_bsd_indent/lexi.c p->rwd = key; p->rwcode = val; p[1].rwd = 0; -Only in pg_bsd_indent/: lexi.o +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 12 11:51:58 2011 +*** 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 **** @@ -239,9 +238,9 @@ diff -c -r bsd_indent/parse.c pg_bsd_indent/parse.c reduce(); /* see if any reduction can be done */ #ifdef debug -Only in pg_bsd_indent/: parse.o +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 12 11:51:58 2011 +*** 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 **** @@ -286,4 +285,4 @@ diff -c -r bsd_indent/pr_comment.c pg_bsd_indent/pr_comment.c } else if (++buf_ptr >= buf_end) fill_buffer(); -Only in pg_bsd_indent/: pr_comment.o +Only in pg_bsd_indent: pr_comment.o diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index eeb6f5d2a2..e4ff5a53e5 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -22,6 +22,7 @@ TYPEDEFS="$1" shift [ -z "$INDENT" ] && INDENT=pg_bsd_indent +INDENT_VERSION="1.1" trap "rm -f /tmp/$$ /tmp/$$a" 0 1 2 3 15 @@ -39,8 +40,8 @@ if [ "$?" -ne 1 ] then echo "You do not appear to have '$INDENT' installed on your system." >&2 exit 1 fi -if [ "`$INDENT -V`" != "$INDENT 1.0" ] -then echo "You do not appear to have $INDENT version 1.0 installed on your system." >&2 +if [ "`$INDENT -V`" != "$INDENT $INDENT_VERSION" ] +then echo "You do not appear to have $INDENT version $INDENT_VERSION installed on your system." >&2 exit 1 fi $INDENT -gnu /dev/null 2>&1 -- 2.40.0