Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: make read_until_parent easier to u...



details:   https://anonhg.NetBSD.org/src/rev/06822f1466b4
branches:  trunk
changeset: 373049:06822f1466b4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 15 00:05:38 2023 +0000

description:
lint: make read_until_parent easier to understand

Previously, the '--level' in the loop condition looked as if it applied
more often than it really does.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diffs (35 lines):

diff -r 1475f402eb58 -r 06822f1466b4 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Jan 14 17:31:01 2023 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Jan 15 00:05:38 2023 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.425 2023/01/14 10:33:34 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.426 2023/01/15 00:05:38 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.425 2023/01/14 10:33:34 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.426 2023/01/15 00:05:38 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -2146,12 +2146,11 @@
        freeyyv(&yylval, yychar);
 
        level = 1;
-       while (yychar != T_RPAREN || --level > 0) {
-               if (yychar == T_LPAREN) {
+       while (yychar > 0) {
+               if (yychar == T_LPAREN)
                        level++;
-               } else if (yychar <= 0) {
+               if (yychar == T_RPAREN && --level == 0)
                        break;
-               }
                freeyyv(&yylval, yychar = yylex());
        }
 



Home | Main Index | Thread Index | Old Index