Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: remove global variable option_source
details: https://anonhg.NetBSD.org/src/rev/f8184bc3cf92
branches: trunk
changeset: 988616:f8184bc3cf92
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Oct 07 19:42:41 2021 +0000
description:
indent: remove global variable option_source
It is only needed at startup, while parsing the options. The string "?"
was not needed at all.
No functional change.
diffstat:
usr.bin/indent/args.c | 18 +++++++-----------
usr.bin/indent/indent.c | 6 +++---
usr.bin/indent/indent.h | 4 ++--
3 files changed, 12 insertions(+), 16 deletions(-)
diffs (131 lines):
diff -r abc772d759f7 -r f8184bc3cf92 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c Thu Oct 07 19:35:50 2021 +0000
+++ b/usr.bin/indent/args.c Thu Oct 07 19:42:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.48 2021/10/07 18:32:09 rillig Exp $ */
+/* $NetBSD: args.c,v 1.49 2021/10/07 19:42:41 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.48 2021/10/07 18:32:09 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.49 2021/10/07 19:42:41 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -66,8 +66,6 @@
void add_typedefs_from_file(const char *);
-static const char *option_source = "?";
-
#if __STDC_VERSION__ >= 201112L
#define assert_type(expr, type) _Generic((expr), type : (expr))
#else
@@ -149,7 +147,6 @@
err(EXIT_FAILURE, "profile %s", fname);
return;
}
- option_source = fname;
for (;;) {
char buf[BUFSIZ];
@@ -166,7 +163,7 @@
break;
} else if (n >= nitems(buf) - 5) {
diag(1, "buffer overflow in %s, starting with '%.10s'",
- option_source, buf);
+ fname, buf);
exit(1);
} else
buf[n++] = (char)ch;
@@ -176,7 +173,7 @@
buf[n] = '\0';
if (opt.verbose)
printf("profile: %s\n", buf);
- set_option(buf);
+ set_option(buf, fname);
} else if (ch == EOF)
break;
}
@@ -195,7 +192,6 @@
load_profile(fname, false);
}
load_profile(".indent.pro", false);
- option_source = "Command line";
}
static const char *
@@ -211,7 +207,7 @@
}
static bool
-set_special_option(const char *arg)
+set_special_option(const char *arg, const char *option_source)
{
const char *arg_end;
@@ -265,13 +261,13 @@
}
void
-set_option(const char *arg)
+set_option(const char *arg, const char *option_source)
{
const struct pro *p;
const char *param_start;
arg++; /* skip leading '-' */
- if (set_special_option(arg))
+ if (set_special_option(arg, option_source))
return;
for (p = pro + nitems(pro); p-- != pro;) {
diff -r abc772d759f7 -r f8184bc3cf92 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Thu Oct 07 19:35:50 2021 +0000
+++ b/usr.bin/indent/indent.c Thu Oct 07 19:42:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.113 2021/10/07 19:35:50 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.114 2021/10/07 19:42:41 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.113 2021/10/07 19:35:50 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.114 2021/10/07 19:42:41 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -476,7 +476,7 @@
for (i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
- set_option(argv[i]);
+ set_option(argv[i], "Command line");
} else if (input == NULL) {
in_name = argv[i];
diff -r abc772d759f7 -r f8184bc3cf92 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Thu Oct 07 19:35:50 2021 +0000
+++ b/usr.bin/indent/indent.h Thu Oct 07 19:42:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.29 2021/10/05 06:09:42 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.30 2021/10/07 19:42:41 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -65,7 +65,7 @@
void fill_buffer(void);
void parse(token_type);
void process_comment(void);
-void set_option(const char *);
+void set_option(const char *, const char *);
void load_profiles(const char *);
void *xmalloc(size_t);
Home |
Main Index |
Thread Index |
Old Index