Module Name:    src
Committed By:   rillig
Date:           Sun Dec  3 21:40:44 UTC 2023

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

Log Message:
indent: group input-related variables into a struct

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.389 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.233 -r1.234 src/usr.bin/indent/io.c

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/indent.c
diff -u src/usr.bin/indent/indent.c:1.388 src/usr.bin/indent/indent.c:1.389
--- src/usr.bin/indent/indent.c:1.388	Sun Dec  3 21:03:58 2023
+++ src/usr.bin/indent/indent.c	Sun Dec  3 21:40:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.388 2023/12/03 21:03:58 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.389 2023/12/03 21:40:44 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.388 2023/12/03 21:03:58 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.389 2023/12/03 21:40:44 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -87,7 +87,6 @@ static struct {
 	size_t cap;
 } ifdef;
 
-FILE *input;
 FILE *output;
 
 static const char *in_name = "Standard Input";

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.205 src/usr.bin/indent/indent.h:1.206
--- src/usr.bin/indent/indent.h:1.205	Sun Dec  3 21:03:58 2023
+++ src/usr.bin/indent/indent.h	Sun Dec  3 21:40:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.205 2023/12/03 21:03:58 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.206 2023/12/03 21:40:44 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -146,18 +146,28 @@ struct buffer {
 	size_t cap;
 };
 
-extern FILE *input;
-extern FILE *output;
-
 /*
- * The current line from the input file, used by the lexer to generate tokens.
- * To read from the line, start at inp_p and continue up to and including the
+ * The current input file, used by the lexer to generate tokens.
+ * To read from the input, start at p and continue up to and including the
  * next '\n'. To read beyond the '\n', call inp_skip or inp_next, which will
  * make the next line available, invalidating any pointers into the previous
  * line.
  */
-extern struct buffer inp;
-extern const char *inp_p;
+extern struct input_state {
+	FILE *f;
+	struct buffer line;
+	const char *p;
+	int token_start_line;
+	int token_end_line;
+} in;
+
+#define input in.f
+#define inp in.line
+#define inp_p in.p
+#define token_start_line_no in.token_start_line
+#define token_end_line_no in.token_end_line
+
+extern FILE *output;
 
 extern struct buffer token;	/* the current token to be processed, is
 				 * typically copied to the buffer 'code', or in
@@ -249,8 +259,6 @@ extern struct options {
 
 extern bool found_err;
 extern bool had_eof;		/* whether input is exhausted */
-extern int token_start_line_no;
-extern int token_end_line_no;
 extern enum indent_enabled {
 	indent_on,
 	indent_off,

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.233 src/usr.bin/indent/io.c:1.234
--- src/usr.bin/indent/io.c:1.233	Sun Dec  3 21:03:58 2023
+++ src/usr.bin/indent/io.c	Sun Dec  3 21:40:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.233 2023/12/03 21:03:58 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.234 2023/12/03 21:40:44 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,16 +38,15 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.233 2023/12/03 21:03:58 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.234 2023/12/03 21:40:44 rillig Exp $");
 
 #include <stdio.h>
 
 #include "indent.h"
 
-struct buffer inp;
-const char *inp_p;
-int token_start_line_no;
-int token_end_line_no = 1;
+struct input_state in = {
+	.token_end_line = 1,
+};
 
 struct output_state out;
 enum indent_enabled indent_enabled;

Reply via email to