Module Name: src Committed By: rillig Date: Thu Oct 7 19:42:42 UTC 2021
Modified Files: src/usr.bin/indent: args.c indent.c indent.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/usr.bin/indent/args.c cvs rdiff -u -r1.113 -r1.114 src/usr.bin/indent/indent.c cvs rdiff -u -r1.29 -r1.30 src/usr.bin/indent/indent.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/indent/args.c diff -u src/usr.bin/indent/args.c:1.48 src/usr.bin/indent/args.c:1.49 --- src/usr.bin/indent/args.c:1.48 Thu Oct 7 18:32:09 2021 +++ src/usr.bin/indent/args.c Thu Oct 7 19:42:41 2021 @@ -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 @@ static char sccsid[] = "@(#)args.c 8.1 ( #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 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/ 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 @@ load_profile(const char *fname, bool mus err(EXIT_FAILURE, "profile %s", fname); return; } - option_source = fname; for (;;) { char buf[BUFSIZ]; @@ -166,7 +163,7 @@ load_profile(const char *fname, bool mus 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 @@ load_profile(const char *fname, bool mus 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_profiles(const char *profile_name) load_profile(fname, false); } load_profile(".indent.pro", false); - option_source = "Command line"; } static const char * @@ -211,7 +207,7 @@ skip_over(const char *s, bool may_negate } 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 @@ need_param: } 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;) { Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.113 src/usr.bin/indent/indent.c:1.114 --- src/usr.bin/indent/indent.c:1.113 Thu Oct 7 19:35:50 2021 +++ src/usr.bin/indent/indent.c Thu Oct 7 19:42:41 2021 @@ -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 @@ static char sccsid[] = "@(#)indent.c 5.1 #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 @@ main_parse_command_line(int argc, char * 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]; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.29 src/usr.bin/indent/indent.h:1.30 --- src/usr.bin/indent/indent.h:1.29 Tue Oct 5 06:09:42 2021 +++ src/usr.bin/indent/indent.h Thu Oct 7 19:42:41 2021 @@ -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 dump_line(void); 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);