Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/indent indent: reduce negations in search_stmt_looka...



details:   https://anonhg.NetBSD.org/src/rev/a697b4d829e4
branches:  trunk
changeset: 990487:a697b4d829e4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Oct 28 21:56:26 2021 +0000

description:
indent: reduce negations in search_stmt_lookahead

No functional change.

diffstat:

 usr.bin/indent/indent.c |  17 ++++++++---------
 usr.bin/indent/indent.h |   4 ++--
 usr.bin/indent/lexi.c   |   8 +++++---
 3 files changed, 15 insertions(+), 14 deletions(-)

diffs (93 lines):

diff -r 4adbbc603858 -r a697b4d829e4 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu Oct 28 21:51:43 2021 +0000
+++ b/usr.bin/indent/indent.c   Thu Oct 28 21:56:26 2021 +0000
@@ -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 @@
 
 #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 @@
            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 @@
                                 * 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". */
 
diff -r 4adbbc603858 -r a697b4d829e4 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Thu Oct 28 21:51:43 2021 +0000
+++ b/usr.bin/indent/indent.h   Thu Oct 28 21:56:26 2021 +0000
@@ -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 @@
 #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);
diff -r 4adbbc603858 -r a697b4d829e4 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Thu Oct 28 21:51:43 2021 +0000
+++ b/usr.bin/indent/lexi.c     Thu Oct 28 21:56:26 2021 +0000
@@ -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 @@
 
 #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 @@
 
 /* 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;



Home | Main Index | Thread Index | Old Index