Module Name: src Committed By: rillig Date: Sun Jun 4 17:02:06 UTC 2023
Modified Files: src/usr.bin/indent: debug.c indent.h Log Message: indent: fix debug output of the parser symbol stack Even though the stack always contains a stmt_list as first element, print it nevertheless to avoid confusion about starting at index 1, and to provide the full picture. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/usr.bin/indent/debug.c cvs rdiff -u -r1.168 -r1.169 src/usr.bin/indent/indent.h 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/debug.c diff -u src/usr.bin/indent/debug.c:1.31 src/usr.bin/indent/debug.c:1.32 --- src/usr.bin/indent/debug.c:1.31 Sun Jun 4 14:20:00 2023 +++ src/usr.bin/indent/debug.c Sun Jun 4 17:02:06 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.31 2023/06/04 14:20:00 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.32 2023/06/04 17:02:06 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: debug.c,v 1.31 2023/06/04 14:20:00 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.32 2023/06/04 17:02:06 rillig Exp $"); #include <stdarg.h> @@ -348,10 +348,8 @@ void debug_parse_stack(const char *situation) { printf("parse stack %s:", situation); - for (int i = 1; i <= ps.tos; ++i) + for (int i = 0; i <= ps.tos; ++i) printf(" %s %d", psym_name[ps.s_sym[i]], ps.s_ind_level[i]); - if (ps.tos == 0) - printf(" empty"); printf("\n"); } #endif Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.168 src/usr.bin/indent/indent.h:1.169 --- src/usr.bin/indent/indent.h:1.168 Sun Jun 4 14:20:00 2023 +++ src/usr.bin/indent/indent.h Sun Jun 4 17:02:06 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.168 2023/06/04 14:20:00 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.169 2023/06/04 17:02:06 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -112,10 +112,14 @@ typedef enum lexer_symbol { lsym_return, } lexer_symbol; +/* + * Structure of the source code, in terms of declarations, statements and + * braces; used to determine the indentation level of these parts. + */ typedef enum parser_symbol { - psym_0, /* a placeholder */ + psym_0, /* a placeholder; not stored on the stack */ psym_lbrace, - psym_rbrace, + psym_rbrace, /* not stored on the stack */ psym_decl, psym_stmt, psym_stmt_list,