Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/xlint lint: uniformly pass command line flags ...
details: https://anonhg.NetBSD.org/src/rev/a32f814f26f1
branches: trunk
changeset: 1023016:a32f814f26f1
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Aug 19 15:55:23 2021 +0000
description:
lint: uniformly pass command line flags to subprocesses
No functional change.
diffstat:
usr.bin/xlint/xlint/xlint.c | 72 ++++++++++++++++++++++++++++----------------
1 files changed, 46 insertions(+), 26 deletions(-)
diffs (187 lines):
diff -r 5f9ce00c8a4b -r a32f814f26f1 usr.bin/xlint/xlint/xlint.c
--- a/usr.bin/xlint/xlint/xlint.c Thu Aug 19 15:50:30 2021 +0000
+++ b/usr.bin/xlint/xlint/xlint.c Thu Aug 19 15:55:23 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.72 2021/08/09 21:27:20 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.73 2021/08/19 15:55:23 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: xlint.c,v 1.72 2021/08/09 21:27:20 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.73 2021/08/19 15:55:23 rillig Exp $");
#endif
#include <sys/param.h>
@@ -203,6 +203,17 @@
}
static void
+pass_flag_to_lint1(int flag)
+{
+ char buf[3];
+
+ buf[0] = '-';
+ buf[1] = (char)flag;
+ buf[2] = '\0';
+ pass_to_lint1(buf);
+}
+
+static void
pass_to_lint2(const char *opt)
{
@@ -210,6 +221,17 @@
}
static void
+pass_flag_to_lint2(int flag)
+{
+ char buf[3];
+
+ buf[0] = '-';
+ buf[1] = (char)flag;
+ buf[2] = '\0';
+ pass_to_lint2(buf);
+}
+
+static void
pass_to_cpp(const char *opt)
{
@@ -308,7 +330,7 @@
main(int argc, char *argv[])
{
int c;
- char flgbuf[3], *tmp;
+ char *tmp;
size_t len;
const char *ks;
@@ -372,12 +394,11 @@
case 'v':
case 'w':
case 'z':
- (void)sprintf(flgbuf, "-%c", c);
- pass_to_lint1(flgbuf);
+ pass_flag_to_lint1(c);
break;
case 'A':
- pass_to_lint1("-A");
+ pass_flag_to_lint1(c);
pass_to_lint1(optarg);
break;
@@ -386,14 +407,12 @@
/* FALLTHROUGH */
case 'u':
case 'h':
- (void)sprintf(flgbuf, "-%c", c);
- pass_to_lint1(flgbuf);
- pass_to_lint2(flgbuf);
+ pass_flag_to_lint1(c);
+ pass_flag_to_lint2(c);
break;
case 'X':
- (void)sprintf(flgbuf, "-%c", c);
- pass_to_lint1(flgbuf);
+ pass_flag_to_lint1(c);
pass_to_lint1(optarg);
break;
@@ -408,8 +427,8 @@
break;
case 'p':
- pass_to_lint1("-p");
- pass_to_lint2("-p");
+ pass_flag_to_lint1(c);
+ pass_flag_to_lint2(c);
if (*deflibs != NULL) {
list_clear(&deflibs);
list_add_copy(&deflibs, "c");
@@ -417,11 +436,12 @@
break;
case 'P':
- pass_to_lint1("-P");
+ pass_flag_to_lint1(c);
break;
case 'R':
- pass_to_lint1(concat2("-R", optarg));
+ pass_flag_to_lint1(c);
+ pass_to_lint1(optarg);
break;
case 's':
@@ -432,23 +452,22 @@
list_add_copy(&cpp.lcflags, "-Wtrigraphs");
list_add_copy(&cpp.lcflags, "-pedantic");
list_add_copy(&cpp.lcflags, "-D__STRICT_ANSI__");
- pass_to_lint1("-s");
- pass_to_lint2("-s");
+ pass_flag_to_lint1(c);
+ pass_flag_to_lint2(c);
sflag = true;
break;
case 'S':
if (tflag)
usage();
- pass_to_lint1("-S");
+ pass_flag_to_lint1(c);
Sflag = true;
break;
case 'T':
- (void)sprintf(flgbuf, "-%c", c);
pass_to_cpp("-I" PATH_STRICT_BOOL_INCLUDE);
- pass_to_lint1(flgbuf);
- pass_to_lint2(flgbuf);
+ pass_flag_to_lint1(c);
+ pass_flag_to_lint2(c);
break;
#if !HAVE_NBTOOL_CONFIG_H
@@ -460,21 +479,22 @@
list_add_copy(&cpp.lcflags, "-Wtraditional");
list_add_copy(&cpp.lcflags, "-D" MACHINE);
list_add_copy(&cpp.lcflags, "-D" MACHINE_ARCH);
- pass_to_lint1("-t");
- pass_to_lint2("-t");
+ pass_flag_to_lint1(c);
+ pass_flag_to_lint2(c);
tflag = true;
break;
#endif
case 'x':
- pass_to_lint2("-x");
+ pass_flag_to_lint2(c);
break;
case 'C':
if (Cflag || oflag || iflag)
usage();
Cflag = true;
- list_add(&lint2.flags, concat2("-C", optarg));
+ pass_flag_to_lint2(c);
+ pass_to_lint2(optarg);
lint2.outlib = xasprintf("llib-l%s.ln", optarg);
list_clear(&deflibs);
break;
@@ -511,7 +531,7 @@
break;
case 'H':
- pass_to_lint2("-H");
+ pass_flag_to_lint2(c);
break;
case 'B':
Home |
Main Index |
Thread Index |
Old Index