Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: clean up debugging code
details: https://anonhg.NetBSD.org/src/rev/3026dfdea475
branches: trunk
changeset: 376368:3026dfdea475
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Jun 14 09:57:02 2023 +0000
description:
indent: clean up debugging code
diffstat:
usr.bin/indent/debug.c | 32 +++++++++++++++-----------------
usr.bin/indent/indent.h | 6 +++---
usr.bin/indent/io.c | 8 +++++---
3 files changed, 23 insertions(+), 23 deletions(-)
diffs (161 lines):
diff -r 291d784bcee7 -r 3026dfdea475 usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c Wed Jun 14 09:31:05 2023 +0000
+++ b/usr.bin/indent/debug.c Wed Jun 14 09:57:02 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.57 2023/06/14 09:31:05 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.58 2023/06/14 09:57:02 rillig Exp $ */
/*-
* Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.57 2023/06/14 09:31:05 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.58 2023/06/14 09:57:02 rillig Exp $");
#include <stdarg.h>
#include <string.h>
@@ -40,10 +40,8 @@
#ifdef debug
static struct {
- /*-
- * false show only the changes to the parser state
- * true show unchanged parts of the parser state as well
- */
+ // false show only the changes to the parser state
+ // true show unchanged parts of the parser state as well
bool full_parser_state;
} config = {
.full_parser_state = false,
@@ -191,10 +189,9 @@ debug_blank_line(void)
}
void
-debug_vis_range(const char *prefix, const char *s, size_t len,
- const char *suffix)
+debug_vis_range(const char *s, size_t len)
{
- debug_printf("%s", prefix);
+ debug_printf("\"");
for (size_t i = 0; i < len; i++) {
const char *p = s + i;
if (*p == '\\' || *p == '"')
@@ -208,7 +205,7 @@ debug_vis_range(const char *prefix, cons
else
debug_printf("\\x%02x", (unsigned char)*p);
}
- debug_printf("%s", suffix);
+ debug_printf("\"");
}
void
@@ -216,7 +213,7 @@ debug_print_buf(const char *name, const
{
if (buf->len > 0) {
debug_printf(" %s ", name);
- debug_vis_range("\"", buf->s, buf->len, "\"");
+ debug_vis_range(buf->s, buf->len);
}
}
@@ -230,7 +227,7 @@ debug_buffers(void)
}
static void
-write_ps_bool(const char *name, bool prev, bool curr)
+debug_ps_bool_member(const char *name, bool prev, bool curr)
{
if (!state.ps_first && curr != prev) {
char diff = " -+x"[(prev ? 1 : 0) + (curr ? 2 : 0)];
@@ -240,7 +237,7 @@ write_ps_bool(const char *name, bool pre
}
static void
-write_ps_int(const char *name, int prev, int curr)
+debug_ps_int_member(const char *name, int prev, int curr)
{
if (!state.ps_first && curr != prev)
debug_println(" %3d -> %3d ps.%s", prev, curr, name);
@@ -249,7 +246,7 @@ write_ps_int(const char *name, int prev,
}
static void
-write_ps_enum(const char *name, const char *prev, const char *curr)
+debug_ps_enum_member(const char *name, const char *prev, const char *curr)
{
if (!state.ps_first && strcmp(prev, curr) != 0)
debug_println(" %3s -> %3s ps.%s", prev, curr, name);
@@ -316,11 +313,12 @@ debug_ps_di_stack(void)
}
#define debug_ps_bool(name) \
- write_ps_bool(#name, state.prev_ps.name, ps.name)
+ debug_ps_bool_member(#name, state.prev_ps.name, ps.name)
#define debug_ps_int(name) \
- write_ps_int(#name, state.prev_ps.name, ps.name)
+ debug_ps_int_member(#name, state.prev_ps.name, ps.name)
#define debug_ps_enum(name, names) \
- write_ps_enum(#name, (names)[state.prev_ps.name], (names)[ps.name])
+ debug_ps_enum_member(#name, (names)[state.prev_ps.name], \
+ (names)[ps.name])
void
debug_parser_state(void)
diff -r 291d784bcee7 -r 3026dfdea475 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Wed Jun 14 09:31:05 2023 +0000
+++ b/usr.bin/indent/indent.h Wed Jun 14 09:57:02 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.192 2023/06/14 09:31:05 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.193 2023/06/14 09:57:02 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -431,7 +431,7 @@ extern struct output_state {
void debug_printf(const char *, ...) __printflike(1, 2);
void debug_println(const char *, ...) __printflike(1, 2);
void debug_blank_line(void);
-void debug_vis_range(const char *, const char *, size_t, const char *);
+void debug_vis_range(const char *, size_t);
void debug_parser_state(void);
void debug_psyms_stack(const char *);
void debug_print_buf(const char *, const struct buffer *);
@@ -445,7 +445,7 @@ extern const char *const line_kind_name[
#define debug_printf(fmt, ...) debug_noop()
#define debug_println(fmt, ...) debug_noop()
#define debug_blank_line() debug_noop()
-#define debug_vis_range(prefix, s, e, suffix) debug_noop()
+#define debug_vis_range(s, len) debug_noop()
#define debug_parser_state() debug_noop()
#define debug_psyms_stack(situation) debug_noop()
#define debug_print_buf(name, buf) debug_noop()
diff -r 291d784bcee7 -r 3026dfdea475 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Wed Jun 14 09:31:05 2023 +0000
+++ b/usr.bin/indent/io.c Wed Jun 14 09:57:02 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.218 2023/06/14 09:31:05 rillig Exp $ */
+/* $NetBSD: io.c,v 1.219 2023/06/14 09:57:02 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.218 2023/06/14 09:31:05 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.219 2023/06/14 09:57:02 rillig Exp $");
#include <stdio.h>
@@ -131,7 +131,9 @@ write_range(const char *s, size_t len)
{
write_buffered_newlines();
fwrite(s, 1, len, output);
- debug_vis_range("write_range \"", s, len, "\"\n");
+ debug_printf("write_range ");
+ debug_vis_range(s, len);
+ debug_println("");
for (size_t i = 0; i < len; i++)
newlines = s[i] == '\n' ? newlines + 1 : 0;
out_ind = ind_add(out_ind, s, len);
Home |
Main Index |
Thread Index |
Old Index