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: run indent on indent.h
details: https://anonhg.NetBSD.org/src/rev/00711f369020
branches: trunk
changeset: 1024044:00711f369020
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Oct 08 19:03:34 2021 +0000
description:
indent: run indent on indent.h
The formatting looks mostly OK.
Some struct members had excessively long names, leaving no space for
their corresponding comments. Renamed some of them using well-known
abbreviations.
The formatting for debug_vis_range is messed up, no idea why. It is
clearly a function declaration, not a function definition, so there is
no need to place the function name in column 1.
No functional change.
diffstat:
usr.bin/indent/args.c | 12 +-
usr.bin/indent/indent.c | 9 +-
usr.bin/indent/indent.h | 337 +++++++++++++++++++++----------------------
usr.bin/indent/io.c | 6 +-
usr.bin/indent/pr_comment.c | 6 +-
5 files changed, 183 insertions(+), 187 deletions(-)
diffs (truncated from 547 to 300 lines):
diff -r b94884f14b34 -r 00711f369020 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c Fri Oct 08 18:29:36 2021 +0000
+++ b/usr.bin/indent/args.c Fri Oct 08 19:03:34 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.51 2021/10/07 22:56:49 rillig Exp $ */
+/* $NetBSD: args.c,v 1.52 2021/10/08 19:03:34 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.51 2021/10/07 22:56:49 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.52 2021/10/08 19:03:34 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -89,10 +89,10 @@
void *p_var; /* the associated variable */
} pro[] = {
bool_options("bacc", blanklines_around_conditional_compilation),
- bool_options("bad", blanklines_after_declarations),
- bool_options("badp", blanklines_after_declarations_at_proctop),
+ bool_options("bad", blanklines_after_decl),
+ bool_options("badp", blanklines_after_decl_at_top),
bool_options("bap", blanklines_after_procs),
- bool_options("bbb", blanklines_before_blockcomments),
+ bool_options("bbb", blanklines_before_block_comments),
bool_options("bc", break_after_comma),
bool_option("bl", false, brace_same_line),
bool_option("br", true, brace_same_line),
@@ -107,7 +107,7 @@
int_option("d", unindent_displace),
int_option("di", decl_indent),
bool_options("dj", ljust_decl),
- bool_options("eei", extra_expression_indent),
+ bool_options("eei", extra_expr_indent),
bool_options("ei", else_if),
bool_options("fbs", function_brace_split),
bool_options("fc1", format_col1_comments),
diff -r b94884f14b34 -r 00711f369020 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Fri Oct 08 18:29:36 2021 +0000
+++ b/usr.bin/indent/indent.c Fri Oct 08 19:03:34 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.127 2021/10/08 16:47:42 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.128 2021/10/08 19:03:34 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.127 2021/10/08 16:47:42 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.128 2021/10/08 19:03:34 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -657,7 +657,7 @@
debug_println("paren_indent[%d] is now %d",
ps.p_l_follow - 1, ps.paren_indents[ps.p_l_follow - 1]);
- if (sp_sw && ps.p_l_follow == 1 && opt.extra_expression_indent
+ if (sp_sw && ps.p_l_follow == 1 && opt.extra_expr_indent
&& ps.paren_indents[0] < 2 * opt.indent_size) {
ps.paren_indents[0] = (short)(2 * opt.indent_size);
debug_println("paren_indent[0] is now %d", ps.paren_indents[0]);
@@ -904,8 +904,7 @@
ps.decl_on_line = false; /* we can't be in the middle of a
* declaration, so don't do special
* indentation of comments */
- if (opt.blanklines_after_declarations_at_proctop
- && ps.in_parameter_declaration)
+ if (opt.blanklines_after_decl_at_top && ps.in_parameter_declaration)
postfix_blankline_requested = true;
ps.in_parameter_declaration = false;
ps.in_decl = false;
diff -r b94884f14b34 -r 00711f369020 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Fri Oct 08 18:29:36 2021 +0000
+++ b/usr.bin/indent/indent.h Fri Oct 08 19:03:34 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.33 2021/10/08 17:19:49 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.34 2021/10/08 19:03:34 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -123,103 +123,100 @@
char *l; /* limit */
};
-extern FILE *input; /* the fid for the input file */
-extern FILE *output; /* the output file */
+extern FILE *input;
+extern FILE *output;
-extern struct buffer lab; /* label or preprocessor directive */
-extern struct buffer code; /* code */
-extern struct buffer com; /* comment */
-extern struct buffer token; /* the last token scanned */
+extern struct buffer lab; /* label or preprocessor directive */
+extern struct buffer code; /* code */
+extern struct buffer com; /* comment */
+extern struct buffer token; /* the last token scanned */
extern struct buffer inp;
-extern char sc_buf[sc_size]; /* input text is saved here when looking for
+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 *save_com; /* start of the comment stored in sc_buf */
-extern char *saved_inp_s; /* saved value of inp.s when taking input
- * from save_com */
-extern char *saved_inp_e; /* similarly saved value of inp.e */
+extern char *saved_inp_s; /* saved value of inp.s when taking input from
+ * save_com */
+extern char *saved_inp_e; /* similarly saved value of inp.e */
extern struct options {
- bool blanklines_around_conditional_compilation;
- bool blanklines_after_declarations_at_proctop; /* this is vaguely
- * similar to blanklines_after_declarations
- * except that it only applies to the first
- * set of declarations in a procedure (just
- * after the first '{') and it causes a blank
- * line to be generated even if there are no
- * declarations */
- bool blanklines_after_declarations;
- bool blanklines_after_procs;
- bool blanklines_before_blockcomments;
- bool break_after_comma; /* whether to break declarations after
- * commas */
- bool brace_same_line;/* whether brace should be on same line
- * as if, while, etc */
- bool blank_after_sizeof; /* whether a blank should always be
- * inserted after sizeof */
- bool comment_delimiter_on_blankline;
- int decl_comment_column; /* the column in which comments after
+ bool blanklines_around_conditional_compilation;
+ bool blanklines_after_decl_at_top; /* this is vaguely similar to
+ * blanklines_after_decl except that
+ * it only applies to the first set of
+ * declarations in a procedure (just
+ * after the first '{') and it causes
+ * a blank line to be generated even
+ * if there are no declarations */
+ bool blanklines_after_decl;
+ bool blanklines_after_procs;
+ bool blanklines_before_block_comments;
+ bool break_after_comma; /* whether to break declarations after commas */
+ bool brace_same_line; /* whether brace should be on same line as if,
+ * while, etc */
+ bool blank_after_sizeof; /* whether a blank should always be inserted
+ * after sizeof */
+ bool comment_delimiter_on_blankline;
+ int decl_comment_column; /* the column in which comments after
* declarations should be put */
- bool cuddle_else; /* whether 'else' should cuddle up to '}' */
- int continuation_indent; /* the indentation between the
- * edge of code and continuation lines */
- float case_indent; /* The distance (measured in indentation
+ bool cuddle_else; /* whether 'else' should cuddle up to '}' */
+ int continuation_indent; /* the indentation between the edge of code
+ * and continuation lines */
+ float case_indent; /* The distance (measured in indentation
* levels) to indent case labels from the
* switch statement */
- int comment_column; /* the column in which comments to the right
+ int comment_column; /* the column in which comments to the right
* of code should start */
- int decl_indent; /* indentation of identifier in declaration */
- bool ljust_decl; /* true if declarations should be left
+ int decl_indent; /* indentation of identifier in declaration */
+ bool ljust_decl; /* true if declarations should be left
* justified */
- int unindent_displace; /* comments not to the right of code
- * will be placed this many
- * indentation levels to the left of
- * code */
- bool extra_expression_indent; /* whether continuation lines from
- * the expression part of "if(e)",
- * "while(e)", "for(e;e;e)" should be
- * indented an extra tab stop so that they
- * don't conflict with the code that follows */
- bool else_if; /* whether else-if pairs should be handled
+ int unindent_displace; /* comments not to the right of code will be
+ * placed this many indentation levels to the
+ * left of code */
+ bool extra_expr_indent; /* whether continuation lines from the
+ * expression part of "if(e)", "while(e)",
+ * "for(e;e;e)" should be indented an extra
+ * tab stop so that they don't conflict with
+ * the code that follows */
+ bool else_if; /* whether else-if pairs should be handled
* specially */
- bool function_brace_split; /* split function declaration and
- * brace onto separate lines */
- bool format_col1_comments; /* If comments which start in column 1
- * are to be magically reformatted (just
- * like comments that begin in later columns) */
- bool format_block_comments; /* whether comments beginning with
- * '/ * \n' are to be reformatted */
- bool indent_parameters;
- int indent_size; /* the size of one indentation level */
- int block_comment_max_line_length;
- int local_decl_indent; /* like decl_indent but for locals */
- bool lineup_to_parens_always; /* whether to not(?) attempt to keep
- * lined-up code within the margin */
- bool lineup_to_parens; /* whether continued code within parens
- * will be lined up to the open paren */
- bool proc_calls_space; /* whether procedure calls look like:
- * foo (bar) rather than foo(bar) */
- bool procnames_start_line; /* whether the names of procedures
- * being defined get placed in column 1 (i.e.
- * a newline is placed between the type of
- * the procedure and its name) */
- bool space_after_cast; /* "b = (int) a" vs "b = (int)a" */
- bool star_comment_cont; /* whether comment continuation lines
- * should have stars at the beginning of
- * each line. */
- bool swallow_optional_blanklines;
- bool auto_typedefs; /* whether to recognize identifiers
- * ending in "_t" like typedefs */
- int tabsize; /* the size of a tab */
- int max_line_length;
- bool use_tabs; /* set true to use tabs for spacing, false
+ bool function_brace_split; /* split function declaration and brace onto
+ * separate lines */
+ bool format_col1_comments; /* If comments which start in column 1 are to
+ * be magically reformatted (just like
+ * comments that begin in later columns) */
+ bool format_block_comments; /* whether comments beginning with '/ * \n'
+ * are to be reformatted */
+ bool indent_parameters;
+ int indent_size; /* the size of one indentation level */
+ int block_comment_max_line_length;
+ int local_decl_indent; /* like decl_indent but for locals */
+ bool lineup_to_parens_always; /* whether to not(?) attempt to keep
+ * lined-up code within the margin */
+ bool lineup_to_parens; /* whether continued code within parens will
+ * be lined up to the open paren */
+ bool proc_calls_space; /* whether function calls look like: foo (bar)
+ * rather than foo(bar) */
+ bool procnames_start_line; /* whether the names of procedures being
+ * defined get placed in column 1 (i.e. a
+ * newline is placed between the type of the
+ * procedure and its name) */
+ bool space_after_cast; /* "b = (int) a" vs "b = (int)a" */
+ bool star_comment_cont; /* whether comment continuation lines should
+ * have stars at the beginning of each line. */
+ bool swallow_optional_blanklines;
+ bool auto_typedefs; /* whether to recognize identifiers ending in
+ * "_t" like typedefs */
+ int tabsize; /* the size of a tab */
+ int max_line_length;
+ bool use_tabs; /* set true to use tabs for spacing, false
* uses all spaces */
- bool verbose; /* whether non-essential error messages
- * are printed */
-} opt;
+ bool verbose; /* whether non-essential error messages are
+ * printed */
+} opt;
enum keyword_kind {
kw_0,
@@ -238,135 +235,135 @@
};
-extern bool found_err;
-extern int next_blank_lines;
-extern bool prefix_blankline_requested;
-extern bool postfix_blankline_requested;
-extern bool break_comma; /* when true and not in parens, break after a
+extern bool found_err;
+extern int next_blank_lines;
+extern bool prefix_blankline_requested;
+extern bool postfix_blankline_requested;
+extern bool break_comma; /* when true and not in parens, break after a
* comma */
-extern float case_ind; /* indentation level to be used for a "case
+extern float case_ind; /* indentation level to be used for a "case
* n:" */
-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 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 */
#define STACKSIZE 256
extern struct parser_state {
- token_type last_token;
- token_type p_stack[STACKSIZE]; /* this is the parser's stack */
- int il[STACKSIZE]; /* this stack stores indentation levels */
Home |
Main Index |
Thread Index |
Old Index