Module Name: src Committed By: rillig Date: Sat Nov 27 18:29:29 UTC 2021
Modified Files: src/usr.bin/indent: indent.c Log Message: indent: inline switch_buffer The function name was not accurate all the time. Now that inp_from_comment is a separate function, it doesn't make sense anymore to offload the 3 simple statements to a separate function. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.234 src/usr.bin/indent/indent.c:1.235 --- src/usr.bin/indent/indent.c:1.234 Fri Nov 26 15:18:18 2021 +++ src/usr.bin/indent/indent.c Sat Nov 27 18:29:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.234 2021/11/26 15:18:18 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.235 2021/11/27 18:29:29 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1 #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: indent.c,v 1.234 2021/11/26 15:18:18 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.235 2021/11/27 18:29:29 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -269,11 +269,11 @@ search_stmt_comment(void) if (token.e[-1] == '/') { while (inp_peek() != '\n') inp_comment_add_char(inp_next()); - debug_inp("search_stmt_comment end C99"); + debug_inp("search_stmt_comment: end of C99 comment"); } else { while (!inp_comment_complete_block()) inp_comment_add_char(inp_next()); - debug_inp("search_stmt_comment end block"); + debug_inp("search_stmt_comment: end of block comment"); } } @@ -330,8 +330,8 @@ search_stmt_other(lexer_symbol lsym, boo inp_comment_rtrim_newline(); } - if (*force_nl) { /* if we should insert a nl here, put it into - * the buffer */ + if (*force_nl) { /* if we should insert a newline here, put it + * into the buffer */ *force_nl = false; --line_no; /* this will be re-increased when the newline * is read from the buffer */ @@ -348,14 +348,6 @@ search_stmt_other(lexer_symbol lsym, boo } static void -switch_buffer(void) -{ - ps.search_stmt = false; - inp_comment_add_char(' '); /* add trailing blank, just in case */ - inp_from_comment(); -} - -static void search_stmt_lookahead(lexer_symbol *lsym) { if (*lsym == lsym_eof) @@ -426,7 +418,9 @@ search_stmt(lexer_symbol *lsym, bool *fo *last_else)) return; switch_buffer: - switch_buffer(); + ps.search_stmt = false; + inp_comment_add_char(' '); /* add trailing blank, just in case */ + inp_from_comment(); } search_stmt_lookahead(lsym); }