Module Name: src Committed By: rillig Date: Thu Oct 28 21:56:26 UTC 2021
Modified Files: src/usr.bin/indent: indent.c indent.h lexi.c Log Message: indent: reduce negations in search_stmt_lookahead No functional change. To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/usr.bin/indent/indent.c cvs rdiff -u -r1.53 -r1.54 src/usr.bin/indent/indent.h cvs rdiff -u -r1.105 -r1.106 src/usr.bin/indent/lexi.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.164 src/usr.bin/indent/indent.c:1.165 --- src/usr.bin/indent/indent.c:1.164 Thu Oct 28 21:51:43 2021 +++ src/usr.bin/indent/indent.c Thu Oct 28 21:56:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.164 2021/10/28 21:51:43 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.165 2021/10/28 21:56:26 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.164 2021/10/28 21:51:43 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.165 2021/10/28 21:56:26 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -333,12 +333,11 @@ search_stmt_lookahead(lexer_symbol *lsym inbuf_read_line(); } - struct parser_state transient_state = ps; - *lsym = lexi(&transient_state); /* read another token */ - if (*lsym != lsym_newline && *lsym != lsym_form_feed && - *lsym != lsym_comment && !transient_state.search_stmt) { - ps = transient_state; - } + struct parser_state backup_ps = ps; + *lsym = lexi(); + if (*lsym == lsym_newline || *lsym == lsym_form_feed || + *lsym == lsym_comment || ps.search_stmt) + ps = backup_ps; } /* @@ -1352,7 +1351,7 @@ main_loop(void) * reach eof */ bool comment_buffered = false; - lexer_symbol lsym = lexi(&ps); /* Read the next token. The actual + lexer_symbol lsym = lexi(); /* Read the next token. The actual * characters read are stored in * "token". */ Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.53 src/usr.bin/indent/indent.h:1.54 --- src/usr.bin/indent/indent.h:1.53 Thu Oct 28 21:51:43 2021 +++ src/usr.bin/indent/indent.h Thu Oct 28 21:56:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.53 2021/10/28 21:51:43 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.54 2021/10/28 21:56:26 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -368,7 +368,7 @@ void debug_println(const char *, ...)__p #endif void inbuf_skip(void); char inbuf_next(void); -lexer_symbol lexi(struct parser_state *); +lexer_symbol lexi(void); void diag(int, const char *, ...)__printflike(2, 3); void dump_line(void); void dump_line_ff(void); Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.105 src/usr.bin/indent/lexi.c:1.106 --- src/usr.bin/indent/lexi.c:1.105 Tue Oct 26 20:43:35 2021 +++ src/usr.bin/indent/lexi.c Thu Oct 28 21:56:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.105 2021/10/26 20:43:35 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.106 2021/10/28 21:56:26 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.105 2021/10/26 20:43:35 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.106 2021/10/28 21:56:26 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); #endif @@ -557,8 +557,10 @@ not_proc:; /* Reads the next token, placing it in the global variable "token". */ lexer_symbol -lexi(struct parser_state *state) +lexi(void) { + struct parser_state *state = &ps; + token.e = token.s; state->col_1 = state->last_nl; state->last_nl = false;