Fri Jun 16 23:17:22 2023 UTC ()
indent: add debug output for typedef declarations


(rillig)
diff -r1.64 -r1.65 src/usr.bin/indent/debug.c

cvs diff -r1.64 -r1.65 src/usr.bin/indent/debug.c (expand / switch to unified diff)

--- src/usr.bin/indent/debug.c 2023/06/16 11:48:32 1.64
+++ src/usr.bin/indent/debug.c 2023/06/16 23:17:22 1.65
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: debug.c,v 1.64 2023/06/16 11:48:32 rillig Exp $ */ 1/* $NetBSD: debug.c,v 1.65 2023/06/16 23:17:22 rillig Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2023 The NetBSD Foundation, Inc. 4 * Copyright (c) 2023 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Roland Illig <rillig@NetBSD.org>. 8 * by Roland Illig <rillig@NetBSD.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__RCSID("$NetBSD: debug.c,v 1.64 2023/06/16 11:48:32 rillig Exp $"); 33__RCSID("$NetBSD: debug.c,v 1.65 2023/06/16 23:17:22 rillig Exp $");
34 34
35#include <stdarg.h> 35#include <stdarg.h>
36#include <string.h> 36#include <string.h>
37 37
38#include "indent.h" 38#include "indent.h"
39 39
40#ifdef debug 40#ifdef debug
41 41
42static struct { 42static struct {
43 // false show only the changes to the parser state 43 // false show only the changes to the parser state
44 // true show unchanged parts of the parser state as well 44 // true show unchanged parts of the parser state as well
45 bool full_parser_state; 45 bool full_parser_state;
46} config = { 46} config = {
@@ -320,26 +320,27 @@ debug_ps_di_stack(void) @@ -320,26 +320,27 @@ debug_ps_di_stack(void)
320#define debug_ps_enum(name, names) \ 320#define debug_ps_enum(name, names) \
321 debug_ps_enum_member(#name, (names)[state.prev_ps.name], \ 321 debug_ps_enum_member(#name, (names)[state.prev_ps.name], \
322 (names)[ps.name]) 322 (names)[ps.name])
323 323
324void 324void
325debug_parser_state(void) 325debug_parser_state(void)
326{ 326{
327 debug_blank_line(); 327 debug_blank_line();
328 328
329 state.heading = "token classification"; 329 state.heading = "token classification";
330 debug_ps_enum(prev_lsym, lsym_name); 330 debug_ps_enum(prev_lsym, lsym_name);
331 debug_ps_bool(in_stmt_or_decl); 331 debug_ps_bool(in_stmt_or_decl);
332 debug_ps_bool(in_decl); 332 debug_ps_bool(in_decl);
 333 debug_ps_bool(in_typedef_decl);
333 debug_ps_bool(in_var_decl); 334 debug_ps_bool(in_var_decl);
334 debug_ps_bool(in_init); 335 debug_ps_bool(in_init);
335 debug_ps_int(init_level); 336 debug_ps_int(init_level);
336 debug_ps_bool(line_has_func_def); 337 debug_ps_bool(line_has_func_def);
337 debug_ps_bool(in_func_def_params); 338 debug_ps_bool(in_func_def_params);
338 debug_ps_bool(line_has_decl); 339 debug_ps_bool(line_has_decl);
339 debug_ps_enum(lbrace_kind, psym_name); 340 debug_ps_enum(lbrace_kind, psym_name);
340 debug_ps_enum(spaced_expr_psym, psym_name); 341 debug_ps_enum(spaced_expr_psym, psym_name);
341 debug_ps_bool(seen_case); 342 debug_ps_bool(seen_case);
342 debug_ps_bool(prev_paren_was_cast); 343 debug_ps_bool(prev_paren_was_cast);
343 debug_ps_int(quest_level); 344 debug_ps_int(quest_level);
344 345
345 state.heading = "indentation of statements and declarations"; 346 state.heading = "indentation of statements and declarations";