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 support for form feed characte...



details:   https://anonhg.NetBSD.org/src/rev/927b160628b8
branches:  trunk
changeset: 375839:927b160628b8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue May 16 11:32:01 2023 +0000

description:
indent: remove support for form feed characters inside a line

Form feeds are occasionally used to split code into pages, and this use
is still supported.  Having a form feed in the middle of a line is
exotic.

diffstat:

 tests/usr.bin/indent/lsym_comment.c            |  20 ++++++--------------
 tests/usr.bin/indent/lsym_form_feed.c          |   4 ++--
 tests/usr.bin/indent/lsym_lparen_or_lbracket.c |   7 +++----
 usr.bin/indent/debug.c                         |   5 ++---
 usr.bin/indent/indent.c                        |  20 ++++----------------
 usr.bin/indent/indent.h                        |   3 +--
 usr.bin/indent/io.c                            |  24 ++++++------------------
 usr.bin/indent/lexi.c                          |  10 ++--------
 usr.bin/indent/pr_comment.c                    |  13 ++-----------
 9 files changed, 28 insertions(+), 78 deletions(-)

diffs (truncated from 321 to 300 lines):

diff -r fe7bd86ec90f -r 927b160628b8 tests/usr.bin/indent/lsym_comment.c
--- a/tests/usr.bin/indent/lsym_comment.c       Tue May 16 09:52:30 2023 +0000
+++ b/tests/usr.bin/indent/lsym_comment.c       Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_comment.c,v 1.12 2023/05/15 20:30:20 rillig Exp $ */
+/* $NetBSD: lsym_comment.c,v 1.13 2023/05/16 11:32:02 rillig Exp $ */
 
 /*
  * Tests for the token lsym_comment, which starts a comment.
@@ -880,9 +880,8 @@ int         decl;
 
 
 /*
- * At the beginning of a block comment or after a '*', '\f' is special. This
- * is an implementation detail that should not be visible from the outside.
- * Form feeds in comments are seldom used though, so this is no problem.
+ * Form feeds are seldom used, especially in comments, so treat them as an
+ * ordinary character.
  */
 //indent input
 /* comment*/
@@ -890,18 +889,11 @@ int               decl;
 //indent end
 
 //indent run
-/* * comment */
-/* text* * comment */
+/*  comment */
+/* text* comment */
 //indent end
 
-/*
- * Without 'star_comment_cont', there is no separator between the form feed
- * and the surrounding text.
- */
-//indent run -nsc
-/*comment */
-/* text*comment */
-//indent end
+//indent run-equals-prev-output -nsc
 
 //indent run-equals-input -nfc1
 
diff -r fe7bd86ec90f -r 927b160628b8 tests/usr.bin/indent/lsym_form_feed.c
--- a/tests/usr.bin/indent/lsym_form_feed.c     Tue May 16 09:52:30 2023 +0000
+++ b/tests/usr.bin/indent/lsym_form_feed.c     Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_form_feed.c,v 1.6 2023/05/11 18:13:55 rillig Exp $ */
+/* $NetBSD: lsym_form_feed.c,v 1.7 2023/05/16 11:32:02 rillig Exp $ */
 
 /*
  * Tests for the token lsym_form_feed, which represents a form feed, a special
@@ -34,7 +34,7 @@ void
 function(void)
 {
        if (expr)
-              /* <-- form feed */
+                              /* <-- form feed */
        {
        }
 }
diff -r fe7bd86ec90f -r 927b160628b8 tests/usr.bin/indent/lsym_lparen_or_lbracket.c
--- a/tests/usr.bin/indent/lsym_lparen_or_lbracket.c    Tue May 16 09:52:30 2023 +0000
+++ b/tests/usr.bin/indent/lsym_lparen_or_lbracket.c    Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.8 2023/05/11 18:13:55 rillig Exp $ */
+/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.9 2023/05/16 11:32:02 rillig Exp $ */
 
 /*
  * Tests for the token lsym_lparen_or_lbracket, which represents a '(' or '['
@@ -249,8 +249,7 @@ void cover_want_blank_before_lparen(void
        switch (expr) {}
 #define preprocessing
        (preprocessing)();
-       /* $ XXX: lsym_form_feed should be skipped, just as newline. */
-       (lsym_form_feed)();    /* XXX: should be skipped */
+       (lsym_form_feed)();
        for(;;);
        do(lsym_do)=3;while(0);
        if(cond);else(lsym_else)();
@@ -297,7 +296,7 @@ cover_want_blank_before_lparen(void)
        }
 #define preprocessing
        (preprocessing)();
-      (lsym_form_feed)();     /* XXX: should be skipped */
+       (lsym_form_feed)();
        for (;;);
        do
                (lsym_do) = 3;
diff -r fe7bd86ec90f -r 927b160628b8 usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c    Tue May 16 09:52:30 2023 +0000
+++ b/usr.bin/indent/debug.c    Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: debug.c,v 1.9 2023/05/15 22:52:21 rillig Exp $ */
+/*     $NetBSD: debug.c,v 1.10 2023/05/16 11:32:01 rillig Exp $        */
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.9 2023/05/15 22:52:21 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.10 2023/05/16 11:32:01 rillig Exp $");
 
 #include <stdarg.h>
 
