Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/indent Upgrade indent(1)



details:   https://anonhg.NetBSD.org/src/rev/b2eedd633f57
branches:  trunk
changeset: 997988:b2eedd633f57
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Apr 04 15:27:35 2019 +0000

description:
Upgrade indent(1)

Merge all the changes from the recent FreeBSD HEAD snapshot
into our local copy.

FreeBSD actively maintains this program in their sources and their
repository contains over 100 commits with changes.

Keep the delta between the FreeBSD and NetBSD versions to absolute
minimum, mostly RCS Id and compatiblity fixes.

Major chages in this import:

 - Added an option -ldi<N> to control indentation of local variable names.
 - Added option -P for loading user-provided files as profiles
 - Added -tsn for setting tabsize
 - Rename -nsac/-sac ("space after cast") to -ncs/-cs
 - Added option -fbs Enables (disables) splitting the function declaration and opening brace across two lines.
 - Respect SIMPLE_BACKUP_SUFFIX environment variable in indent(1)
 - Group global option variables into an options structure
 - Use bsearch() for looking up type keywords.
 - Don't produce unneeded space character in function declarators
 - Don't unnecessarily add a blank before a comment ends.
 - Don't ignore newlines after comments that follow braces.

Merge the FreeBSD intend(1) tests with our ATF framework.
All tests pass.

Upgrade prepared by Manikishan Ghantasala.
Final polishing by myself.

Part II, checkin new files.

diffstat:

 tests/usr.bin/indent/Makefile                 |  54 ++++++++++++++++
 tests/usr.bin/indent/binary.0                 |  11 +++
 tests/usr.bin/indent/binary.0.stdout          |  13 +++
 tests/usr.bin/indent/comments.0               |  53 +++++++++++++++
 tests/usr.bin/indent/comments.0.pro           |   3 +
 tests/usr.bin/indent/comments.0.stdout        |  61 ++++++++++++++++++
 tests/usr.bin/indent/cs.0                     |   5 +
 tests/usr.bin/indent/cs.0.pro                 |   3 +
 tests/usr.bin/indent/cs.0.stdout              |   7 ++
 tests/usr.bin/indent/declarations.0           |  80 +++++++++++++++++++++++
 tests/usr.bin/indent/declarations.0.stdout    |  74 +++++++++++++++++++++
 tests/usr.bin/indent/elsecomment.0            |  43 ++++++++++++
 tests/usr.bin/indent/elsecomment.0.pro        |   3 +
 tests/usr.bin/indent/elsecomment.0.stdout     |  48 ++++++++++++++
 tests/usr.bin/indent/f_decls.0                |  30 ++++++++
 tests/usr.bin/indent/f_decls.0.stdout         |  33 +++++++++
 tests/usr.bin/indent/float.0                  |   9 ++
 tests/usr.bin/indent/float.0.stdout           |  11 +++
 tests/usr.bin/indent/label.0                  |  14 ++++
 tests/usr.bin/indent/label.0.pro              |   3 +
 tests/usr.bin/indent/label.0.stdout           |  15 ++++
 tests/usr.bin/indent/list_head.0              |  17 +++++
 tests/usr.bin/indent/list_head.0.stdout       |  15 ++++
 tests/usr.bin/indent/ncs.0                    |   5 +
 tests/usr.bin/indent/ncs.0.pro                |   3 +
 tests/usr.bin/indent/ncs.0.stdout             |   7 ++
 tests/usr.bin/indent/offsetof.0               |   6 +
 tests/usr.bin/indent/offsetof.0.stdout        |   8 ++
 tests/usr.bin/indent/parens.0                 |  28 ++++++++
 tests/usr.bin/indent/parens.0.pro             |   3 +
 tests/usr.bin/indent/parens.0.stdout          |  28 ++++++++
 tests/usr.bin/indent/pcs.0                    |   8 ++
 tests/usr.bin/indent/pcs.0.pro                |   3 +
 tests/usr.bin/indent/pcs.0.stdout             |  10 ++
 tests/usr.bin/indent/struct.0                 |  22 ++++++
 tests/usr.bin/indent/struct.0.stdout          |  24 +++++++
 tests/usr.bin/indent/surplusbad.0             |  10 ++
 tests/usr.bin/indent/surplusbad.0.pro         |   3 +
 tests/usr.bin/indent/surplusbad.0.stdout      |  10 ++
 tests/usr.bin/indent/t_indent.sh              |  91 +++++++++++++++++++++++++++
 tests/usr.bin/indent/types_from_file.0        |   4 +
 tests/usr.bin/indent/types_from_file.0.list   |   2 +
 tests/usr.bin/indent/types_from_file.0.pro    |   3 +
 tests/usr.bin/indent/types_from_file.0.stdout |   4 +
 tests/usr.bin/indent/wchar.0                  |   7 ++
 tests/usr.bin/indent/wchar.0.stdout           |   7 ++
 usr.bin/indent/indent.h                       |  60 +++++++++++++++++
 47 files changed, 961 insertions(+), 0 deletions(-)

