Module Name: src Committed By: rillig Date: Sun Sep 26 21:23:31 UTC 2021
Modified Files: src/usr.bin/indent: indent.c indent_globs.h io.c lexi.c Log Message: indent: unexport global variables The variable match_state was write-only and was thus removed. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/usr.bin/indent/indent.c cvs rdiff -u -r1.38 -r1.39 src/usr.bin/indent/indent_globs.h cvs rdiff -u -r1.67 -r1.68 src/usr.bin/indent/io.c cvs rdiff -u -r1.60 -r1.61 src/usr.bin/indent/lexi.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.87 src/usr.bin/indent/indent.c:1.88 --- src/usr.bin/indent/indent.c:1.87 Sun Sep 26 19:57:23 2021 +++ src/usr.bin/indent/indent.c Sun Sep 26 21:23:31 2021 @@ -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 @@ static char sccsid[] = "@(#)indent.c 5.1 #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 *buf_end; 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 @@ float case_ind; 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 @@ FILE *output; 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 @@ main_init_globals(void) const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX"); if (suffix != NULL) - simple_backup_suffix = suffix; + backup_suffix = suffix; } static void @@ -1150,18 +1145,15 @@ process_preprocessing(void) } 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 @@ bakcopy(void) 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); Index: src/usr.bin/indent/indent_globs.h diff -u src/usr.bin/indent/indent_globs.h:1.38 src/usr.bin/indent/indent_globs.h:1.39 --- src/usr.bin/indent/indent_globs.h:1.38 Sun Sep 26 19:57:23 2021 +++ src/usr.bin/indent/indent_globs.h Sun Sep 26 21:23:31 2021 @@ -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 *buf_end; /* ptr to f 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 float case_ind; /* indentat 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 @@ extern struct parser_state { int comment_lines; } stats; } ps; - -extern int ifdef_level; -extern struct parser_state state_stack[5]; -extern struct parser_state match_state[5]; Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.67 src/usr.bin/indent/io.c:1.68 --- src/usr.bin/indent/io.c:1.67 Sun Sep 26 19:37:11 2021 +++ src/usr.bin/indent/io.c Sun Sep 26 21:23:31 2021 @@ -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 @@ static char sccsid[] = "@(#)io.c 8.1 (Be #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 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/ static bool comment_open; static int paren_indent; +static int suppress_blanklines; static void output_char(char ch) Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.60 src/usr.bin/indent/lexi.c:1.61 --- src/usr.bin/indent/lexi.c:1.60 Sun Sep 26 21:05:48 2021 +++ src/usr.bin/indent/lexi.c Sun Sep 26 21:23:31 2021 @@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 ( #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 @@ static const struct special { {"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