Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/common lint: extract type_name_of_array from t...



details:   https://anonhg.NetBSD.org/src/rev/8b4433b3242e
branches:  trunk
changeset: 953168:8b4433b3242e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 28 02:37:04 2021 +0000

description:
lint: extract type_name_of_array from type_name

No functional change.

diffstat:

 usr.bin/xlint/common/tyname.c |  35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diffs (67 lines):

diff -r 1d6a8f701f61 -r 8b4433b3242e usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c     Sun Feb 28 02:29:28 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c     Sun Feb 28 02:37:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tyname.c,v 1.32 2021/02/28 02:29:28 rillig Exp $       */
+/*     $NetBSD: tyname.c,v 1.33 2021/02/28 02:37:04 rillig Exp $       */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.32 2021/02/28 02:29:28 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.33 2021/02/28 02:37:04 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -314,6 +314,23 @@
 #endif
 }
 
+static void
+type_name_of_array(buffer *buf, const type_t *tp)
+{
+       buf_add(buf, " of ");
+       buf_add(buf, type_name(tp->t_subt));
+       buf_add(buf, "[");
+#ifdef t_str /* lint1 */
+       if (tp->t_incomplete_array)
+               buf_add(buf, "unknown_size");
+       else
+               buf_add_int(buf, tp->t_dim);
+#else
+       buf_add_int(buf, tp->t_dim);
+#endif
+       buf_add(buf, "]");
+}
+
 const char *
 type_name(const type_t *tp)
 {
@@ -379,23 +396,11 @@
                type_name_of_struct_or_union(&buf, tp);
                break;
        case ARRAY:
-               buf_add(&buf, " of ");
-               buf_add(&buf, type_name(tp->t_subt));
-               buf_add(&buf, "[");
-#ifdef t_str /* lint1 */
-               if (tp->t_incomplete_array)
-                       buf_add(&buf, "unknown_size");
-               else
-                       buf_add_int(&buf, tp->t_dim);
-#else
-               buf_add_int(&buf, tp->t_dim);
-#endif
-               buf_add(&buf, "]");
+               type_name_of_array(&buf, tp);
                break;
        case FUNC:
                type_name_of_function(&buf, tp);
                break;
-
        default:
                LERROR("type_name(%d)", t);
        }



Home | Main Index | Thread Index | Old Index