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.
This commit is contained in:
parent
6b1434d492
commit
81c7fd789d
|
@ -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
|
||||
|
||||
|
|
|
@ -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 */
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
@ -379,13 +379,6 @@ move_com_to_code(lexer_symbol lsym)
|
|||
ps.want_blank = false;
|
||||
}
|
||||
|
||||
static void
|
||||
process_form_feed(void)
|
||||
{
|
||||
output_line_ff();
|
||||
ps.want_blank = false;
|
||||
}
|
||||
|
||||
static void
|
||||
process_newline(void)
|
||||
{
|
||||
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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_terminator)
|
|||
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_terminator)
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 delim)
|
|||
|
||||
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");
|
||||
|
|
Loading…
Reference in New Issue