Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: replace call to ttos with type_name



details:   https://anonhg.NetBSD.org/src/rev/e86af9927463
branches:  trunk
changeset: 1022386:e86af9927463
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 15 17:03:50 2021 +0000

description:
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.

diffstat:

 usr.bin/xlint/lint1/emit1.c    |  33 ++-------------------------------
 usr.bin/xlint/lint1/externs1.h |   3 +--
 usr.bin/xlint/lint1/tree.c     |   6 +++---
 3 files changed, 6 insertions(+), 36 deletions(-)

diffs (98 lines):

diff -r e291c0aeeba7 -r e86af9927463 usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c       Thu Jul 15 15:23:46 2021 +0000
+++ b/usr.bin/xlint/lint1/emit1.c       Thu Jul 15 17:03:50 2021 +0000
@@ -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 @@
 }
 
 /*
- * 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,
diff -r e291c0aeeba7 -r e86af9927463 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Thu Jul 15 15:23:46 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Thu Jul 15 17:03:50 2021 +0000
@@ -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 @@
  * 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 *);
diff -r e291c0aeeba7 -r e86af9927463 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Thu Jul 15 15:23:46 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Thu Jul 15 17:03:50 2021 +0000
@@ -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 @@
                (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);



Home | Main Index | Thread Index | Old Index