Module Name: src Committed By: rillig Date: Wed Jun 14 07:20:55 UTC 2023
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile psym_stmt.c src/usr.bin/indent: debug.c indent.c indent.h parse.c Removed Files: src/tests/usr.bin/indent: psym_stmt_list.c Log Message: indent: merge parser symbols for stmt and stmt_list They were handled in exactly the same way. To generate a diff of this commit: cvs rdiff -u -r1.1266 -r1.1267 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.47 -r1.48 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/psym_stmt.c cvs rdiff -u -r1.5 -r0 src/tests/usr.bin/indent/psym_stmt_list.c cvs rdiff -u -r1.53 -r1.54 src/usr.bin/indent/debug.c cvs rdiff -u -r1.357 -r1.358 src/usr.bin/indent/indent.c cvs rdiff -u -r1.188 -r1.189 src/usr.bin/indent/indent.h cvs rdiff -u -r1.72 -r1.73 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1266 src/distrib/sets/lists/tests/mi:1.1267 --- src/distrib/sets/lists/tests/mi:1.1266 Thu Jun 1 07:27:30 2023 +++ src/distrib/sets/lists/tests/mi Wed Jun 14 07:20:54 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1266 2023/06/01 07:27:30 rillig Exp $ +# $NetBSD: mi,v 1.1267 2023/06/14 07:20:54 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5252,7 +5252,7 @@ ./usr/tests/usr.bin/indent/psym_rbrace.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/psym_semicolon.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/psym_stmt.c tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/indent/psym_stmt_list.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/indent/psym_stmt_list.c tests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/psym_switch_expr.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/psym_while_expr.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/struct.0 tests-obsolete obsolete,atf Index: src/tests/usr.bin/indent/Makefile diff -u src/tests/usr.bin/indent/Makefile:1.47 src/tests/usr.bin/indent/Makefile:1.48 --- src/tests/usr.bin/indent/Makefile:1.47 Sat May 20 21:32:05 2023 +++ src/tests/usr.bin/indent/Makefile Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.47 2023/05/20 21:32:05 rillig Exp $ +# $NetBSD: Makefile,v 1.48 2023/06/14 07:20:55 rillig Exp $ .include <bsd.own.mk> @@ -109,7 +109,6 @@ FILES+= psym_lbrace.c FILES+= psym_rbrace.c FILES+= psym_semicolon.c FILES+= psym_stmt.c -FILES+= psym_stmt_list.c FILES+= psym_switch_expr.c FILES+= psym_while_expr.c FILES+= t_options.lua Index: src/tests/usr.bin/indent/psym_stmt.c diff -u src/tests/usr.bin/indent/psym_stmt.c:1.6 src/tests/usr.bin/indent/psym_stmt.c:1.7 --- src/tests/usr.bin/indent/psym_stmt.c:1.6 Fri Jun 9 10:24:55 2023 +++ src/tests/usr.bin/indent/psym_stmt.c Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: psym_stmt.c,v 1.6 2023/06/09 10:24:55 rillig Exp $ */ +/* $NetBSD: psym_stmt.c,v 1.7 2023/06/14 07:20:55 rillig Exp $ */ /* * Tests for the parser symbol psym_stmt, which represents a statement on the @@ -39,3 +39,40 @@ function(void) //indent end //indent run-equals-input -di0 -nlp -ci4 + + +//indent input +void +function(void) +{ + stmt(); + int var; + stmt(); + { + stmt(); + int var; + stmt(); + } +} +//indent end + +//indent run-equals-input -ldi0 + + +//indent input +void +return_after_rbrace(void) +{ + {}return; +} +//indent end + +//indent run +void +return_after_rbrace(void) +{ + { + } + return; +} +//indent end Index: src/usr.bin/indent/debug.c diff -u src/usr.bin/indent/debug.c:1.53 src/usr.bin/indent/debug.c:1.54 --- src/usr.bin/indent/debug.c:1.53 Sat Jun 10 21:36:38 2023 +++ src/usr.bin/indent/debug.c Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $"); #include <stdarg.h> #include <string.h> @@ -99,7 +99,6 @@ const char *const psym_name[] = { "}", "decl", "stmt", - "stmt_list", "for_exprs", "if_expr", "if_expr_stmt", Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.357 src/usr.bin/indent/indent.c:1.358 --- src/usr.bin/indent/indent.c:1.357 Sat Jun 10 21:36:38 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.358 2023/06/14 07:20:55 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.358 2023/06/14 07:20:55 rillig Exp $"); #include <sys/param.h> #include <err.h> @@ -184,7 +184,7 @@ ind_add(int ind, const char *s, size_t l static void init_globals(void) { - ps.psyms.sym[0] = psym_stmt_list; + ps.psyms.sym[0] = psym_stmt; ps.prev_lsym = lsym_semicolon; ps.next_col_1 = true; ps.lbrace_kind = psym_lbrace_block; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.188 src/usr.bin/indent/indent.h:1.189 --- src/usr.bin/indent/indent.h:1.188 Sat Jun 10 21:36:38 2023 +++ src/usr.bin/indent/indent.h Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.188 2023/06/10 21:36:38 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.189 2023/06/14 07:20:55 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -129,7 +129,6 @@ typedef enum parser_symbol { psym_rbrace, /* not stored on the stack */ psym_decl, psym_stmt, - psym_stmt_list, psym_for_exprs, /* 'for' '(' ... ')' */ psym_if_expr, /* 'if' '(' expr ')' */ psym_if_expr_stmt, /* 'if' '(' expr ')' stmt */ Index: src/usr.bin/indent/parse.c diff -u src/usr.bin/indent/parse.c:1.72 src/usr.bin/indent/parse.c:1.73 --- src/usr.bin/indent/parse.c:1.72 Sat Jun 10 17:35:40 2023 +++ src/usr.bin/indent/parse.c Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.72 2023/06/10 17:35:40 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.73 2023/06/14 07:20:55 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: parse.c,v 1.72 2023/06/10 17:35:40 rillig Exp $"); +__RCSID("$NetBSD: parse.c,v 1.73 2023/06/14 07:20:55 rillig Exp $"); #include <err.h> @@ -54,8 +54,7 @@ psyms_reduce_stmt(struct psym_stack *psy switch (psyms->sym[psyms->top - 1]) { case psym_stmt: - case psym_stmt_list: - psyms->sym[--psyms->top] = psym_stmt_list; + psyms->sym[--psyms->top] = psym_stmt; return true; case psym_do: @@ -67,7 +66,6 @@ psyms_reduce_stmt(struct psym_stack *psy psyms->sym[--psyms->top] = psym_if_expr_stmt; int i = psyms->top - 1; while (psyms->sym[i] != psym_stmt && - psyms->sym[i] != psym_stmt_list && psyms->sym[i] != psym_lbrace_block) --i; ps.ind_level_follow = psyms->ind_level[i]; @@ -162,8 +160,7 @@ parse(parser_symbol psym) case psym_lbrace_enum: ps.break_after_comma = false; if (psyms->sym[psyms->top] == psym_decl - || psyms->sym[psyms->top] == psym_stmt - || psyms->sym[psyms->top] == psym_stmt_list) + || psyms->sym[psyms->top] == psym_stmt) ++ps.ind_level_follow; else if (code.len == 0) { /* It is part of a while, for, etc. */