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: rename functions



details:   https://anonhg.NetBSD.org/src/rev/d7abd7345833
branches:  trunk
changeset: 988208:d7abd7345833
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 03 18:44:51 2021 +0000

description:
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.

diffstat:

 usr.bin/indent/args.c   |  55 ++++++++++++++++++++++--------------------------
 usr.bin/indent/indent.c |   6 ++--
 usr.bin/indent/indent.h |   4 +-
 3 files changed, 30 insertions(+), 35 deletions(-)

diffs (136 lines):

diff -r fccd65876560 -r d7abd7345833 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c     Sun Oct 03 18:41:36 2021 +0000
+++ b/usr.bin/indent/args.c     Sun Oct 03 18:44:51 2021 +0000
@@ -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 @@
 
 #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 @@
 
 #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 @@
     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 @@
     }
 }
 
+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)
 {
diff -r fccd65876560 -r d7abd7345833 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sun Oct 03 18:41:36 2021 +0000
+++ b/usr.bin/indent/indent.c   Sun Oct 03 18:44:51 2021 +0000
@@ -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 @@
 
 #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 @@
        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] == '-') {
diff -r fccd65876560 -r d7abd7345833 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Sun Oct 03 18:41:36 2021 +0000
+++ b/usr.bin/indent/indent.h   Sun Oct 03 18:44:51 2021 +0000
@@ -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           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);



Home | Main Index | Thread Index | Old Index