@@ -48,7 +48,6 @@ const char *const lsym_name[] = {
     "eof",
     "preprocessing",
     "newline",
-    "form_feed",
     "comment",
     "lparen_or_lbracket",
     "rparen_or_rbracket",
diff -r fe7bd86ec90f -r 927b160628b8 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Tue May 16 09:52:30 2023 +0000
+++ b/usr.bin/indent/indent.c   Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.288 2023/05/16 08:22:11 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.289 2023/05/16 11:32:01 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.288 2023/05/16 08:22:11 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.289 2023/05/16 11:32:01 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -156,7 +156,7 @@ int
 ind_add(int ind, const char *s, size_t len)
 {
     for (const char *p = s; len > 0; p++, len--) {
-       if (*p == '\n' || *p == '\f')
+       if (*p == '\n')
            ind = 0;
        else if (*p == '\t')
            ind = next_tab(ind);
@@ -380,13 +380,6 @@ move_com_to_code(lexer_symbol lsym)
 }
 
 static void
-process_form_feed(void)
-{
-    output_line_ff();
-    ps.want_blank = false;
-}
-
-static void
 process_newline(void)
 {
     if (ps.prev_token == lsym_comma && ps.nparen == 0 && !ps.block_init &&
@@ -1025,8 +1018,7 @@ main_loop(void)
        if (lsym == lsym_if && ps.prev_token == lsym_else && opt.else_if)
            ps.force_nl = false;
 
-       if (lsym == lsym_newline || lsym == lsym_form_feed ||
-               lsym == lsym_preprocessing)
+       if (lsym == lsym_newline || lsym == lsym_preprocessing)
            ps.force_nl = false;
        else if (lsym != lsym_comment) {
            maybe_break_line(lsym);
@@ -1038,10 +1030,6 @@ main_loop(void)
 
        switch (lsym) {
 
-       case lsym_form_feed:
-           process_form_feed();
-           break;
-
        case lsym_newline:
            process_newline();
            break;
diff -r fe7bd86ec90f -r 927b160628b8 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Tue May 16 09:52:30 2023 +0000
+++ b/usr.bin/indent/indent.h   Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.144 2023/05/16 08:04:03 rillig Exp $      */
+/*     $NetBSD: indent.h,v 1.145 2023/05/16 11:32:01 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -72,7 +72,6 @@ typedef enum lexer_symbol {
     lsym_eof,
     lsym_preprocessing,                /* '#' */
     lsym_newline,
-    lsym_form_feed,
     lsym_comment,              /* the initial '/ *' or '//' of a comment */
     lsym_lparen_or_lbracket,
     lsym_rparen_or_rbracket,
diff -r fe7bd86ec90f -r 927b160628b8 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Tue May 16 09:52:30 2023 +0000
+++ b/usr.bin/indent/io.c       Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.173 2023/05/16 08:04:03 rillig Exp $  */
+/*     $NetBSD: io.c,v 1.174 2023/05/16 11:32:01 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.173 2023/05/16 08:04:03 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.174 2023/05/16 11:32:01 rillig Exp $");
 
 #include <stdio.h>
 #include <string.h>
@@ -236,12 +236,12 @@ output_line_comment(int ind)
  *
  * Comments are written directly, bypassing this function.
  */
-static void
-output_complete_line(char line_terminator)
+void
+output_line(void)
 {
     debug_printf("%s", __func__);
     debug_buffers();
-    debug_println("%s", line_terminator == '\f' ? " form_feed" : "");
+    debug_println("");
 
     ps.is_function_definition = false;
 
@@ -269,7 +269,7 @@ output_complete_line(char line_terminato
        if (com.len > 0)
            output_line_comment(ind);
 
-       output_char(line_terminator);
+       output_char('\n');
     }
 
     if (indent_enabled == indent_last_off_line) {
@@ -300,18 +300,6 @@ output_complete_line(char line_terminato
     ps.want_blank = false;
 }
 
-void
-output_line(void)
-{
-    output_complete_line('\n');
-}
-
-void
-output_line_ff(void)
-{
-    output_complete_line('\f');
-}
-
 static int
 compute_code_indent_lineup(int base_ind)
 {
diff -r fe7bd86ec90f -r 927b160628b8 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Tue May 16 09:52:30 2023 +0000
+++ b/usr.bin/indent/lexi.c     Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.194 2023/05/16 08:04:03 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.195 2023/05/16 11:32:01 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.194 2023/05/16 08:04:03 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.195 2023/05/16 11:32:01 rillig Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -575,12 +575,6 @@ lexi(void)
        ps.next_col_1 = true;
        break;
 
-    case '\f':
-       lsym = lsym_form_feed;
-       next_unary = ps.next_unary;
-       ps.next_col_1 = true;
-       break;
-
     case '#':
        lsym = lsym_preprocessing;
        next_unary = ps.next_unary;
diff -r fe7bd86ec90f -r 927b160628b8 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Tue May 16 09:52:30 2023 +0000
+++ b/usr.bin/indent/pr_comment.c       Tue May 16 11:32:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.142 2023/05/15 19:55:51 rillig Exp $  */
+/*     $NetBSD: pr_comment.c,v 1.143 2023/05/16 11:32:01 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>



Home | Main Index | Thread Index | Old Index