Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/indent indent: remove broken code for handling blank...



details:   https://anonhg.NetBSD.org/src/rev/4ad8de056a3b
branches:  trunk
changeset: 374766:4ad8de056a3b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu May 11 18:13:55 2023 +0000

description:
indent: remove broken code for handling blank lines

This fixes several bugs where blank lines were erroneously added or
removed, treating these old bugs for new bugs in different places.
These new bugs are expected to be easier to fix, as the old bugs will
not interfere anymore.

diffstat:

 tests/usr.bin/indent/indent_off_on.c           |  25 ++++++++++-
 tests/usr.bin/indent/lsym_form_feed.c          |  15 +-----
 tests/usr.bin/indent/lsym_lparen_or_lbracket.c |   6 +-
 tests/usr.bin/indent/opt_bacc.c                |  28 +------------
 tests/usr.bin/indent/opt_bad.c                 |   6 +-
 tests/usr.bin/indent/opt_badp.c                |  12 +----
 tests/usr.bin/indent/opt_bap_sob.c             |  27 +-----------
 tests/usr.bin/indent/opt_bbb.c                 |  10 ++--
 tests/usr.bin/indent/opt_v.c                   |   6 +-
 usr.bin/indent/indent.c                        |  25 +-----------
 usr.bin/indent/indent.h                        |   9 +---
 usr.bin/indent/io.c                            |  54 +------------------------
 usr.bin/indent/pr_comment.c                    |   7 +--
 13 files changed, 57 insertions(+), 173 deletions(-)

diffs (truncated from 610 to 300 lines):

diff -r c9b469ff3a9d -r 4ad8de056a3b tests/usr.bin/indent/indent_off_on.c
--- a/tests/usr.bin/indent/indent_off_on.c      Thu May 11 18:03:51 2023 +0000
+++ b/tests/usr.bin/indent/indent_off_on.c      Thu May 11 18:13:55 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_off_on.c,v 1.8 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: indent_off_on.c,v 1.9 2023/05/11 18:13:55 rillig Exp $ */
 
 /*
  * Tests for the comments 'INDENT OFF' and 'INDENT ON', which temporarily
@@ -24,6 +24,8 @@
 }
 /* $ FIXME: This empty line must stay. */
 /*INDENT OFF*/