diffs (truncated from 1150 to 300 lines):

diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/Makefile     Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,54 @@
+#      $NetBSD: Makefile,v 1.1 2019/04/04 15:27:35 kamil Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/usr.bin/indent
+TESTS_SH=      t_indent
+
+FILESDIR=      ${TESTSDIR}
+FILES=         binary.0
+FILES+=                binary.0.stdout
+FILES+=                comments.0
+FILES+=                comments.0.pro
+FILES+=                comments.0.stdout
+FILES+=                declarations.0
+FILES+=                declarations.0.stdout
+FILES+=                elsecomment.0
+FILES+=                elsecomment.0.stdout
+FILES+=                elsecomment.0.pro
+FILES+=                f_decls.0
+FILES+=                f_decls.0.stdout
+FILES+=                float.0
+FILES+=                float.0.stdout
+FILES+=                label.0
+FILES+=                label.0.stdout
+FILES+=                label.0.pro
+FILES+=                list_head.0
+FILES+=                list_head.0.stdout
+FILES+=                ncs.0
+FILES+=                ncs.0.stdout
+FILES+=                ncs.0.pro
+FILES+=                offsetof.0
+FILES+=                offsetof.0.stdout
+FILES+=                parens.0
+FILES+=                parens.0.stdout
+FILES+=                parens.0.pro
+FILES+=                pcs.0
+FILES+=                pcs.0.stdout
+FILES+=                pcs.0.pro
+FILES+=                cs.0
+FILES+=                cs.0.stdout
+FILES+=                cs.0.pro
+FILES+=                struct.0
+FILES+=                struct.0.stdout
+FILES+=                surplusbad.0
+FILES+=                surplusbad.0.stdout
+FILES+=                surplusbad.0.pro
+FILES+=                types_from_file.0
+FILES+=                types_from_file.0.stdout
+FILES+=                types_from_file.0.list
+FILES+=                types_from_file.0.pro
+FILES+=                wchar.0
+FILES+=                wchar.0.stdout
+
+.include <bsd.test.mk>
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/binary.0
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/binary.0     Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,11 @@
+/*     $NetBSD: binary.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
+/* $FreeBSD: head/usr.bin/indent/tests/binary.0 318471 2017-05-18 17:15:58Z pstef $ */
+#define b00101010 -1
+void t(void) {
+       unsigned a[] = {0b00101010, 0x00005678, 02, 17U};
+       float x[] = {.7f, 0.7f};
+       unsigned long ul[] = {0b00001111UL, 0x01010101UL, 02UL, 17UL};
+
+       if (0 b00101010)
+               return;
+}
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/binary.0.stdout
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/binary.0.stdout      Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,13 @@
+/*     $NetBSD: binary.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $  */
+/* $FreeBSD: head/usr.bin/indent/tests/binary.0.stdout 321381 2017-07-23 14:04:45Z pstef $ */
+#define b00101010 -1
+void
+t(void)
+{
+       unsigned        a[] = {0b00101010, 0x00005678, 02, 17U};
+       float           x[] = {.7f, 0.7f};
+       unsigned long   ul[] = {0b00001111UL, 0x01010101UL, 02UL, 17UL};
+
+       if (0 b00101010)
+               return;
+}
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/comments.0
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/comments.0   Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,53 @@
+/*     $NetBSD: comments.0,v 1.1 2019/04/04 15:27:35 kamil Exp $       */
+/* $FreeBSD: head/usr.bin/indent/tests/comments.0 321383 2017-07-23 15:07:52Z pstef $ */
+typedef enum x {
+       aaaaaaaaaaaaaaaaaaaaaa = 1 << 0,        /* test a */
+       bbbbbbbbbbbbbbbbb = 1 << 1,     /* test b */
+       cccccccccccccc = 1 << 1,        /* test c */
+       dddddddddddddddddddddddddddddd = 1 << 2 /* test d */
+} x;
+
+/* See r303597, r303598, r309219, and r309343 */
+void t(void) {
+       /*
+        * Old indent wrapped the URL near where this sentence ends.
+        *
+        * https://www.freebsd.org/cgi/man.cgi?query=indent&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
+        */
+        
+       /*
+        * Old indent did not wrap to column 78
+        * 
+        * aaaaaa bbbbbb cccccc dddddd eeeeee ffffff ggggg hhhhh iiiii jjjj kk
+        */
+       
+       /*
+        * Old indent unnecessarily removed the star comment continuation on the next line.
+        * 
+        * *test*
+        */
+       
+       /* r309219 Go through linked list, freeing from the malloced (t[-1]) address. */
+       
+       /* r309343      */
+}
+
+int c(void)
+{
+       if (1) { /*- a christmas tree  *
+                                     ***
+                                    ***** */
+                   /*- another one *
+                                  ***
+                                 ***** */
+           7;
+       }
+
+       if (1) /*- a christmas tree  *
+                                   ***
+                                  ***** */
+                   /*- another one *
+                                  ***
+                                 ***** */
+           1;
+}
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/comments.0.pro
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/comments.0.pro       Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: comments.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $   */
+/* $FreeBSD: head/usr.bin/indent/tests/comments.0.pro 321383 2017-07-23 15:07:52Z pstef $ */
+-bbb
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/comments.0.stdout
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/comments.0.stdout    Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,61 @@
+/*     $NetBSD: comments.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $        */
+/* $FreeBSD: head/usr.bin/indent/tests/comments.0.stdout 334563 2018-06-03 15:28:55Z pstef $ */
+typedef enum x {
+       aaaaaaaaaaaaaaaaaaaaaa = 1 << 0,        /* test a */
+       bbbbbbbbbbbbbbbbb = 1 << 1,     /* test b */
+       cccccccccccccc = 1 << 1,        /* test c */
+       dddddddddddddddddddddddddddddd = 1 << 2 /* test d */
+} x;
+
+/* See r303597, r303598, r309219, and r309343 */
+void
+t(void)
+{
+       /*
+        * Old indent wrapped the URL near where this sentence ends.
+        *
+        * https://www.freebsd.org/cgi/man.cgi?query=indent&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
+        */
+
+       /*
+        * Old indent did not wrap to column 78
+        *
+        * aaaaaa bbbbbb cccccc dddddd eeeeee ffffff ggggg hhhhh iiiii jjjj
+        * kk
+        */
+
+       /*
+        * Old indent unnecessarily removed the star comment continuation on
+        * the next line.
+        *
+        * *test*
+        */
+
+       /*
+        * r309219 Go through linked list, freeing from the malloced (t[-1])
+        * address.
+        */
+
+       /* r309343      */
+}
+
+int
+c(void)
+{
+       if (1) {                /*- a christmas tree  *
+                                                    ***
+                                                   ***** */
+               /*- another one *
+                              ***
+                             ***** */
+               7;
+       }
+
+       if (1)                  /*- a christmas tree  *
+                                                    ***
+                                                   ***** */
+               /*- another one *
+                              ***
+                             ***** */
+               1;
+}
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/cs.0
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/cs.0 Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,5 @@
+/*     $NetBSD: cs.0,v 1.1 2019/04/04 15:27:35 kamil Exp $     */
+/* $FreeBSD: head/usr.bin/indent/tests/cs.0 334944 2018-06-11 05:35:57Z pstef $ */
+void t(void) {
+       int a = (double) 8;
+}
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/cs.0.pro
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/cs.0.pro     Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: cs.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
+/* $FreeBSD: head/usr.bin/indent/tests/cs.0.pro 334944 2018-06-11 05:35:57Z pstef $ */
+-cs
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/cs.0.stdout
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/cs.0.stdout  Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,7 @@
+/*     $NetBSD: cs.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $      */
+/* $FreeBSD: head/usr.bin/indent/tests/cs.0.stdout 334944 2018-06-11 05:35:57Z pstef $ */
+void
+t(void)
+{
+       int             a = (double) 8;
+}
diff -r 3a0d368b7449 -r b2eedd633f57 tests/usr.bin/indent/declarations.0
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/declarations.0       Thu Apr 04 15:27:35 2019 +0000
@@ -0,0 +1,80 @@
+/*     $NetBSD: declarations.0,v 1.1 2019/04/04 15:27:35 kamil Exp $   */
+/* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
+/* See r303570 */
+
+typedef void   (*voidptr) (int *);
+
+static const struct
+{
+       double          x;
+       double          y, z;
+} n[m + 1] =
+{
+       {
+               .0,
+               .9,
+               5
+       }
+};
+
+typedef struct Complex
+{
+       double          x;
+       double          y;
+}      Complex;
+
+void 
+t1 (char *a, int b,
+       void (*fn)(void))
+{}
+
+void t2 (char *x, int y)
+{
+       int a,
+       b,
+       c;
+       int
+       *d,
+       *e,
+       *f;
+       int (*g)(),
+       (*h)(),
+       (*i)();
+       int j,
+       k,
+       l;
+       int m
+       ,n
+       ,o
+       ;
+       int             chars[ /* push the comma beyond column 74 .... */ ], x;



Home | Main Index | Thread Index | Old Index