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: trim down the code for writing th...



details:   https://anonhg.NetBSD.org/src/rev/8f3137d3fb8a
branches:  trunk
changeset: 1023360:8f3137d3fb8a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 04 14:42:30 2021 +0000

description:
lint: trim down the code for writing the output files

The output buffer is only needed in a single file, so unexport it.

When calling outname, the chances for the name being null are close to
zero, therefore omit the caller information.

diffstat:

 usr.bin/xlint/common/emit.c    |  28 ++++++++--------------------
 usr.bin/xlint/common/externs.h |   7 ++-----
 2 files changed, 10 insertions(+), 25 deletions(-)

diffs (103 lines):

diff -r 2a050600552f -r 8f3137d3fb8a usr.bin/xlint/common/emit.c
--- a/usr.bin/xlint/common/emit.c       Sat Sep 04 14:31:04 2021 +0000
+++ b/usr.bin/xlint/common/emit.c       Sat Sep 04 14:42:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emit.c,v 1.14 2021/09/04 14:26:32 rillig Exp $ */
+/*     $NetBSD: emit.c,v 1.15 2021/09/04 14:42:30 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit.c,v 1.14 2021/09/04 14:26:32 rillig Exp $");
+__RCSID("$NetBSD: emit.c,v 1.15 2021/09/04 14:42:30 rillig Exp $");
 #endif
 
 #include <stdio.h>
@@ -50,7 +50,7 @@
 static FILE    *lout;
 
 /* output buffer data */
-ob_t   ob;
+static ob_t    ob;
 
 static void    outxbuf(void);
 
@@ -132,9 +132,7 @@
 }
 
 #if defined(IS_LINT1)
-/*
- * write a character to the output buffer, quoted if necessary
- */
+/* write a character to the output buffer, quoted if necessary */
 void
 outqchar(char c)
 {
@@ -200,9 +198,7 @@
        }
 }
 
-/*
- * write an integer value to the output buffer
- */
+/* write an integer value to the output buffer */
 void
 outint(int i)
 {
@@ -212,23 +208,15 @@
        ob.o_next += sprintf(ob.o_next, "%d", i);
 }
 
-/*
- * write the name of a symbol to the output buffer
- * the name is preceded by its length
- */
+/* write a name to the output buffer, preceded by its length */
 void
-outname1(const char *file, size_t line, const char *name)
+outname(const char *name)
 {
-
-       if (name == NULL)
-               errx(1, "%s, %zu: internal error: outname(NULL)", file, line);
        outint((int)strlen(name));
        outstrg(name);
 }
 
-/*
- * write the name of the .c source
- */
+/* write the name of the .c source */
 void
 outsrc(const char *name)
 {
diff -r 2a050600552f -r 8f3137d3fb8a usr.bin/xlint/common/externs.h
--- a/usr.bin/xlint/common/externs.h    Sat Sep 04 14:31:04 2021 +0000
+++ b/usr.bin/xlint/common/externs.h    Sat Sep 04 14:42:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs.h,v 1.22 2021/09/04 14:26:32 rillig Exp $      */
+/*     $NetBSD: externs.h,v 1.23 2021/09/04 14:42:30 rillig Exp $      */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -56,8 +56,6 @@
  * emit.c
  */
 #if defined(IS_LINT1) || defined(IS_LINT2)
-extern ob_t    ob;
-
 extern void    outopen(const char *);
 extern void    outclose(void);
 extern void    outclr(void);
@@ -65,7 +63,6 @@
 extern void    outqchar(char);
 extern void    outstrg(const char *);
 extern void    outint(int);
-#define outname(a)     outname1(__FILE__, __LINE__, a);
-extern void    outname1(const char *, size_t, const char *);
+extern void    outname(const char *);
 extern void    outsrc(const char *);
 #endif



Home | Main Index | Thread Index | Old Index