Module Name:    src
Committed By:   rillig
Date:           Thu Jul 15 17:03:50 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: emit1.c externs1.h tree.c

Log Message:
lint: replace call to ttos with type_name

Since tyname.c 1.20 from 2021-01-02, type_name is as simple to use as
ttos and more expressive.  It can also be called multiple times without
invalidating the returned strings.

Used only in debug mode.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/lint1/emit1.c
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.314 -r1.315 src/usr.bin/xlint/lint1/tree.c

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/xlint/lint1/emit1.c
diff -u src/usr.bin/xlint/lint1/emit1.c:1.45 src/usr.bin/xlint/lint1/emit1.c:1.46
--- src/usr.bin/xlint/lint1/emit1.c:1.45	Mon Jul  5 19:39:12 2021
+++ src/usr.bin/xlint/lint1/emit1.c	Thu Jul 15 17:03:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.45 2021/07/05 19:39:12 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.46 2021/07/15 17:03:50 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit1.c,v 1.45 2021/07/05 19:39:12 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.46 2021/07/15 17:03:50 rillig Exp $");
 #endif
 
 #include "lint1.h"
@@ -158,35 +158,6 @@ outtype(const type_t *tp)
 }
 
 /*
- * type to string
- * used for debugging output
- *
- * it uses its own output buffer for conversion
- */
-const char *
-ttos(const type_t *tp)
-{
-	static	ob_t	tob;
-	ob_t	tmp;
-
-	if (tob.o_buf == NULL) {
-		tob.o_len = 64;
-		tob.o_buf = tob.o_next = xmalloc(tob.o_len);
-		tob.o_end = tob.o_buf + tob.o_len;
-	}
-
-	tmp = ob;
-	ob = tob;
-	ob.o_next = ob.o_buf;
-	outtype(tp);
-	outchar('\0');
-	tob = ob;
-	ob = tmp;
-
-	return tob.o_buf;
-}
-
-/*
  * write the name of a tag or typename
  *
  * if the tag is named, the name of the tag is written,

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.117 src/usr.bin/xlint/lint1/externs1.h:1.118
--- src/usr.bin/xlint/lint1/externs1.h:1.117	Wed Jul 14 17:07:24 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Thu Jul 15 17:03:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.117 2021/07/14 17:07:24 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.118 2021/07/15 17:03:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -314,7 +314,6 @@ extern	void	add_designator_subscript(ran
  * emit.c
  */
 extern	void	outtype(const type_t *);
-extern	const	char *ttos(const type_t *);
 extern	void	outsym(const sym_t *, scl_t, def_t);
 extern	void	outfdef(const sym_t *, const pos_t *, bool, bool,
 		    const sym_t *);

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.314 src/usr.bin/xlint/lint1/tree.c:1.315
--- src/usr.bin/xlint/lint1/tree.c:1.314	Wed Jul 14 17:07:24 2021
+++ src/usr.bin/xlint/lint1/tree.c	Thu Jul 15 17:03:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.314 2021/07/14 17:07:24 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.315 2021/07/15 17:03:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.314 2021/07/14 17:07:24 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.315 2021/07/15 17:03:50 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3815,7 +3815,7 @@ display_expression(const tnode_t *tn, in
 		(void)printf("o=%d, l=%d ", tn->tn_type->t_foffs,
 			     tn->tn_type->t_flen);
 	}
-	(void)printf("%s\n", ttos(tn->tn_type));
+	(void)printf("%s\n", type_name(tn->tn_type));
 	if (tn->tn_op == NAME || tn->tn_op == CON || tn->tn_op == STRING)
 		return;
 	display_expression(tn->tn_left, offs + 2);

Reply via email to