Module Name:    src
Committed By:   rillig
Date:           Tue May 16 11:32:02 UTC 2023

Modified Files:
        src/tests/usr.bin/indent: lsym_comment.c lsym_form_feed.c
            lsym_lparen_or_lbracket.c
        src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c pr_comment.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/lsym_comment.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/lsym_form_feed.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.288 -r1.289 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.173 -r1.174 src/usr.bin/indent/io.c
cvs rdiff -u -r1.194 -r1.195 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.142 -r1.143 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/lsym_comment.c
diff -u src/tests/usr.bin/indent/lsym_comment.c:1.12 src/tests/usr.bin/indent/lsym_comment.c:1.13
--- src/tests/usr.bin/indent/lsym_comment.c:1.12	Mon May 15 20:30:20 2023
+++ src/tests/usr.bin/indent/lsym_comment.c	Tue May 16 11:32:02 2023
@@ -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
 

Index: src/tests/usr.bin/indent/lsym_form_feed.c
diff -u src/tests/usr.bin/indent/lsym_form_feed.c:1.6 src/tests/usr.bin/indent/lsym_form_feed.c:1.7
--- src/tests/usr.bin/indent/lsym_form_feed.c:1.6	Thu May 11 18:13:55 2023
+++ src/tests/usr.bin/indent/lsym_form_feed.c	Tue May 16 11:32:02 2023
@@ -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 */
 	{
 	}
 }

Index: src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c
diff -u src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.8 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.9
--- src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.8	Thu May 11 18:13:55 2023
+++ src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c	Tue May 16 11:32:02 2023
@@ -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;

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.9 src/usr.bin/indent/debug.c:1.10
--- src/usr.bin/indent/debug.c:1.9	Mon May 15 22:52:21 2023
+++ src/usr.bin/indent/debug.c	Tue May 16 11:32:01 2023
@@ -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",

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.288 src/usr.bin/indent/indent.c:1.289
--- src/usr.bin/indent/indent.c:1.288	Tue May 16 08:22:11 2023
+++ src/usr.bin/indent/indent.c	Tue May 16 11:32:01 2023
@@ -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;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.144 src/usr.bin/indent/indent.h:1.145
--- src/usr.bin/indent/indent.h:1.144	Tue May 16 08:04:03 2023
+++ src/usr.bin/indent/indent.h	Tue May 16 11:32:01 2023
@@ -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,

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.173 src/usr.bin/indent/io.c:1.174
--- src/usr.bin/indent/io.c:1.173	Tue May 16 08:04:03 2023
+++ src/usr.bin/indent/io.c	Tue May 16 11:32:01 2023
@@ -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)
 {

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.194 src/usr.bin/indent/lexi.c:1.195
--- src/usr.bin/indent/lexi.c:1.194	Tue May 16 08:04:03 2023
+++ src/usr.bin/indent/lexi.c	Tue May 16 11:32:01 2023
@@ -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;

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.142 src/usr.bin/indent/pr_comment.c:1.143
--- src/usr.bin/indent/pr_comment.c:1.142	Mon May 15 19:55:51 2023
+++ src/usr.bin/indent/pr_comment.c	Tue May 16 11:32:01 2023
@@ -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>
-__RCSID("$NetBSD: pr_comment.c,v 1.142 2023/05/15 19:55:51 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.143 2023/05/16 11:32:01 rillig Exp $");
 
 #include <string.h>
 
@@ -164,15 +164,6 @@ copy_comment_wrap(int line_length, bool 
 
     for (;;) {
 	switch (inp_peek()) {
-	case '\f':
-	    output_line_ff();
-	    last_blank = -1;
-	    com_add_delim();
-	    inp_skip();
-	    while (ch_isblank(inp_peek()))
-		inp_skip();
-	    break;
-
 	case '\n':
 	    if (had_eof) {
 		diag(1, "Unterminated comment");

Reply via email to