Module Name: src Committed By: rillig Date: Sun Oct 31 17:22:48 UTC 2021
Modified Files: src/tests/usr.bin/indent: fmt_decl.c src/usr.bin/indent: lexi.c Log Message: indent: in debug log, print token subtype in same line The keyword 'void' is parsed as lsym_type in some cases and lsym_ident in others. Its corresponding keyword is always kw_type though. Put the subtype into the same line as the other token information. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.121 -r1.122 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/tests/usr.bin/indent/fmt_decl.c diff -u src/tests/usr.bin/indent/fmt_decl.c:1.8 src/tests/usr.bin/indent/fmt_decl.c:1.9 --- src/tests/usr.bin/indent/fmt_decl.c:1.8 Sun Oct 31 10:56:19 2021 +++ src/tests/usr.bin/indent/fmt_decl.c Sun Oct 31 17:22:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_decl.c,v 1.8 2021/10/31 10:56:19 rillig Exp $ */ +/* $NetBSD: fmt_decl.c,v 1.9 2021/10/31 17:22:48 rillig Exp $ */ /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */ /* See FreeBSD r303570 */ @@ -62,27 +62,27 @@ typedef struct Complex { * As of 2021-10-31, indent parses the following function definition as these * tokens: * - * line 1: type "void" + * line 1: type type "void" * line 1: newline "\n" * line 2: funcname "t1" * line 2: newline "\n" repeated, see search_stmt * line 3: funcname "t1" XXX: wrong line_no * line 3: lparen_or_lbracket "(" - * line 3: ident "char" XXX: should be 'type', intuitively + * line 3: ident type "char" * line 3: unary_op "*" * line 3: ident "a" * line 3: comma "," - * line 3: ident "int" XXX: should be 'type' + * line 3: ident type "int" * line 3: ident "b" * line 3: comma "," * line 3: newline "\n" - * line 4: ident "void" XXX: should be 'type' + * line 4: ident type "void" * line 4: lparen_or_lbracket "(" * line 4: unary_op "*" * line 4: ident "fn" * line 4: rparen_or_rbracket ")" * line 4: lparen_or_lbracket "(" - * line 4: ident "void" XXX: should be 'type' + * line 4: ident type "void" * line 4: rparen_or_rbracket ")" * line 4: rparen_or_rbracket ")" * line 4: newline "\n" Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.121 src/usr.bin/indent/lexi.c:1.122 --- src/usr.bin/indent/lexi.c:1.121 Sun Oct 31 10:09:43 2021 +++ src/usr.bin/indent/lexi.c Sun Oct 31 17:22:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.121 2021/10/31 10:09:43 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.122 2021/10/31 17:22:47 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.121 2021/10/31 10:09:43 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.122 2021/10/31 17:22:47 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); #endif @@ -305,14 +305,16 @@ debug_lexi(lexer_symbol lsym) debug_println(""); debug_printf("line %d: %s", line_no, lsym_name(lsym)); + if (ps.curr_keyword != kw_0) + debug_printf(" %s", kw_name(ps.curr_keyword)); debug_vis_range(" \"", token.s, token.e, "\"\n"); + debug_print_buf("label", &lab); debug_print_buf("code", &code); debug_print_buf("comment", &com); - // prev_token + debug_println(" ps.prev_token = %s", lsym_name(ps.prev_token)); debug_ps_keyword(prev_keyword); - debug_ps_keyword(curr_keyword); debug_ps_bool(curr_newline); debug_ps_bool(curr_col_1); debug_ps_bool(next_unary);