Module Name:    src
Committed By:   rillig
Date:           Fri Feb  2 16:25:59 UTC 2024

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_254.c
        src/usr.bin/xlint/common: externs.h tyname.c
        src/usr.bin/xlint/lint1: debug.c

Log Message:
lint: fix debug output for strings, reduce code size

The debug output contained too many newlines.

The buffer functions were built into lint2 even though they weren't
used.

Enable the query for invisible characters in string literals, to make
sure that a newline in a string literal does not trigger that query.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_254.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/xlint/common/externs.h
cvs rdiff -u -r1.60 -r1.61 src/usr.bin/xlint/common/tyname.c
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/xlint/lint1/debug.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/xlint/lint1/msg_254.c
diff -u src/tests/usr.bin/xlint/lint1/msg_254.c:1.4 src/tests/usr.bin/xlint/lint1/msg_254.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_254.c:1.4	Fri Jun 17 18:54:53 2022
+++ src/tests/usr.bin/xlint/lint1/msg_254.c	Fri Feb  2 16:25:58 2024
@@ -1,9 +1,9 @@
-/*	$NetBSD: msg_254.c,v 1.4 2022/06/17 18:54:53 rillig Exp $	*/
+/*	$NetBSD: msg_254.c,v 1.5 2024/02/02 16:25:58 rillig Exp $	*/
 # 3 "msg_254.c"
 
 /* Test for message: newline in string or char constant [254] */
 
-/* lint1-flags: -tw */
+/* lint1-flags: -tw -q17 */
 
 /*
  * The sequence backslash-newline is a GCC extension.

Index: src/usr.bin/xlint/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.35 src/usr.bin/xlint/common/externs.h:1.36
--- src/usr.bin/xlint/common/externs.h:1.35	Thu Feb  1 21:19:13 2024
+++ src/usr.bin/xlint/common/externs.h	Fri Feb  2 16:25:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.35 2024/02/01 21:19:13 rillig Exp $	*/
+/*	$NetBSD: externs.h,v 1.36 2024/02/02 16:25:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,6 +37,8 @@
 #if IS_LINT1 || IS_LINT2
 const char *type_name(const type_t *);
 const char *tspec_name(tspec_t);
+#endif
+#if IS_LINT1
 void buf_init(buffer *);
 void buf_add_char(buffer *, char);
 #endif

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.60 src/usr.bin/xlint/common/tyname.c:1.61
--- src/usr.bin/xlint/common/tyname.c:1.60	Thu Feb  1 21:19:13 2024
+++ src/usr.bin/xlint/common/tyname.c	Fri Feb  2 16:25:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.60 2024/02/01 21:19:13 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.61 2024/02/02 16:25:58 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tyname.c,v 1.60 2024/02/01 21:19:13 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.61 2024/02/02 16:25:58 rillig Exp $");
 #endif
 
 #include <assert.h>
@@ -94,7 +94,11 @@ intern(const char *name)
 	return n->ntn_name;
 }
 
+#if IS_LINT1
 void
+#else
+static void
+#endif
 buf_init(buffer *buf)
 {
 	buf->len = 0;
@@ -122,11 +126,13 @@ buf_add_mem(buffer *buf, const char *s, 
 	buf->data[buf->len] = '\0';
 }
 
+#if IS_LINT1
 void
 buf_add_char(buffer *buf, char c)
 {
 	buf_add_mem(buf, &c, 1);
 }
+#endif
 
 static void
 buf_add(buffer *buf, const char *s)

Index: src/usr.bin/xlint/lint1/debug.c
diff -u src/usr.bin/xlint/lint1/debug.c:1.68 src/usr.bin/xlint/lint1/debug.c:1.69
--- src/usr.bin/xlint/lint1/debug.c:1.68	Thu Feb  1 18:37:06 2024
+++ src/usr.bin/xlint/lint1/debug.c	Fri Feb  2 16:25:58 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.68 2024/02/01 18:37:06 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.69 2024/02/02 16:25:58 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.68 2024/02/01 18:37:06 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.69 2024/02/02 16:25:58 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -235,10 +235,11 @@ debug_node(const tnode_t *tn) // NOLINT(
 		debug_printf("\n");
 		break;
 	case STRING:
-		debug_printf(", length %zu\n", tn->tn_string->len);
+		debug_printf(", length %zu", tn->tn_string->len);
 		if (tn->tn_string->data != NULL)
 			// TODO: May contain \0 or control characters.
-			debug_printf(", \"%s\"\n", tn->tn_string->data);
+			debug_printf(", \"%s\"", tn->tn_string->data);
+		debug_printf("\n");
 		break;
 	default:
 		debug_printf("\n");

Reply via email to