Module Name:    src
Committed By:   rillig
Date:           Thu May 18 06:01:39 UTC 2023

Modified Files:
        src/usr.bin/indent: args.c indent.c indent.h

Log Message:
indent: rename a few functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/indent/args.c
cvs rdiff -u -r1.293 -r1.294 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.148 -r1.149 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.79 src/usr.bin/indent/args.c:1.80
--- src/usr.bin/indent/args.c:1.79	Thu May 18 05:33:27 2023
+++ src/usr.bin/indent/args.c	Thu May 18 06:01:39 2023
@@ -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);
 		}

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.293 src/usr.bin/indent/indent.c:1.294
--- src/usr.bin/indent/indent.c:1.293	Thu May 18 05:33:27 2023
+++ src/usr.bin/indent/indent.c	Thu May 18 06:01:39 2023
@@ -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();
-}
-
-void *
-nonnull(void *p)
-{
-	if (p == NULL)
-		err(EXIT_FAILURE, NULL);
-	return p;
+	init_globals();
+	load_profiles(argc, argv);
+	parse_command_line(argc, argv);
+	set_initial_indentation();
+	return indent();
 }

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.148 src/usr.bin/indent/indent.h:1.149
--- src/usr.bin/indent/indent.h:1.148	Thu May 18 04:23:03 2023
+++ src/usr.bin/indent/indent.h	Thu May 18 06:01:39 2023
@@ -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 *);
 

Reply via email to