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: unexport global variables
details: https://anonhg.NetBSD.org/src/rev/61b83b6461eb
branches: trunk
changeset: 1023821:61b83b6461eb
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Sep 26 21:23:31 2021 +0000
description:
indent: unexport global variables
The variable match_state was write-only and was thus removed.
No functional change.
diffstat:
usr.bin/indent/indent.c | 36 ++++++++++++++----------------------
usr.bin/indent/indent_globs.h | 9 +--------
usr.bin/indent/io.c | 5 +++--
usr.bin/indent/lexi.c | 10 +++++-----
4 files changed, 23 insertions(+), 37 deletions(-)
diffs (190 lines):
diff -r 562324457e7e -r 61b83b6461eb usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Sun Sep 26 21:05:48 2021 +0000
+++ b/usr.bin/indent/indent.c Sun Sep 26 21:23:31 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.87 2021/09/26 19:57:23 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.88 2021/09/26 21:23:31 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.87 2021/09/26 19:57:23 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.88 2021/09/26 21:23:31 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -99,7 +99,7 @@
char sc_buf[sc_size];
char *save_com;
-char *sc_end;
+static char *sc_end; /* pointer into save_com buffer */
char *bp_save;
char *be_save;
@@ -113,11 +113,9 @@
bool had_eof;
int line_no;
bool inhibit_formatting;
-int suppress_blanklines;
-int ifdef_level;
-struct parser_state state_stack[5];
-struct parser_state match_state[5];
+static int ifdef_level;
+static struct parser_state state_stack[5];
FILE *input;
FILE *output;
@@ -125,13 +123,10 @@
static void bakcopy(void);
static void indent_declaration(int, bool);
-const char *in_name = "Standard Input"; /* will always point to name of input
- * file */
-const char *out_name = "Standard Output"; /* will always point to name
- * of output file */
-const char *simple_backup_suffix = ".BAK"; /* Suffix to use for backup
- * files */
-char bakfile[MAXPATHLEN] = "";
+static const char *in_name = "Standard Input";
+static const char *out_name = "Standard Output";
+static const char *backup_suffix = ".BAK";
+static char bakfile[MAXPATHLEN] = "";
static void
check_size_code(size_t desired_size)
@@ -404,7 +399,7 @@
const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX");
if (suffix != NULL)
- simple_backup_suffix = suffix;
+ backup_suffix = suffix;
}
static void
@@ -1150,18 +1145,15 @@
}
if (strncmp(lab.s, "#if", 3) == 0) { /* also ifdef, ifndef */
- if ((size_t)ifdef_level < nitems(state_stack)) {
- match_state[ifdef_level].tos = -1;
+ if ((size_t)ifdef_level < nitems(state_stack))
state_stack[ifdef_level++] = ps;
- } else
+ else
diag(1, "#if stack overflow");
} else if (strncmp(lab.s, "#el", 3) == 0) { /* else, elif */
if (ifdef_level <= 0)
diag(1, lab.s[3] == 'i' ? "Unmatched #elif" : "Unmatched #else");
- else {
- match_state[ifdef_level - 1] = ps;
+ else
ps = state_stack[ifdef_level - 1];
- }
} else if (strncmp(lab.s, "#endif", 6) == 0) {
if (ifdef_level <= 0)
diag(1, "Unmatched #endif");
@@ -1418,7 +1410,7 @@
p--;
if (*p == '/')
p++;
- sprintf(bakfile, "%s%s", p, simple_backup_suffix);
+ sprintf(bakfile, "%s%s", p, backup_suffix);
/* copy in_name to backup file */
bakchn = creat(bakfile, 0600);
diff -r 562324457e7e -r 61b83b6461eb usr.bin/indent/indent_globs.h
--- a/usr.bin/indent/indent_globs.h Sun Sep 26 21:05:48 2021 +0000
+++ b/usr.bin/indent/indent_globs.h Sun Sep 26 21:23:31 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_globs.h,v 1.38 2021/09/26 19:57:23 rillig Exp $ */
+/* $NetBSD: indent_globs.h,v 1.39 2021/09/26 21:23:31 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -70,7 +70,6 @@
extern char sc_buf[sc_size]; /* input text is saved here when looking for
* the brace after an if, while, etc */
extern char *save_com; /* start of the comment stored in sc_buf */
-extern char *sc_end; /* pointer into save_com buffer */
extern char *bp_save; /* saved value of buf_ptr when taking input
* from save_com */
@@ -184,8 +183,6 @@
extern bool had_eof; /* whether input is exhausted */
extern int line_no; /* the current line number. */
extern bool inhibit_formatting; /* true if INDENT OFF is in effect */
-extern int suppress_blanklines;/* set iff following blanklines should
- * be suppressed */
#define STACKSIZE 256
@@ -268,7 +265,3 @@
int comment_lines;
} stats;
} ps;
-
-extern int ifdef_level;
-extern struct parser_state state_stack[5];
-extern struct parser_state match_state[5];
diff -r 562324457e7e -r 61b83b6461eb usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Sun Sep 26 21:05:48 2021 +0000
+++ b/usr.bin/indent/io.c Sun Sep 26 21:23:31 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.67 2021/09/26 19:37:11 rillig Exp $ */
+/* $NetBSD: io.c,v 1.68 2021/09/26 21:23:31 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.67 2021/09/26 19:37:11 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.68 2021/09/26 21:23:31 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -57,6 +57,7 @@
static bool comment_open;
static int paren_indent;
+static int suppress_blanklines;
static void
output_char(char ch)
diff -r 562324457e7e -r 61b83b6461eb usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sun Sep 26 21:05:48 2021 +0000
+++ b/usr.bin/indent/lexi.c Sun Sep 26 21:23:31 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.60 2021/09/26 21:05:48 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.61 2021/09/26 21:23:31 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.60 2021/09/26 21:05:48 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.61 2021/09/26 21:23:31 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -108,9 +108,9 @@
{"while", rw_for_or_if_or_while}
};
-const char **typenames;
-int typename_count;
-int typename_top = -1;
+static const char **typenames;
+static int typename_count;
+static int typename_top = -1;
/*
* The transition table below was rewritten by hand from lx's output, given
Home |
Main Index |
Thread Index |
Old Index