Module Name: src Committed By: rillig Date: Sun Oct 3 18:44:51 UTC 2021
Modified Files: src/usr.bin/indent: args.c indent.c indent.h Log Message: indent: rename functions There was no good reason for using the different verbs 'scan' and 'set' for two functions that essentially do the same. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/args.c cvs rdiff -u -r1.97 -r1.98 src/usr.bin/indent/indent.c cvs rdiff -u -r1.26 -r1.27 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.40 src/usr.bin/indent/args.c:1.41 --- src/usr.bin/indent/args.c:1.40 Sun Oct 3 18:41:36 2021 +++ src/usr.bin/indent/args.c Sun Oct 3 18:44:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: args.c,v 1.40 2021/10/03 18:41:36 rillig Exp $ */ +/* $NetBSD: args.c,v 1.41 2021/10/03 18:44:51 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.40 2021/10/03 18:41:36 rillig Exp $"); +__RCSID("$NetBSD: args.c,v 1.41 2021/10/03 18:44:51 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $"); #endif @@ -64,7 +64,6 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/ #define INDENT_VERSION "2.0" -static void scan_profile(FILE *); void add_typedefs_from_file(const char *); static const char *option_source = "?"; @@ -140,34 +139,8 @@ static const struct pro { bool_options("v", verbose), }; -/* - * set_profile reads $HOME/.indent.pro and ./.indent.pro and handles arguments - * given in these files. - */ -void -set_profile(const char *profile_name) -{ - FILE *f; - char fname[PATH_MAX]; - static char prof[] = ".indent.pro"; - - if (profile_name == NULL) - snprintf(fname, sizeof(fname), "%s/%s", getenv("HOME"), prof); - else - snprintf(fname, sizeof(fname), "%s", profile_name); - if ((f = fopen(option_source = fname, "r")) != NULL) { - scan_profile(f); - (void)fclose(f); - } - if ((f = fopen(option_source = prof, "r")) != NULL) { - scan_profile(f); - (void)fclose(f); - } - option_source = "Command line"; -} - static void -scan_profile(FILE *f) +load_profile(FILE *f) { int comment_index, i; char *p; @@ -200,6 +173,28 @@ scan_profile(FILE *f) } } +void +load_profiles(const char *profile_name) +{ + FILE *f; + char fname[PATH_MAX]; + static char prof[] = ".indent.pro"; + + if (profile_name == NULL) + snprintf(fname, sizeof(fname), "%s/%s", getenv("HOME"), prof); + else + snprintf(fname, sizeof(fname), "%s", profile_name); + if ((f = fopen(option_source = fname, "r")) != NULL) { + load_profile(f); + (void)fclose(f); + } + if ((f = fopen(option_source = prof, "r")) != NULL) { + load_profile(f); + (void)fclose(f); + } + option_source = "Command line"; +} + static const char * skip_over(const char *s, bool may_negate, const char *prefix) { Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.97 src/usr.bin/indent/indent.c:1.98 --- src/usr.bin/indent/indent.c:1.97 Sun Oct 3 18:41:36 2021 +++ src/usr.bin/indent/indent.c Sun Oct 3 18:44:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.97 2021/10/03 18:41:36 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.98 2021/10/03 18:44:51 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.97 2021/10/03 18:41:36 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.98 2021/10/03 18:44:51 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -449,7 +449,7 @@ main_parse_command_line(int argc, char * else if (argv[i][0] == '-' && argv[i][1] == 'P' && argv[i][2] != '\0') profile_name = argv[i] + 2; /* non-empty -P (set profile) */ if (i >= argc) - set_profile(profile_name); + load_profiles(profile_name); for (i = 1; i < argc; ++i) { if (argv[i][0] == '-') { Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.26 src/usr.bin/indent/indent.h:1.27 --- src/usr.bin/indent/indent.h:1.26 Mon Sep 27 18:21:47 2021 +++ src/usr.bin/indent/indent.h Sun Oct 3 18:44:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.26 2021/09/27 18:21:47 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.27 2021/10/03 18:44:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -64,7 +64,7 @@ void fill_buffer(void); void parse(token_type); void process_comment(void); void set_option(const char *); -void set_profile(const char *); +void load_profiles(const char *); void *xmalloc(size_t); void *xrealloc(void *, size_t);