+/* $ FIXME: The empty line below must be above the 'OFF' comment. */
+
 /* INDENT ON */
 
 {
@@ -42,9 +44,10 @@
 //indent run
 {
 }
-/* $ FIXME: This empty line must stay. */
-/* $ FIXME: This empty line must stay. */
+
 /*INDENT OFF*/
+/* $ FIXME: The empty line below must be above the 'OFF' comment. */
+
 /* INDENT ON */
 //indent end
 
@@ -64,6 +67,8 @@
 {
 }
  /* INDENT OFF */
+/* $ FIXME: The empty line below must be removed. */
+
 /* INDENT ON */
 {
 }
@@ -85,6 +90,8 @@
 {
 }
        /* INDENT OFF */
+/* $ FIXME: The empty line below must be removed. */
+
 /* INDENT ON */
 {
 }
@@ -107,6 +114,8 @@ int   decl   ;
 int decl;
 /*INDENTOFF*/
 int   decl   ;
+/* $ FIXME: The empty line below must be removed. */
+
 /* INDENTON */
 int decl;
 //indent end
@@ -132,6 +141,8 @@ int   decl   ;
 int decl;
 /*             INDENT          OFF             */
 int   decl   ;
+/* $ FIXME: The empty line below must be removed. */
+
 /* INDENT              ON              */
 int decl;
 //indent end
@@ -151,6 +162,8 @@ int format( void ) {{{
 int format( void ) {{{
 /* $ XXX: Why is the INDENT ON comment indented? */
 /* $ XXX: Why does the INDENT ON comment get spaces, but not the OFF comment? */
+/* $ FIXME: The empty line below must be removed. */
+
                        /* INDENT ON */
 }
 }
@@ -184,6 +197,8 @@ void indent_still_on ( void ) ;     /* due t
 //indent run
 /* INDENT OFF */
 void indent_off ( void ) ;
+/* $ FIXME: The empty line below must be removed. */
+
 /* $ XXX: The double space from the below comment got merged to a single */
 /* $ XXX: space even though the comment might be regarded to be still in */
 /* $ XXX: the OFF section. */
@@ -191,6 +206,8 @@ void indent_off ( void ) ;
 void           indent_on(void);
 /* INDENT OFF */
 void indent_off ( void ) ;
+/* $ FIXME: The empty line below must be removed. */
+
 /* $ XXX: The below comment got moved from column 9 to column 1. */
 /* INDENT ON */
 void           indent_on(void);        /* the comment may be indented */
@@ -200,6 +217,8 @@ void indent_off ( void ) ;
 void indent_still_off ( void ) ;       /* due to the word 'INDENTATION' */
 /* INDENT ON * */
 void indent_still_off ( void ) ;       /* due to the extra '*' at the end */
+/* $ FIXME: The empty line below must be removed. */
+
 /* INDENT ON */
 void           indent_on(void);
 /* INDENT: OFF */
diff -r c9b469ff3a9d -r 4ad8de056a3b tests/usr.bin/indent/lsym_form_feed.c
--- a/tests/usr.bin/indent/lsym_form_feed.c     Thu May 11 18:03:51 2023 +0000
+++ b/tests/usr.bin/indent/lsym_form_feed.c     Thu May 11 18:13:55 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_form_feed.c,v 1.5 2023/05/11 09:28:53 rillig Exp $ */
+/* $NetBSD: lsym_form_feed.c,v 1.6 2023/05/11 18:13:55 rillig Exp $ */
 
 /*
  * Tests for the token lsym_form_feed, which represents a form feed, a special
@@ -13,14 +13,7 @@ void function_1(void);
 void function_2(void);
 //indent end
 
-//indent run -di0
-void function_1(void);
-
-/* $ XXX: The form feed is not preserved. */
-/* $ XXX: Why 2 empty lines? */
-
-void function_2(void);
-//indent end
+//indent run-equals-input -di0
 
 
 /*
@@ -41,9 +34,7 @@ void
 function(void)
 {
        if (expr)
-               /* $ XXX: The form feed has disappeared. */
-
-               /* <-- form feed */
+              /* <-- form feed */
        {
        }
 }
diff -r c9b469ff3a9d -r 4ad8de056a3b tests/usr.bin/indent/lsym_lparen_or_lbracket.c
--- a/tests/usr.bin/indent/lsym_lparen_or_lbracket.c    Thu May 11 18:03:51 2023 +0000
+++ b/tests/usr.bin/indent/lsym_lparen_or_lbracket.c    Thu May 11 18:13:55 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.7 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.8 2023/05/11 18:13:55 rillig Exp $ */
 
 /*
  * Tests for the token lsym_lparen_or_lbracket, which represents a '(' or '['
@@ -297,9 +297,7 @@ cover_want_blank_before_lparen(void)
        }
 #define preprocessing
        (preprocessing)();
-
-/* $ XXX: Where has the '\f' gone? It should have been preserved. */
-       (lsym_form_feed)();     /* XXX: should be skipped */
+      (lsym_form_feed)();     /* XXX: should be skipped */
        for (;;);
        do
                (lsym_do) = 3;
diff -r c9b469ff3a9d -r 4ad8de056a3b tests/usr.bin/indent/opt_bacc.c
--- a/tests/usr.bin/indent/opt_bacc.c   Thu May 11 18:03:51 2023 +0000
+++ b/tests/usr.bin/indent/opt_bacc.c   Thu May 11 18:13:55 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bacc.c,v 1.10 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: opt_bacc.c,v 1.11 2023/05/11 18:13:55 rillig Exp $ */
 
 /*
  * Tests for the options '-bacc' and '-nbacc' ("blank line around conditional
@@ -55,17 +55,7 @@ int          space_b;
 int            space_c;
 //indent end
 
-//indent run -bacc
-int            space_a;
-/* $ FIXME: expecting a blank line here */
-#if 0
-
-/* $ FIXME: expecting NO blank line here */
-int            space_b;
-#endif
-
-int            space_c;
-//indent end
+//indent run-equals-input -bacc
 
 /* The option '-nbacc' does not remove anything. */
 //indent run-equals-input -nbacc
@@ -92,12 +82,8 @@ os_name(void)
 {
 /* $ FIXME: expecting a blank line here. */
 #if defined(__NetBSD__) || defined(__FreeBSD__)
-/* $ FIXME: expecting NO blank line here. */
-
        return "BSD";
 #else
-/* $ FIXME: expecting NO blank line here. */
-
        return "unknown";
 #endif
 /* $ FIXME: expecting a blank line here. */
@@ -118,15 +104,7 @@ int decl;
 #endif
 //indent end
 
-//indent run -di0 -bacc
-#if outer
-
-#if inner
-int decl;
-#endif
-
-#endif
-//indent end
+//indent run-equals-input -di0 -bacc
 
 //indent run-equals-input -di0 -nbacc
 
diff -r c9b469ff3a9d -r 4ad8de056a3b tests/usr.bin/indent/opt_bad.c
--- a/tests/usr.bin/indent/opt_bad.c    Thu May 11 18:03:51 2023 +0000
+++ b/tests/usr.bin/indent/opt_bad.c    Thu May 11 18:13:55 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bad.c,v 1.6 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: opt_bad.c,v 1.7 2023/05/11 18:13:55 rillig Exp $ */
 
 /*
  * Tests for the options '-bad' and '-nbad'.
@@ -67,10 +67,10 @@ void
 function_definition(void)
 {
        int             local_variable;
-
+/* $ TODO: add empty line */
        function_call();
        int             local_variable_after_statement;
-
+/* $ TODO: add empty line */
        function_call();
 }
 //indent end
diff -r c9b469ff3a9d -r 4ad8de056a3b tests/usr.bin/indent/opt_badp.c
--- a/tests/usr.bin/indent/opt_badp.c   Thu May 11 18:03:51 2023 +0000
+++ b/tests/usr.bin/indent/opt_badp.c   Thu May 11 18:13:55 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_badp.c,v 1.9 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: opt_badp.c,v 1.10 2023/05/11 18:13:55 rillig Exp $ */
 
 /*
  * Tests for the options '-badp' and '-nbadp'.
@@ -53,14 +53,8 @@ statement(void)
 }
 //indent end
 
-//indent run -badp
-void
-statement(void)
-{
-
-       stmt();
-}
-//indent end
+/* TODO: add blank line */
+//indent run-equals-input -badp
 
 //indent run-equals-input -nbadp
 
diff -r c9b469ff3a9d -r 4ad8de056a3b tests/usr.bin/indent/opt_bap_sob.c
--- a/tests/usr.bin/indent/opt_bap_sob.c        Thu May 11 18:03:51 2023 +0000
+++ b/tests/usr.bin/indent/opt_bap_sob.c        Thu May 11 18:13:55 2023 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: opt_bap_sob.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: opt_bap_sob.c,v 1.5 2023/05/11 18:13:55 rillig Exp $ */
 
 /*
- * As of 2021-03-08, the combination of -bap and -sob, which occurs in the
- * example indent.pro from NetBSD, removes the empty line above the
+ * Before 2023-05-11, the combination of -bap and -sob, which occurs in the
+ * example indent.pro from NetBSD, removed the empty line above the
  * separator.  Seen in games/cgram/cgram.c.
  */
 
@@ -27,26 +27,7 @@ function3(void)
 }
 //indent end
 
-//indent run -bap -sob
-void
-function1(void)
-{
-}
-/* $ FIXME: Keep the empty line between the '}' and the '//'. */
-///// C99 separator /////
-
-void
-function2(void)
-{
-}
-/* $ FIXME: Keep the empty line. */
-/* C block separator */
-
-void



Home | Main Index | Thread Index | Old Index