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 a few functions



details:   https://anonhg.NetBSD.org/src/rev/9a3fde0e7cb8
branches:  trunk
changeset: 375875:9a3fde0e7cb8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu May 18 06:01:39 2023 +0000

description:
indent: rename a few functions

No functional change.

diffstat:

 usr.bin/indent/args.c   |  15 +++++++--------
 usr.bin/indent/indent.c |  43 ++++++++++++++++++++++---------------------
 usr.bin/indent/indent.h |   4 ++--
 3 files changed, 31 insertions(+), 31 deletions(-)

diffs (172 lines):

diff -r 9043cd64385e -r 9a3fde0e7cb8 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c     Thu May 18 05:33:27 2023 +0000
+++ b/usr.bin/indent/args.c     Thu May 18 06:01:39 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: args.c,v 1.79 2023/05/18 05:33:27 rillig Exp $ */
+/*     $NetBSD: args.c,v 1.80 2023/05/18 06:01:39 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: args.c,v 1.79 2023/05/18 05:33:27 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.80 2023/05/18 06:01:39 rillig Exp $");
 
 /* Read options from profile files and from the command line. */
 
@@ -150,7 +150,7 @@ set_special_option(const char *arg, cons
        }
 
        if (arg[0] == 'P' || strcmp(arg, "npro") == 0)
-               return true;    /* see main_load_profiles */
+               return true;    /* see load_profiles */
 
        if (strncmp(arg, "cli", 3) == 0) {
                arg_end = arg + 3;
@@ -299,15 +299,14 @@ load_profile(const char *fname, bool mus
 }
 
 void
-load_profiles(const char *profile_name)
+load_profile_files(const char *path)
 {
-       char fname[PATH_MAX];
-
-       if (profile_name != NULL)
-               load_profile(profile_name, true);
+       if (path != NULL)
+               load_profile(path, true);
        else {
                const char *home = getenv("HOME");
                if (home != NULL) {
+                       char fname[PATH_MAX];
                        snprintf(fname, sizeof(fname), "%s/.indent.pro", home);
                        load_profile(fname, false);
                }
diff -r 9043cd64385e -r 9a3fde0e7cb8 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu May 18 05:33:27 2023 +0000
+++ b/usr.bin/indent/indent.c   Thu May 18 06:01:39 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.293 2023/05/18 05:33:27 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.294 2023/05/18 06:01:39 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.293 2023/05/18 05:33:27 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.294 2023/05/18 06:01:39 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -99,6 +99,14 @@ static const char *backup_suffix = ".BAK
 static char bakfile[MAXPATHLEN] = "";
 
 
+void *
+nonnull(void *p)
+{
+       if (p == NULL)
+               err(EXIT_FAILURE, NULL);
+       return p;
+}
+
 static void
 buf_expand(struct buffer *buf, size_t add_size)
 {
@@ -169,7 +177,7 @@ ind_add(int ind, const char *s, size_t l
 }
 
 static void
-main_init_globals(void)
+init_globals(void)
 {
        ps.s_sym[0] = psym_stmt_list;
        ps.prev_token = lsym_semicolon;
@@ -222,7 +230,7 @@ bakcopy(void)
 }
 
 static void
-main_load_profiles(int argc, char **argv)
+load_profiles(int argc, char **argv)
 {
        const char *profile_name = NULL;
 
@@ -234,11 +242,12 @@ main_load_profiles(int argc, char **argv
                if (arg[0] == '-' && arg[1] == 'P' && arg[2] != '\0')
                        profile_name = arg + 2;
        }
-       load_profiles(profile_name);
+
+       load_profile_files(profile_name);
 }
 
 static void
-main_parse_command_line(int argc, char **argv)
+parse_command_line(int argc, char **argv)
 {
        for (int i = 1; i < argc; ++i) {
                const char *arg = argv[i];
@@ -287,7 +296,7 @@ main_parse_command_line(int argc, char *
 }
 
 static void
-main_prepare_parsing(void)
+set_initial_indentation(void)
 {
        inp_read_line();
 
@@ -1008,7 +1017,7 @@ process_preprocessing(void)
 }
 
 static int
-main_loop(void)
+indent(void)
 {
 
        ps.di_stack[ps.decl_level = 0] = 0;
@@ -1166,17 +1175,9 @@ main_loop(void)
 int
 main(int argc, char **argv)
 {
-       main_init_globals();
-       main_load_profiles(argc, argv);
-       main_parse_command_line(argc, argv);
-       main_prepare_parsing();
-       return main_loop();
+       init_globals();
+       load_profiles(argc, argv);
+       parse_command_line(argc, argv);
+       set_initial_indentation();
+       return indent();
 }
-
-void *
-nonnull(void *p)
-{
-       if (p == NULL)
-               err(EXIT_FAILURE, NULL);
-       return p;
-}
diff -r 9043cd64385e -r 9a3fde0e7cb8 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Thu May 18 05:33:27 2023 +0000
+++ b/usr.bin/indent/indent.h   Thu May 18 06:01:39 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.148 2023/05/18 04:23:03 rillig Exp $      */
+/*     $NetBSD: indent.h,v 1.149 2023/05/18 06:01:39 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -435,7 +435,7 @@ void inp_read_line(void);
 void parse(parser_symbol);
 void process_comment(void);
 void set_option(const char *, const char *);
-void load_profiles(const char *);
+void load_profile_files(const char *);
 
 void *nonnull(void *);
 



Home | Main Index | Thread Index | Old Index