indent: clean up handling of whitespace
No functional change.
This commit is contained in:
parent
f8126bdc7e
commit
a28f6dc620
|
@ -1,5 +1,5 @@
|
|||
#! /bin/sh
|
||||
# $NetBSD: t_misc.sh,v 1.25 2023/05/15 17:38:56 rillig Exp $
|
||||
# $NetBSD: t_misc.sh,v 1.26 2023/06/05 07:23:03 rillig Exp $
|
||||
#
|
||||
# Copyright (c) 2021 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
|
@ -405,6 +405,16 @@ opt_v_break_line_body()
|
|||
"$indent" -v code.c -st
|
||||
}
|
||||
|
||||
|
||||
atf_test_case 'trailing_whitespace_in_preprocessing_line'
|
||||
trailing_whitespace_in_preprocessing_line_body()
|
||||
{
|
||||
printf '#if trailing && space \n#endif\n' > code.c
|
||||
|
||||
atf_check -o 'inline:#if trailing && space\n#endif\n' \
|
||||
"$indent" code.c -st
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case 'in_place'
|
||||
|
@ -421,4 +431,5 @@ atf_init_test_cases()
|
|||
atf_add_test_case 'several_profiles'
|
||||
atf_add_test_case 'command_line_vs_profile'
|
||||
atf_add_test_case 'in_place_parse_error'
|
||||
atf_add_test_case 'trailing_whitespace_in_preprocessing_line'
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: indent.c,v 1.327 2023/06/04 20:51:19 rillig Exp $ */
|
||||
/* $NetBSD: indent.c,v 1.328 2023/06/05 07:23:03 rillig Exp $ */
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: indent.c,v 1.327 2023/06/04 20:51:19 rillig Exp $");
|
||||
__RCSID("$NetBSD: indent.c,v 1.328 2023/06/05 07:23:03 rillig Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <err.h>
|
||||
|
@ -1001,9 +1001,6 @@ read_preprocessing_line(void)
|
|||
|
||||
buf_add_char(&lab, '#');
|
||||
|
||||
while (ch_isblank(inp_p[0]))
|
||||
buf_add_char(&lab, *inp_p++);
|
||||
|
||||
while (inp_p[0] != '\n' || (state == COMM && !had_eof)) {
|
||||
buf_add_char(&lab, inp_next());
|
||||
switch (lab.s[lab.len - 1]) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: io.c,v 1.194 2023/06/05 06:43:14 rillig Exp $ */
|
||||
/* $NetBSD: io.c,v 1.195 2023/06/05 07:23:03 rillig Exp $ */
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: io.c,v 1.194 2023/06/05 06:43:14 rillig Exp $");
|
||||
__RCSID("$NetBSD: io.c,v 1.195 2023/06/05 07:23:03 rillig Exp $");
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -179,10 +179,6 @@ is_blank_line_optional(void)
|
|||
static void
|
||||
output_line_label(void)
|
||||
{
|
||||
|
||||
while (lab.len > 0 && ch_isblank(lab.s[lab.len - 1]))
|
||||
lab.len--;
|
||||
|
||||
output_indent(compute_label_indent());
|
||||
output_range(lab.s, lab.len);
|
||||
}
|
||||
|
@ -202,10 +198,9 @@ output_line_code(void)
|
|||
}
|
||||
}
|
||||
|
||||
int label_end_ind = out_ind;
|
||||
output_indent(target_ind);
|
||||
if (label_end_ind > 0 && out_ind == label_end_ind)
|
||||
if (lab.len > 0 && target_ind <= out_ind)
|
||||
output_range(" ", 1);
|
||||
output_indent(target_ind);
|
||||
output_range(code.s, code.len);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue