Module Name: src Committed By: rillig Date: Sat Oct 30 22:36:07 UTC 2021
Modified Files: src/tests/usr.bin/indent: token_binary_op.c token_comment.c src/usr.bin/indent: indent.c indent.h lexi.c pr_comment.c Log Message: indent: rename prev_newline and prev_col_1 to curr These two flags describe the token that is currently processed. In process_binary_op, curr_newline can never be true since newline is not a binary operator, so remove that condition. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token_binary_op.c cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/indent/token_comment.c cvs rdiff -u -r1.194 -r1.195 src/usr.bin/indent/indent.c cvs rdiff -u -r1.65 -r1.66 src/usr.bin/indent/indent.h cvs rdiff -u -r1.116 -r1.117 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.92 -r1.93 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/token_binary_op.c diff -u src/tests/usr.bin/indent/token_binary_op.c:1.5 src/tests/usr.bin/indent/token_binary_op.c:1.6 --- src/tests/usr.bin/indent/token_binary_op.c:1.5 Fri Oct 29 22:37:25 2021 +++ src/tests/usr.bin/indent/token_binary_op.c Sat Oct 30 22:36:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: token_binary_op.c,v 1.5 2021/10/29 22:37:25 rillig Exp $ */ +/* $NetBSD: token_binary_op.c,v 1.6 2021/10/30 22:36:07 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -245,7 +245,7 @@ char *(*fn)(int, int) = NULL; * Ensure that the result of the indentation does not depend on whether a * token from the input starts in column 1 or 9. * - * See process_binary_op, ps.prev_col_1. + * See process_binary_op, ps.curr_col_1. */ #indent input int col_1 // Index: src/tests/usr.bin/indent/token_comment.c diff -u src/tests/usr.bin/indent/token_comment.c:1.14 src/tests/usr.bin/indent/token_comment.c:1.15 --- src/tests/usr.bin/indent/token_comment.c:1.14 Sat Oct 30 16:57:18 2021 +++ src/tests/usr.bin/indent/token_comment.c Sat Oct 30 22:36:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: token_comment.c,v 1.14 2021/10/30 16:57:18 rillig Exp $ */ +/* $NetBSD: token_comment.c,v 1.15 2021/10/30 22:36:07 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -41,7 +41,7 @@ * - with varying opt.comment_column (-c0, -c1, -c33, -c80) * - with varying opt.decl_comment_column (-cd0, -cd1, -cd20, -cd33, -cd80) * - with/without ps.decl_on_line - * - with/without ps.prev_newline + * - with/without ps.curr_newline * * - very long comments that overflow the buffer 'com' * - comments that come from save_com Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.194 src/usr.bin/indent/indent.c:1.195 --- src/usr.bin/indent/indent.c:1.194 Sat Oct 30 20:01:46 2021 +++ src/usr.bin/indent/indent.c Sat Oct 30 22:36:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.194 2021/10/30 20:01:46 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.195 2021/10/30 22:36:07 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.194 2021/10/30 20:01:46 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.195 2021/10/30 22:36:07 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -512,7 +512,7 @@ main_init_globals(void) ps.s_sym[0] = psym_stmt_list; ps.prev_token = lsym_semicolon; - ps.prev_newline = true; + ps.curr_newline = true; const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX"); if (suffix != NULL) @@ -850,7 +850,7 @@ process_unary_op(int decl_ind, bool tabs static void process_binary_op(void) { - if (!ps.prev_newline && buf_len(&code) > 0) + if (buf_len(&code) > 0) buf_add_char(&code, ' '); buf_add_buf(&code, &token); ps.want_blank = true; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.65 src/usr.bin/indent/indent.h:1.66 --- src/usr.bin/indent/indent.h:1.65 Sat Oct 30 22:15:51 2021 +++ src/usr.bin/indent/indent.h Sat Oct 30 22:36:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.65 2021/10/30 22:15:51 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.66 2021/10/30 22:36:07 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -282,12 +282,11 @@ extern struct parser_state { * means exactly the same thing. */ lexer_symbol prev_token; - bool prev_newline; /* whether the last thing scanned was a - * newline */ - bool prev_col_1; /* whether the last token started in column 1 - * of the unformatted input */ enum keyword_kind prev_keyword; enum keyword_kind curr_keyword; + bool curr_newline; + bool curr_col_1; /* whether the current token started in column + * 1 of the unformatted input */ bool next_unary; /* whether the following operator should be * unary */ Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.116 src/usr.bin/indent/lexi.c:1.117 --- src/usr.bin/indent/lexi.c:1.116 Sat Oct 30 22:25:11 2021 +++ src/usr.bin/indent/lexi.c Sat Oct 30 22:36:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.116 2021/10/30 22:25:11 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.117 2021/10/30 22:36:07 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c 8.1 ( #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: lexi.c,v 1.116 2021/10/30 22:25:11 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.117 2021/10/30 22:36:07 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); #endif @@ -310,10 +310,10 @@ debug_lexi(lexer_symbol lsym) debug_print_buf("comment", &com); // prev_token - debug_ps_bool(prev_newline); - debug_ps_bool(prev_col_1); debug_ps_keyword(prev_keyword); debug_ps_keyword(curr_keyword); + debug_ps_bool(curr_newline); + debug_ps_bool(curr_col_1); debug_ps_bool(next_unary); // procname debug_ps_bool(want_blank); @@ -603,13 +603,13 @@ lexer_symbol lexi(void) { token.e = token.s; - ps.prev_col_1 = ps.prev_newline; - ps.prev_newline = false; + ps.curr_col_1 = ps.curr_newline; + ps.curr_newline = false; ps.prev_keyword = ps.curr_keyword; ps.curr_keyword = kw_0; while (ch_isblank(*inp.s)) { - ps.prev_col_1 = false; + ps.curr_col_1 = false; inbuf_skip(); } @@ -630,7 +630,7 @@ lexi(void) switch (*token.s) { case '\n': unary_delim = ps.next_unary; - ps.prev_newline = true; + ps.curr_newline = true; /* if data has been exhausted, the newline is a dummy. */ lsym = had_eof ? lsym_eof : lsym_newline; break; @@ -684,7 +684,7 @@ lexi(void) case '\f': unary_delim = ps.next_unary; - ps.prev_newline = true; + ps.curr_newline = true; lsym = lsym_form_feed; break; Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.92 src/usr.bin/indent/pr_comment.c:1.93 --- src/usr.bin/indent/pr_comment.c:1.92 Sat Oct 30 18:23:17 2021 +++ src/usr.bin/indent/pr_comment.c Sat Oct 30 22:36:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.92 2021/10/30 18:23:17 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.93 2021/10/30 22:36:07 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: pr_comment.c,v 1.92 2021/10/30 18:23:17 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.93 2021/10/30 22:36:07 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $"); #endif @@ -135,7 +135,7 @@ process_comment(void) /* Figure where to align and how to treat the comment */ - if (ps.prev_col_1 && !opt.format_col1_comments) { + if (ps.curr_col_1 && !opt.format_col1_comments) { may_wrap = false; break_delim = false; com_ind = 0; @@ -249,7 +249,7 @@ process_comment(void) } last_blank = -1; - if (!may_wrap || ps.prev_newline) { /* if this is a boxed comment, + if (!may_wrap || ps.curr_newline) { /* if this is a boxed comment, * we handle the newline */ if (com.s == com.e) com_add_char(' '); @@ -262,7 +262,7 @@ process_comment(void) com_add_delim(); } else { - ps.prev_newline = true; + ps.curr_newline = true; if (!ch_isblank(com.e[-1])) com_add_char(' '); last_blank = com.e - 1 - com.buf; @@ -329,7 +329,7 @@ process_comment(void) break; } - ps.prev_newline = false; + ps.curr_newline = false; if (now_len <= adj_max_line_length || !may_wrap) break;