indent(1): group global option variables into an options structure
It's clearer now when a variable represents a toggable command line option. Many options were stored in the parser's state structure, so fix also that.
This commit is contained in:
parent
957e7993d4
commit
8f52e72108
@ -102,72 +102,72 @@ struct pro {
|
||||
{"U", PRO_SPECIAL, 0, KEY_FILE, 0},
|
||||
{"-version", PRO_SPECIAL, 0, VERSION, 0},
|
||||
{"P", PRO_SPECIAL, 0, IGN, 0},
|
||||
{"bacc", PRO_BOOL, false, ON, &blanklines_around_conditional_compilation},
|
||||
{"badp", PRO_BOOL, false, ON, &blanklines_after_declarations_at_proctop},
|
||||
{"bad", PRO_BOOL, false, ON, &blanklines_after_declarations},
|
||||
{"bap", PRO_BOOL, false, ON, &blanklines_after_procs},
|
||||
{"bbb", PRO_BOOL, false, ON, &blanklines_before_blockcomments},
|
||||
{"bc", PRO_BOOL, true, OFF, &ps.leave_comma},
|
||||
{"bl", PRO_BOOL, true, OFF, &btype_2},
|
||||
{"br", PRO_BOOL, true, ON, &btype_2},
|
||||
{"bs", PRO_BOOL, false, ON, &Bill_Shannon},
|
||||
{"cdb", PRO_BOOL, true, ON, &comment_delimiter_on_blankline},
|
||||
{"cd", PRO_INT, 0, 0, &ps.decl_com_ind},
|
||||
{"ce", PRO_BOOL, true, ON, &cuddle_else},
|
||||
{"ci", PRO_INT, 0, 0, &continuation_indent},
|
||||
{"bacc", PRO_BOOL, false, ON, &opt.blanklines_around_conditional_compilation},
|
||||
{"badp", PRO_BOOL, false, ON, &opt.blanklines_after_declarations_at_proctop},
|
||||
{"bad", PRO_BOOL, false, ON, &opt.blanklines_after_declarations},
|
||||
{"bap", PRO_BOOL, false, ON, &opt.blanklines_after_procs},
|
||||
{"bbb", PRO_BOOL, false, ON, &opt.blanklines_before_blockcomments},
|
||||
{"bc", PRO_BOOL, true, OFF, &opt.leave_comma},
|
||||
{"bl", PRO_BOOL, true, OFF, &opt.btype_2},
|
||||
{"br", PRO_BOOL, true, ON, &opt.btype_2},
|
||||
{"bs", PRO_BOOL, false, ON, &opt.Bill_Shannon},
|
||||
{"cdb", PRO_BOOL, true, ON, &opt.comment_delimiter_on_blankline},
|
||||
{"cd", PRO_INT, 0, 0, &opt.decl_com_ind},
|
||||
{"ce", PRO_BOOL, true, ON, &opt.cuddle_else},
|
||||
{"ci", PRO_INT, 0, 0, &opt.continuation_indent},
|
||||
{"cli", PRO_SPECIAL, 0, CLI, 0},
|
||||
{"c", PRO_INT, 33, 0, &ps.com_ind},
|
||||
{"di", PRO_INT, 16, 0, &ps.decl_indent},
|
||||
{"dj", PRO_BOOL, false, ON, &ps.ljust_decl},
|
||||
{"d", PRO_INT, 0, 0, &ps.unindent_displace},
|
||||
{"eei", PRO_BOOL, false, ON, &extra_expression_indent},
|
||||
{"ei", PRO_BOOL, true, ON, &ps.else_if},
|
||||
{"fbs", PRO_BOOL, true, ON, &function_brace_split},
|
||||
{"fc1", PRO_BOOL, true, ON, &format_col1_comments},
|
||||
{"fcb", PRO_BOOL, true, ON, &format_block_comments},
|
||||
{"ip", PRO_BOOL, true, ON, &ps.indent_parameters},
|
||||
{"i", PRO_INT, 8, 0, &ps.ind_size},
|
||||
{"lc", PRO_INT, 0, 0, &block_comment_max_col},
|
||||
{"ldi", PRO_INT, -1, 0, &ps.local_decl_indent},
|
||||
{"lpl", PRO_BOOL, false, ON, &lineup_to_parens_always},
|
||||
{"lp", PRO_BOOL, true, ON, &lineup_to_parens},
|
||||
{"l", PRO_INT, 78, 0, &max_col},
|
||||
{"nbacc", PRO_BOOL, false, OFF, &blanklines_around_conditional_compilation},
|
||||
{"nbadp", PRO_BOOL, false, OFF, &blanklines_after_declarations_at_proctop},
|
||||
{"nbad", PRO_BOOL, false, OFF, &blanklines_after_declarations},
|
||||
{"nbap", PRO_BOOL, false, OFF, &blanklines_after_procs},
|
||||
{"nbbb", PRO_BOOL, false, OFF, &blanklines_before_blockcomments},
|
||||
{"nbc", PRO_BOOL, true, ON, &ps.leave_comma},
|
||||
{"nbs", PRO_BOOL, false, OFF, &Bill_Shannon},
|
||||
{"ncdb", PRO_BOOL, true, OFF, &comment_delimiter_on_blankline},
|
||||
{"nce", PRO_BOOL, true, OFF, &cuddle_else},
|
||||
{"ndj", PRO_BOOL, false, OFF, &ps.ljust_decl},
|
||||
{"neei", PRO_BOOL, false, OFF, &extra_expression_indent},
|
||||
{"nei", PRO_BOOL, true, OFF, &ps.else_if},
|
||||
{"nfbs", PRO_BOOL, true, OFF, &function_brace_split},
|
||||
{"nfc1", PRO_BOOL, true, OFF, &format_col1_comments},
|
||||
{"nfcb", PRO_BOOL, true, OFF, &format_block_comments},
|
||||
{"nip", PRO_BOOL, true, OFF, &ps.indent_parameters},
|
||||
{"nlpl", PRO_BOOL, false, OFF, &lineup_to_parens_always},
|
||||
{"nlp", PRO_BOOL, true, OFF, &lineup_to_parens},
|
||||
{"npcs", PRO_BOOL, false, OFF, &proc_calls_space},
|
||||
{"c", PRO_INT, 33, 0, &opt.com_ind},
|
||||
{"di", PRO_INT, 16, 0, &opt.decl_indent},
|
||||
{"dj", PRO_BOOL, false, ON, &opt.ljust_decl},
|
||||
{"d", PRO_INT, 0, 0, &opt.unindent_displace},
|
||||
{"eei", PRO_BOOL, false, ON, &opt.extra_expression_indent},
|
||||
{"ei", PRO_BOOL, true, ON, &opt.else_if},
|
||||
{"fbs", PRO_BOOL, true, ON, &opt.function_brace_split},
|
||||
{"fc1", PRO_BOOL, true, ON, &opt.format_col1_comments},
|
||||
{"fcb", PRO_BOOL, true, ON, &opt.format_block_comments},
|
||||
{"ip", PRO_BOOL, true, ON, &opt.indent_parameters},
|
||||
{"i", PRO_INT, 8, 0, &opt.ind_size},
|
||||
{"lc", PRO_INT, 0, 0, &opt.block_comment_max_col},
|
||||
{"ldi", PRO_INT, -1, 0, &opt.local_decl_indent},
|
||||
{"lpl", PRO_BOOL, false, ON, &opt.lineup_to_parens_always},
|
||||
{"lp", PRO_BOOL, true, ON, &opt.lineup_to_parens},
|
||||
{"l", PRO_INT, 78, 0, &opt.max_col},
|
||||
{"nbacc", PRO_BOOL, false, OFF, &opt.blanklines_around_conditional_compilation},
|
||||
{"nbadp", PRO_BOOL, false, OFF, &opt.blanklines_after_declarations_at_proctop},
|
||||
{"nbad", PRO_BOOL, false, OFF, &opt.blanklines_after_declarations},
|
||||
{"nbap", PRO_BOOL, false, OFF, &opt.blanklines_after_procs},
|
||||
{"nbbb", PRO_BOOL, false, OFF, &opt.blanklines_before_blockcomments},
|
||||
{"nbc", PRO_BOOL, true, ON, &opt.leave_comma},
|
||||
{"nbs", PRO_BOOL, false, OFF, &opt.Bill_Shannon},
|
||||
{"ncdb", PRO_BOOL, true, OFF, &opt.comment_delimiter_on_blankline},
|
||||
{"nce", PRO_BOOL, true, OFF, &opt.cuddle_else},
|
||||
{"ndj", PRO_BOOL, false, OFF, &opt.ljust_decl},
|
||||
{"neei", PRO_BOOL, false, OFF, &opt.extra_expression_indent},
|
||||
{"nei", PRO_BOOL, true, OFF, &opt.else_if},
|
||||
{"nfbs", PRO_BOOL, true, OFF, &opt.function_brace_split},
|
||||
{"nfc1", PRO_BOOL, true, OFF, &opt.format_col1_comments},
|
||||
{"nfcb", PRO_BOOL, true, OFF, &opt.format_block_comments},
|
||||
{"nip", PRO_BOOL, true, OFF, &opt.indent_parameters},
|
||||
{"nlpl", PRO_BOOL, false, OFF, &opt.lineup_to_parens_always},
|
||||
{"nlp", PRO_BOOL, true, OFF, &opt.lineup_to_parens},
|
||||
{"npcs", PRO_BOOL, false, OFF, &opt.proc_calls_space},
|
||||
{"npro", PRO_SPECIAL, 0, IGN, 0},
|
||||
{"npsl", PRO_BOOL, true, OFF, &procnames_start_line},
|
||||
{"nsac", PRO_BOOL, false, OFF, &space_after_cast},
|
||||
{"nsc", PRO_BOOL, true, OFF, &star_comment_cont},
|
||||
{"nsob", PRO_BOOL, false, OFF, &swallow_optional_blanklines},
|
||||
{"nut", PRO_BOOL, true, OFF, &use_tabs},
|
||||
{"nv", PRO_BOOL, false, OFF, &verbose},
|
||||
{"pcs", PRO_BOOL, false, ON, &proc_calls_space},
|
||||
{"psl", PRO_BOOL, true, ON, &procnames_start_line},
|
||||
{"sac", PRO_BOOL, false, ON, &space_after_cast},
|
||||
{"sc", PRO_BOOL, true, ON, &star_comment_cont},
|
||||
{"sob", PRO_BOOL, false, ON, &swallow_optional_blanklines},
|
||||
{"npsl", PRO_BOOL, true, OFF, &opt.procnames_start_line},
|
||||
{"nsac", PRO_BOOL, false, OFF, &opt.space_after_cast},
|
||||
{"nsc", PRO_BOOL, true, OFF, &opt.star_comment_cont},
|
||||
{"nsob", PRO_BOOL, false, OFF, &opt.swallow_optional_blanklines},
|
||||
{"nut", PRO_BOOL, true, OFF, &opt.use_tabs},
|
||||
{"nv", PRO_BOOL, false, OFF, &opt.verbose},
|
||||
{"pcs", PRO_BOOL, false, ON, &opt.proc_calls_space},
|
||||
{"psl", PRO_BOOL, true, ON, &opt.procnames_start_line},
|
||||
{"sac", PRO_BOOL, false, ON, &opt.space_after_cast},
|
||||
{"sc", PRO_BOOL, true, ON, &opt.star_comment_cont},
|
||||
{"sob", PRO_BOOL, false, ON, &opt.swallow_optional_blanklines},
|
||||
{"st", PRO_SPECIAL, 0, STDIN, 0},
|
||||
{"ta", PRO_BOOL, false, ON, &auto_typedefs},
|
||||
{"ts", PRO_INT, 8, 0, &tabsize},
|
||||
{"ut", PRO_BOOL, true, ON, &use_tabs},
|
||||
{"v", PRO_BOOL, false, ON, &verbose},
|
||||
{"ta", PRO_BOOL, false, ON, &opt.auto_typedefs},
|
||||
{"ts", PRO_INT, 8, 0, &opt.tabsize},
|
||||
{"ut", PRO_BOOL, true, ON, &opt.use_tabs},
|
||||
{"v", PRO_BOOL, false, ON, &opt.verbose},
|
||||
/* whew! */
|
||||
{0, 0, 0, 0, 0}
|
||||
};
|
||||
@ -224,7 +224,7 @@ scan_profile(FILE *f)
|
||||
}
|
||||
if (p != buf) {
|
||||
*p++ = 0;
|
||||
if (verbose)
|
||||
if (opt.verbose)
|
||||
printf("profile: %s\n", buf);
|
||||
set_option(buf);
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ main(int argc, char **argv)
|
||||
combuf[0] = codebuf[0] = labbuf[0] = ' '; /* set up code, label, and
|
||||
* comment buffers */
|
||||
combuf[1] = codebuf[1] = labbuf[1] = '\0';
|
||||
ps.else_if = 1; /* Default else-if special processing to on */
|
||||
opt.else_if = 1; /* Default else-if special processing to on */
|
||||
s_lab = e_lab = labbuf + 1;
|
||||
s_code = e_code = codebuf + 1;
|
||||
s_com = e_com = combuf + 1;
|
||||
@ -251,16 +251,16 @@ main(int argc, char **argv)
|
||||
if (cap_enter() < 0 && errno != ENOSYS)
|
||||
err(EXIT_FAILURE, "unable to enter capability mode");
|
||||
|
||||
if (ps.com_ind <= 1)
|
||||
ps.com_ind = 2; /* dont put normal comments before column 2 */
|
||||
if (block_comment_max_col <= 0)
|
||||
block_comment_max_col = max_col;
|
||||
if (ps.local_decl_indent < 0) /* if not specified by user, set this */
|
||||
ps.local_decl_indent = ps.decl_indent;
|
||||
if (ps.decl_com_ind <= 0) /* if not specified by user, set this */
|
||||
ps.decl_com_ind = ps.ljust_decl ? (ps.com_ind <= 10 ? 2 : ps.com_ind - 8) : ps.com_ind;
|
||||
if (continuation_indent == 0)
|
||||
continuation_indent = ps.ind_size;
|
||||
if (opt.com_ind <= 1)
|
||||
opt.com_ind = 2; /* don't put normal comments before column 2 */
|
||||
if (opt.block_comment_max_col <= 0)
|
||||
opt.block_comment_max_col = opt.max_col;
|
||||
if (opt.local_decl_indent < 0) /* if not specified by user, set this */
|
||||
opt.local_decl_indent = opt.decl_indent;
|
||||
if (opt.decl_com_ind <= 0) /* if not specified by user, set this */
|
||||
opt.decl_com_ind = opt.ljust_decl ? (opt.com_ind <= 10 ? 2 : opt.com_ind - 8) : opt.com_ind;
|
||||
if (opt.continuation_indent == 0)
|
||||
opt.continuation_indent = opt.ind_size;
|
||||
fill_buffer(); /* get first batch of stuff into input buffer */
|
||||
|
||||
parse(semicolon);
|
||||
@ -272,13 +272,13 @@ main(int argc, char **argv)
|
||||
if (*p == ' ')
|
||||
col++;
|
||||
else if (*p == '\t')
|
||||
col = tabsize * (1 + (col - 1) / tabsize) + 1;
|
||||
col = opt.tabsize * (1 + (col - 1) / opt.tabsize) + 1;
|
||||
else
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
if (col > ps.ind_size)
|
||||
ps.ind_level = ps.i_l_follow = col / ps.ind_size;
|
||||
if (col > opt.ind_size)
|
||||
ps.ind_level = ps.i_l_follow = col / opt.ind_size;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -359,7 +359,7 @@ main(int argc, char **argv)
|
||||
* jump out of this loop in order to avoid copying the token
|
||||
* again under the default case of the switch below.
|
||||
*/
|
||||
if (sc_end != NULL && btype_2) {
|
||||
if (sc_end != NULL && opt.btype_2) {
|
||||
save_com[0] = '{';
|
||||
/*
|
||||
* Originally the lbrace may have been alone on its own
|
||||
@ -386,7 +386,7 @@ main(int argc, char **argv)
|
||||
e_code != s_code && e_code[-1] == '}')
|
||||
/* "else if" */
|
||||
|| (type_code == sp_paren && *token == 'i' &&
|
||||
last_else && ps.else_if);
|
||||
last_else && opt.else_if);
|
||||
if (remove_newlines)
|
||||
force_nl = false;
|
||||
if (sc_end == NULL) { /* ignore buffering if
|
||||
@ -397,7 +397,7 @@ main(int argc, char **argv)
|
||||
while (sc_end > save_com && isblank((unsigned char)sc_end[-1])) {
|
||||
sc_end--;
|
||||
}
|
||||
if (swallow_optional_blanklines ||
|
||||
if (opt.swallow_optional_blanklines ||
|
||||
(!comment_buffered && remove_newlines)) {
|
||||
force_nl = !remove_newlines;
|
||||
while (sc_end > save_com && sc_end[-1] == '\n') {
|
||||
@ -411,7 +411,7 @@ main(int argc, char **argv)
|
||||
* newline is read from the buffer */
|
||||
*sc_end++ = '\n';
|
||||
*sc_end++ = ' ';
|
||||
if (verbose) /* print error msg if the line was
|
||||
if (opt.verbose) /* print error msg if the line was
|
||||
* not already broken */
|
||||
diag2(0, "Line broken");
|
||||
}
|
||||
@ -484,7 +484,7 @@ main(int argc, char **argv)
|
||||
if (ps.tos > 1) /* check for balanced braces */
|
||||
diag2(1, "Stuff missing from end of file");
|
||||
|
||||
if (verbose) {
|
||||
if (opt.verbose) {
|
||||
printf("There were %d output lines and %d comments\n",
|
||||
ps.out_lines, ps.out_coms);
|
||||
printf("(Lines with comments)/(Lines with code): %6.3f\n",
|
||||
@ -500,9 +500,9 @@ main(int argc, char **argv)
|
||||
(type_code != form_feed)) {
|
||||
if (force_nl &&
|
||||
(type_code != semicolon) &&
|
||||
(type_code != lbrace || !btype_2)) {
|
||||
(type_code != lbrace || !opt.btype_2)) {
|
||||
/* we should force a broken line here */
|
||||
if (verbose)
|
||||
if (opt.verbose)
|
||||
diag2(0, "Line broken");
|
||||
dump_line();
|
||||
ps.want_blank = false; /* dont insert blank at line start */
|
||||
@ -548,7 +548,7 @@ main(int argc, char **argv)
|
||||
|
||||
case newline:
|
||||
if (ps.last_token != comma || ps.p_l_follow > 0
|
||||
|| !ps.leave_comma || ps.block_init || !break_comma || s_com != e_com) {
|
||||
|| !opt.leave_comma || ps.block_init || !break_comma || s_com != e_com) {
|
||||
dump_line();
|
||||
ps.want_blank = false;
|
||||
}
|
||||
@ -572,18 +572,18 @@ main(int argc, char **argv)
|
||||
}
|
||||
else if (ps.want_blank &&
|
||||
((ps.last_token != ident && ps.last_token != funcname) ||
|
||||
proc_calls_space ||
|
||||
opt.proc_calls_space ||
|
||||
/* offsetof (1) is never allowed a space; sizeof (2) gets
|
||||
* one iff -bs; all other keywords (>2) always get a space
|
||||
* before lparen */
|
||||
ps.keyword + Bill_Shannon > 2))
|
||||
ps.keyword + opt.Bill_Shannon > 2))
|
||||
*e_code++ = ' ';
|
||||
ps.want_blank = false;
|
||||
*e_code++ = token[0];
|
||||
ps.paren_indents[ps.p_l_follow - 1] = count_spaces_until(1, s_code, e_code) - 1;
|
||||
if (sp_sw && ps.p_l_follow == 1 && extra_expression_indent
|
||||
&& ps.paren_indents[0] < 2 * ps.ind_size)
|
||||
ps.paren_indents[0] = 2 * ps.ind_size;
|
||||
if (sp_sw && ps.p_l_follow == 1 && opt.extra_expression_indent
|
||||
&& ps.paren_indents[0] < 2 * opt.ind_size)
|
||||
ps.paren_indents[0] = 2 * opt.ind_size;
|
||||
if (ps.in_or_st && *token == '(' && ps.tos <= 2) {
|
||||
/*
|
||||
* this is a kluge to make sure that declarations will be
|
||||
@ -603,7 +603,7 @@ main(int argc, char **argv)
|
||||
if (ps.cast_mask & (1 << ps.p_l_follow) & ~ps.not_cast_mask) {
|
||||
ps.last_u_d = true;
|
||||
ps.cast_mask &= (1 << ps.p_l_follow) - 1;
|
||||
ps.want_blank = space_after_cast;
|
||||
ps.want_blank = opt.space_after_cast;
|
||||
} else
|
||||
ps.want_blank = true;
|
||||
ps.not_cast_mask &= (1 << ps.p_l_follow) - 1;
|
||||
@ -627,10 +627,10 @@ main(int argc, char **argv)
|
||||
|
||||
parse(hd_type); /* let parser worry about if, or whatever */
|
||||
}
|
||||
ps.search_brace = btype_2; /* this should insure that constructs
|
||||
* such as main(){...} and int[]{...}
|
||||
* have their braces put in the right
|
||||
* place */
|
||||
ps.search_brace = opt.btype_2; /* this should ensure that
|
||||
* constructs such as main(){...}
|
||||
* and int[]{...} have their braces
|
||||
* put in the right place */
|
||||
break;
|
||||
|
||||
case unary_op: /* this could be any unary operation */
|
||||
@ -793,14 +793,14 @@ main(int argc, char **argv)
|
||||
ps.block_init_level++;
|
||||
|
||||
if (s_code != e_code && !ps.block_init) {
|
||||
if (!btype_2) {
|
||||
if (!opt.btype_2) {
|
||||
dump_line();
|
||||
ps.want_blank = false;
|
||||
}
|
||||
else if (ps.in_parameter_declaration && !ps.in_or_st) {
|
||||
ps.i_l_follow = 0;
|
||||
if (function_brace_split) { /* dump the line prior to the
|
||||
* brace ... */
|
||||
if (opt.function_brace_split) { /* dump the line prior
|
||||
* to the brace ... */
|
||||
dump_line();
|
||||
ps.want_blank = false;
|
||||
} else /* add a space between the decl and brace */
|
||||
@ -838,7 +838,7 @@ main(int argc, char **argv)
|
||||
* a declaration, so don't do
|
||||
* special indentation of
|
||||
* comments */
|
||||
if (blanklines_after_declarations_at_proctop
|
||||
if (opt.blanklines_after_declarations_at_proctop
|
||||
&& ps.in_parameter_declaration)
|
||||
postfix_blankline_requested = 1;
|
||||
ps.in_parameter_declaration = 0;
|
||||
@ -868,7 +868,7 @@ main(int argc, char **argv)
|
||||
ps.block_init_level--;
|
||||
if (s_code != e_code && !ps.block_init) { /* '}' must be first on
|
||||
* line */
|
||||
if (verbose)
|
||||
if (opt.verbose)
|
||||
diag2(0, "Line broken");
|
||||
dump_line();
|
||||
}
|
||||
@ -884,9 +884,9 @@ main(int argc, char **argv)
|
||||
}
|
||||
prefix_blankline_requested = 0;
|
||||
parse(rbrace); /* let parser know about this */
|
||||
ps.search_brace = cuddle_else && ps.p_stack[ps.tos] == ifhead
|
||||
ps.search_brace = opt.cuddle_else && ps.p_stack[ps.tos] == ifhead
|
||||
&& ps.il[ps.tos] >= ps.ind_level;
|
||||
if (ps.tos <= 1 && blanklines_after_procs && ps.dec_nest <= 0)
|
||||
if (ps.tos <= 1 && opt.blanklines_after_procs && ps.dec_nest <= 0)
|
||||
postfix_blankline_requested = 1;
|
||||
break;
|
||||
|
||||
@ -910,8 +910,8 @@ main(int argc, char **argv)
|
||||
case sp_nparen: /* got else, do */
|
||||
ps.in_stmt = false;
|
||||
if (*token == 'e') {
|
||||
if (e_code != s_code && (!cuddle_else || e_code[-1] != '}')) {
|
||||
if (verbose)
|
||||
if (e_code != s_code && (!opt.cuddle_else || e_code[-1] != '}')) {
|
||||
if (opt.verbose)
|
||||
diag2(0, "Line broken");
|
||||
dump_line();/* make sure this starts a line */
|
||||
ps.want_blank = false;
|
||||
@ -922,7 +922,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
else {
|
||||
if (e_code != s_code) { /* make sure this starts a line */
|
||||
if (verbose)
|
||||
if (opt.verbose)
|
||||
diag2(0, "Line broken");
|
||||
dump_line();
|
||||
ps.want_blank = false;
|
||||
@ -949,7 +949,7 @@ main(int argc, char **argv)
|
||||
ps.want_blank = 0;
|
||||
}
|
||||
}
|
||||
if (ps.in_parameter_declaration && ps.indent_parameters && ps.dec_nest == 0) {
|
||||
if (ps.in_parameter_declaration && opt.indent_parameters && ps.dec_nest == 0) {
|
||||
ps.ind_level = ps.i_l_follow = 1;
|
||||
ps.ind_stmt = 0;
|
||||
}
|
||||
@ -963,12 +963,12 @@ main(int argc, char **argv)
|
||||
|
||||
if (ps.ind_level == 0 || ps.dec_nest > 0) {
|
||||
/* global variable or struct member in local variable */
|
||||
dec_ind = ps.decl_indent > 0 ? ps.decl_indent : i;
|
||||
tabs_to_var = (use_tabs ? ps.decl_indent > 0 : 0);
|
||||
dec_ind = opt.decl_indent > 0 ? opt.decl_indent : i;
|
||||
tabs_to_var = (opt.use_tabs ? opt.decl_indent > 0 : 0);
|
||||
} else {
|
||||
/* local variable */
|
||||
dec_ind = ps.local_decl_indent > 0 ? ps.local_decl_indent : i;
|
||||
tabs_to_var = (use_tabs ? ps.local_decl_indent > 0 : 0);
|
||||
dec_ind = opt.local_decl_indent > 0 ? opt.local_decl_indent : i;
|
||||
tabs_to_var = (opt.use_tabs ? opt.local_decl_indent > 0 : 0);
|
||||
}
|
||||
goto copy_id;
|
||||
|
||||
@ -977,7 +977,7 @@ main(int argc, char **argv)
|
||||
if (ps.in_decl) {
|
||||
if (type_code == funcname) {
|
||||
ps.in_decl = false;
|
||||
if (procnames_start_line && s_code != e_code) {
|
||||
if (opt.procnames_start_line && s_code != e_code) {
|
||||
*e_code = '\0';
|
||||
dump_line();
|
||||
}
|
||||
@ -1048,9 +1048,9 @@ main(int argc, char **argv)
|
||||
if (ps.p_l_follow == 0) {
|
||||
if (ps.block_init_level <= 0)
|
||||
ps.block_init = 0;
|
||||
if (break_comma && (!ps.leave_comma ||
|
||||
if (break_comma && (!opt.leave_comma ||
|
||||
count_spaces_until(compute_code_target(), s_code, e_code) >
|
||||
max_col - tabsize))
|
||||
opt.max_col - opt.tabsize))
|
||||
force_nl = true;
|
||||
}
|
||||
break;
|
||||
@ -1190,7 +1190,7 @@ main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (blanklines_around_conditional_compilation) {
|
||||
if (opt.blanklines_around_conditional_compilation) {
|
||||
postfix_blankline_requested++;
|
||||
n_real_blanklines = 0;
|
||||
}
|
||||
@ -1266,15 +1266,15 @@ indent_declaration(int cur_dec_ind, int tabs_to_var)
|
||||
/*
|
||||
* get the tab math right for indentations that are not multiples of tabsize
|
||||
*/
|
||||
if ((ps.ind_level * ps.ind_size) % tabsize != 0) {
|
||||
pos += (ps.ind_level * ps.ind_size) % tabsize;
|
||||
cur_dec_ind += (ps.ind_level * ps.ind_size) % tabsize;
|
||||
if ((ps.ind_level * opt.ind_size) % opt.tabsize != 0) {
|
||||
pos += (ps.ind_level * opt.ind_size) % opt.tabsize;
|
||||
cur_dec_ind += (ps.ind_level * opt.ind_size) % opt.tabsize;
|
||||
}
|
||||
if (tabs_to_var) {
|
||||
int tpos;
|
||||
|
||||
CHECK_SIZE_CODE(cur_dec_ind / tabsize);
|
||||
while ((tpos = tabsize * (1 + pos / tabsize)) <= cur_dec_ind) {
|
||||
CHECK_SIZE_CODE(cur_dec_ind / opt.tabsize);
|
||||
while ((tpos = opt.tabsize * (1 + pos / opt.tabsize)) <= cur_dec_ind) {
|
||||
*e_code++ = '\t';
|
||||
pos = tpos;
|
||||
}
|
||||
|
@ -141,83 +141,96 @@ char *bp_save; /* saved value of buf_ptr when taking input
|
||||
char *be_save; /* similarly saved value of buf_end */
|
||||
|
||||
|
||||
int found_err;
|
||||
int blanklines_after_declarations;
|
||||
int blanklines_before_blockcomments;
|
||||
int blanklines_after_procs;
|
||||
struct options {
|
||||
int blanklines_around_conditional_compilation;
|
||||
int blanklines_after_declarations_at_proctop; /* this is vaguely
|
||||
* similar to blanklines_after_decla except
|
||||
* that in 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 */
|
||||
int blanklines_after_declarations;
|
||||
int blanklines_after_procs;
|
||||
int blanklines_before_blockcomments;
|
||||
int leave_comma; /* if true, never break declarations after
|
||||
* commas */
|
||||
int btype_2; /* when true, brace should be on same line
|
||||
* as if, while, etc */
|
||||
int Bill_Shannon; /* true iff a blank should always be
|
||||
* inserted after sizeof */
|
||||
int comment_delimiter_on_blankline;
|
||||
int decl_com_ind; /* the column in which comments after
|
||||
* declarations should be put */
|
||||
int cuddle_else; /* true if else should cuddle up to '}' */
|
||||
int continuation_indent; /* set to the indentation between the
|
||||
* edge of code and continuation lines */
|
||||
int com_ind; /* the column in which comments to the right
|
||||
* of code should start */
|
||||
int decl_indent; /* column to indent declared identifiers to */
|
||||
int 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 */
|
||||
int extra_expression_indent; /* true if 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 */
|
||||
int else_if; /* True iff else if pairs should be handled
|
||||
* specially */
|
||||
int function_brace_split; /* split function declaration and
|
||||
* brace onto separate lines */
|
||||
int format_col1_comments; /* If comments which start in column 1
|
||||
* are to be magically reformatted (just
|
||||
* like comments that begin in later columns) */
|
||||
int format_block_comments; /* true if comments beginning with
|
||||
* `/ * \n' are to be reformatted */
|
||||
int indent_parameters;
|
||||
int ind_size; /* the size of one indentation level */
|
||||
int block_comment_max_col;
|
||||
int local_decl_indent; /* like decl_indent but for locals */
|
||||
int lineup_to_parens_always; /* if true, do not attempt to keep
|
||||
* lined-up code within the margin */
|
||||
int lineup_to_parens; /* if true, continued code within parens
|
||||
* will be lined up to the open paren */
|
||||
int proc_calls_space; /* If true, procedure calls look like:
|
||||
* foo (bar) rather than foo(bar) */
|
||||
int procnames_start_line; /* if true, the names of procedures
|
||||
* being defined get placed in column 1 (ie.
|
||||
* a newline is placed between the type of
|
||||
* the procedure and its name) */
|
||||
int space_after_cast; /* "b = (int) a" vs "b = (int)a" */
|
||||
int star_comment_cont; /* true iff comment continuation lines
|
||||
* should have stars at the beginning of
|
||||
* each line. */
|
||||
int swallow_optional_blanklines;
|
||||
int auto_typedefs; /* set true to recognize identifiers
|
||||
* ending in "_t" like typedefs */
|
||||
int tabsize; /* the size of a tab */
|
||||
int max_col; /* the maximum allowable line length */
|
||||
int use_tabs; /* set true to use tabs for spacing, false
|
||||
* uses all spaces */
|
||||
int verbose; /* when true, non-essential error messages
|
||||
* are printed */
|
||||
} opt;
|
||||
|
||||
int found_err;
|
||||
int n_real_blanklines;
|
||||
int prefix_blankline_requested;
|
||||
int postfix_blankline_requested;
|
||||
int break_comma; /* when true and not in parens, break after a
|
||||
* comma */
|
||||
int btype_2; /* when true, brace should be on same line as
|
||||
* if, while, etc */
|
||||
float case_ind; /* indentation level to be used for a "case
|
||||
* n:" */
|
||||
int code_lines; /* count of lines with code */
|
||||
int had_eof; /* set to true when input is exhausted */
|
||||
int line_no; /* the current line number. */
|
||||
int max_col; /* the maximum allowable line length */
|
||||
int verbose; /* when true, non-essential error messages are
|
||||
* printed */
|
||||
int cuddle_else; /* true if else should cuddle up to '}' */
|
||||
int star_comment_cont; /* true iff comment continuation lines should
|
||||
* have stars at the beginning of each line. */
|
||||
int comment_delimiter_on_blankline;
|
||||
int procnames_start_line; /* if true, the names of procedures
|
||||
* being defined get placed in column
|
||||
* 1 (ie. a newline is placed between
|
||||
* the type of the procedure and its
|
||||
* name) */
|
||||
int proc_calls_space; /* If true, procedure calls look like:
|
||||
* foo (bar) rather than foo(bar) */
|
||||
int format_block_comments; /* true if comments beginning with
|
||||
* `/ * \n' are to be reformatted */
|
||||
int format_col1_comments; /* If comments which start in column 1
|
||||
* are to be magically reformatted
|
||||
* (just like comments that begin in
|
||||
* later columns) */
|
||||
int inhibit_formatting; /* true if INDENT OFF is in effect */
|
||||
int suppress_blanklines;/* set iff following blanklines should be
|
||||
* suppressed */
|
||||
int continuation_indent;/* set to the indentation between the edge of
|
||||
* code and continuation lines */
|
||||
int lineup_to_parens; /* if true, continued code within parens will
|
||||
* be lined up to the open paren */
|
||||
int lineup_to_parens_always; /* if true, do not attempt to keep
|
||||
* lined-up code within the margin */
|
||||
int Bill_Shannon; /* true iff a blank should always be inserted
|
||||
* after sizeof */
|
||||
int blanklines_after_declarations_at_proctop; /* This is vaguely
|
||||
* similar to
|
||||
* blanklines_after_decla
|
||||
* rations 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 */
|
||||
int block_comment_max_col;
|
||||
int extra_expression_indent; /* true if 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 */
|
||||
int function_brace_split; /* split function declaration and
|
||||
* brace onto separate lines */
|
||||
int use_tabs; /* set true to use tabs for spacing,
|
||||
* false uses all spaces */
|
||||
int auto_typedefs; /* set true to recognize identifiers
|
||||
* ending in "_t" like typedefs */
|
||||
int space_after_cast; /* "b = (int) a" vs "b = (int)a" */
|
||||
int tabsize; /* the size of a tab */
|
||||
|
||||
struct parser_state {
|
||||
int last_token;
|
||||
@ -252,13 +265,9 @@ struct parser_state {
|
||||
* column 1 */
|
||||
int com_col; /* this is the column in which the current
|
||||
* comment should start */
|
||||
int com_ind; /* the column in which comments to the right
|
||||
* of code should start */
|
||||
int com_lines; /* the number of lines with comments, set by
|
||||
* dump_line */
|
||||
int dec_nest; /* current nesting level for structure or init */
|
||||
int decl_com_ind; /* the column in which comments after
|
||||
* declarations should be put */
|
||||
int decl_on_line; /* set to true if this line of code has part
|
||||
* of a declaration on it */
|
||||
int i_l_follow; /* the level to which ind_level should be set
|
||||
@ -268,16 +277,11 @@ struct parser_state {
|
||||
* slightly different */
|
||||
int in_stmt; /* set to 1 while in a stmt */
|
||||
int ind_level; /* the current indentation level */
|
||||
int ind_size; /* the size of one indentation level */
|
||||
int ind_stmt; /* set to 1 if next line should have an extra
|
||||
* indentation level because we are in the
|
||||
* middle of a stmt */
|
||||
int last_u_d; /* set to true after scanning a token which
|
||||
* forces a following operator to be unary */
|
||||
int leave_comma; /* if true, never break declarations after
|
||||
* commas */
|
||||
int ljust_decl; /* true if declarations should be left
|
||||
* justified */
|
||||
int out_coms; /* the number of comments processed, set by
|
||||
* pr_comment */
|
||||
int out_lines; /* the number of lines written, set by
|
||||
@ -293,25 +297,16 @@ struct parser_state {
|
||||
int search_brace; /* set to true by parse when it is necessary
|
||||
* to buffer up all info up to the start of a
|
||||
* stmt after an if, while, etc */
|
||||
int unindent_displace; /* comments not to the right of code
|
||||
* will be placed this many
|
||||
* indentation levels to the left of
|
||||
* code */
|
||||
int use_ff; /* set to one if the current line should be
|
||||
* terminated with a form feed */
|
||||
int want_blank; /* set to true when the following token should
|
||||
* be prefixed by a blank. (Said prefixing is
|
||||
* ignored in some cases.) */
|
||||
int else_if; /* True iff else if pairs should be handled
|
||||
* specially */
|
||||
int decl_indent; /* column to indent declared identifiers to */
|
||||
int local_decl_indent; /* like decl_indent but for locals */
|
||||
int keyword; /* the type of a keyword or 0 */
|
||||
int dumped_decl_indent;
|
||||
float case_indent; /* The distance to indent case labels from the
|
||||
* switch statement */
|
||||
int in_parameter_declaration;
|
||||
int indent_parameters;
|
||||
int tos; /* pointer to top of stack */
|
||||
char procname[100]; /* The name of the current procedure */
|
||||
int just_saw_decl;
|
||||
|
@ -83,7 +83,7 @@ dump_line(void)
|
||||
suppress_blanklines = 0;
|
||||
ps.bl_line = false;
|
||||
if (prefix_blankline_requested && not_first_line) {
|
||||
if (swallow_optional_blanklines) {
|
||||
if (opt.swallow_optional_blanklines) {
|
||||
if (n_real_blanklines == 1)
|
||||
n_real_blanklines = 0;
|
||||
}
|
||||
@ -163,12 +163,14 @@ dump_line(void)
|
||||
target += ps.comment_delta;
|
||||
while (*com_st == '\t') /* consider original indentation in
|
||||
* case this is a box comment */
|
||||
com_st++, target += tabsize;
|
||||
com_st++, target += opt.tabsize;
|
||||
while (target <= 0)
|
||||
if (*com_st == ' ')
|
||||
target++, com_st++;
|
||||
else if (*com_st == '\t')
|
||||
target = tabsize * (1 + (target - 1) / tabsize) + 1, com_st++;
|
||||
else if (*com_st == '\t') {
|
||||
target = opt.tabsize * (1 + (target - 1) / opt.tabsize) + 1;
|
||||
com_st++;
|
||||
}
|
||||
else
|
||||
target = 1;
|
||||
if (cur_col > target) { /* if comment can't fit on this line,
|
||||
@ -189,7 +191,7 @@ dump_line(void)
|
||||
else
|
||||
putc('\n', output);
|
||||
++ps.out_lines;
|
||||
if (ps.just_saw_decl == 1 && blanklines_after_declarations) {
|
||||
if (ps.just_saw_decl == 1 && opt.blanklines_after_declarations) {
|
||||
prefix_blankline_requested = 1;
|
||||
ps.just_saw_decl = 0;
|
||||
}
|
||||
@ -220,20 +222,20 @@ dump_line(void)
|
||||
int
|
||||
compute_code_target(void)
|
||||
{
|
||||
int target_col = ps.ind_size * ps.ind_level + 1;
|
||||
int target_col = opt.ind_size * ps.ind_level + 1;
|
||||
|
||||
if (ps.paren_level)
|
||||
if (!lineup_to_parens)
|
||||
target_col += continuation_indent
|
||||
* (2 * continuation_indent == ps.ind_size ? 1 : ps.paren_level);
|
||||
else if (lineup_to_parens_always)
|
||||
if (!opt.lineup_to_parens)
|
||||
target_col += opt.continuation_indent *
|
||||
(2 * opt.continuation_indent == opt.ind_size ? 1 : ps.paren_level);
|
||||
else if (opt.lineup_to_parens_always)
|
||||
target_col = paren_target;
|
||||
else {
|
||||
int w;
|
||||
int t = paren_target;
|
||||
|
||||
if ((w = count_spaces(t, s_code) - max_col) > 0
|
||||
&& count_spaces(target_col, s_code) <= max_col) {
|
||||
if ((w = count_spaces(t, s_code) - opt.max_col) > 0
|
||||
&& count_spaces(target_col, s_code) <= opt.max_col) {
|
||||
t -= w + 1;
|
||||
if (t > target_col)
|
||||
target_col = t;
|
||||
@ -242,7 +244,7 @@ compute_code_target(void)
|
||||
target_col = t;
|
||||
}
|
||||
else if (ps.ind_stmt)
|
||||
target_col += continuation_indent;
|
||||
target_col += opt.continuation_indent;
|
||||
return target_col;
|
||||
}
|
||||
|
||||
@ -250,9 +252,9 @@ int
|
||||
compute_label_target(void)
|
||||
{
|
||||
return
|
||||
ps.pcase ? (int) (case_ind * ps.ind_size) + 1
|
||||
ps.pcase ? (int) (case_ind * opt.ind_size) + 1
|
||||
: *s_lab == '#' ? 1
|
||||
: ps.ind_size * (ps.ind_level - label_offset) + 1;
|
||||
: opt.ind_size * (ps.ind_level - label_offset) + 1;
|
||||
}
|
||||
|
||||
|
||||
@ -400,10 +402,10 @@ pad_output(int current, int target)
|
||||
if (current >= target)
|
||||
return (current); /* line is already long enough */
|
||||
curr = current;
|
||||
if (use_tabs) {
|
||||
if (opt.use_tabs) {
|
||||
int tcur;
|
||||
|
||||
while ((tcur = tabsize * (1 + (curr - 1) / tabsize) + 1) <= target) {
|
||||
while ((tcur = opt.tabsize * (1 + (curr - 1) / opt.tabsize) + 1) <= target) {
|
||||
putc('\t', output);
|
||||
curr = tcur;
|
||||
}
|
||||
@ -452,7 +454,7 @@ count_spaces_until(int cur, char *buffer, char *end)
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
cur = tabsize * (1 + (cur - 1) / tabsize) + 1;
|
||||
cur = opt.tabsize * (1 + (cur - 1) / opt.tabsize) + 1;
|
||||
break;
|
||||
|
||||
case 010: /* backspace */
|
||||
|
@ -296,7 +296,7 @@ lexi(struct parser_state *state)
|
||||
char *u;
|
||||
|
||||
/* ... so maybe a type_t or a typedef */
|
||||
if ((auto_typedefs && ((u = strrchr(s_token, '_')) != NULL) &&
|
||||
if ((opt.auto_typedefs && ((u = strrchr(s_token, '_')) != NULL) &&
|
||||
strcmp(u, "_t") == 0) || (typename_top >= 0 &&
|
||||
bsearch(s_token, typenames, typename_top + 1,
|
||||
sizeof(typenames[0]), strcmp_type))) {
|
||||
|
@ -75,7 +75,7 @@ parse(int tk) /* tk: the code for the construct scanned */
|
||||
* input */
|
||||
|
||||
case decl: /* scanned a declaration word */
|
||||
ps.search_brace = btype_2;
|
||||
ps.search_brace = opt.btype_2;
|
||||
/* indicate that following brace should be on same line */
|
||||
if (ps.p_stack[ps.tos] != decl) { /* only put one declaration
|
||||
* onto stack */
|
||||
@ -84,7 +84,7 @@ parse(int tk) /* tk: the code for the construct scanned */
|
||||
ps.p_stack[++ps.tos] = decl;
|
||||
ps.il[ps.tos] = ps.i_l_follow;
|
||||
|
||||
if (ps.ljust_decl) {/* only do if we want left justified
|
||||
if (opt.ljust_decl) {/* only do if we want left justified
|
||||
* declarations */
|
||||
ps.ind_level = 0;
|
||||
for (i = ps.tos - 1; i > 0; --i)
|
||||
@ -97,7 +97,7 @@ parse(int tk) /* tk: the code for the construct scanned */
|
||||
break;
|
||||
|
||||
case ifstmt: /* scanned if (...) */
|
||||
if (ps.p_stack[ps.tos] == elsehead && ps.else_if) /* "else if ..." */
|
||||
if (ps.p_stack[ps.tos] == elsehead && opt.else_if) /* "else if ..." */
|
||||
/*
|
||||
* Note that the stack pointer here is decremented, effectively
|
||||
* reducing "else if" to "if". This saves a lot of stack space
|
||||
@ -110,7 +110,7 @@ parse(int tk) /* tk: the code for the construct scanned */
|
||||
ps.p_stack[++ps.tos] = tk;
|
||||
ps.il[ps.tos] = ps.ind_level = ps.i_l_follow;
|
||||
++ps.i_l_follow; /* subsequent statements should be indented 1 */
|
||||
ps.search_brace = btype_2;
|
||||
ps.search_brace = opt.btype_2;
|
||||
break;
|
||||
|
||||
case lbrace: /* scanned { */
|
||||
@ -154,7 +154,7 @@ parse(int tk) /* tk: the code for the construct scanned */
|
||||
ps.p_stack[++ps.tos] = whilestmt;
|
||||
ps.il[ps.tos] = ps.i_l_follow;
|
||||
++ps.i_l_follow;
|
||||
ps.search_brace = btype_2;
|
||||
ps.search_brace = opt.btype_2;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -170,7 +170,7 @@ parse(int tk) /* tk: the code for the construct scanned */
|
||||
* be in 1 level */
|
||||
ps.p_stack[ps.tos] = elsehead;
|
||||
/* remember if with else */
|
||||
ps.search_brace = btype_2 | ps.else_if;
|
||||
ps.search_brace = opt.btype_2 | opt.else_if;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -194,7 +194,7 @@ parse(int tk) /* tk: the code for the construct scanned */
|
||||
* switch */
|
||||
ps.i_l_follow += ps.case_indent + 1; /* statements should be two
|
||||
* levels in */
|
||||
ps.search_brace = btype_2;
|
||||
ps.search_brace = opt.btype_2;
|
||||
break;
|
||||
|
||||
case semicolon: /* this indicates a simple stmt */
|
||||
|
@ -91,9 +91,10 @@ pr_comment(void)
|
||||
char *last_bl; /* points to the last blank in the output
|
||||
* buffer */
|
||||
char *t_ptr; /* used for moving string */
|
||||
int break_delim = comment_delimiter_on_blankline;
|
||||
int break_delim = opt.comment_delimiter_on_blankline;
|
||||
int l_just_saw_decl = ps.just_saw_decl;
|
||||
adj_max_col = max_col;
|
||||
|
||||
adj_max_col = opt.max_col;
|
||||
ps.just_saw_decl = 0;
|
||||
last_bl = NULL; /* no blanks found so far */
|
||||
ps.box_com = false; /* at first, assume that we are not in
|
||||
@ -103,7 +104,7 @@ pr_comment(void)
|
||||
|
||||
/* Figure where to align and how to treat the comment */
|
||||
|
||||
if (ps.col_1 && !format_col1_comments) { /* if comment starts in column
|
||||
if (ps.col_1 && !opt.format_col1_comments) { /* if comment starts in column
|
||||
* 1 it should not be touched */
|
||||
ps.box_com = true;
|
||||
break_delim = false;
|
||||
@ -111,7 +112,7 @@ pr_comment(void)
|
||||
}
|
||||
else {
|
||||
if (*buf_ptr == '-' || *buf_ptr == '*' ||
|
||||
(*buf_ptr == '\n' && !format_block_comments)) {
|
||||
(*buf_ptr == '\n' && !opt.format_block_comments)) {
|
||||
ps.box_com = true; /* A comment with a '-' or '*' immediately
|
||||
* after the /+* is assumed to be a boxed
|
||||
* comment. A comment with a newline
|
||||
@ -127,10 +128,10 @@ pr_comment(void)
|
||||
* If this (*and previous lines are*) blank, dont put comment way
|
||||
* out at left
|
||||
*/
|
||||
ps.com_col = (ps.ind_level - ps.unindent_displace) * ps.ind_size + 1;
|
||||
adj_max_col = block_comment_max_col;
|
||||
ps.com_col = (ps.ind_level - opt.unindent_displace) * opt.ind_size + 1;
|
||||
adj_max_col = opt.block_comment_max_col;
|
||||
if (ps.com_col <= 1)
|
||||
ps.com_col = 1 + !format_col1_comments;
|
||||
ps.com_col = 1 + !opt.format_col1_comments;
|
||||
}
|
||||
else {
|
||||
int target_col;
|
||||
@ -142,9 +143,9 @@ pr_comment(void)
|
||||
if (s_lab != e_lab)
|
||||
target_col = count_spaces(compute_label_target(), s_lab);
|
||||
}
|
||||
ps.com_col = ps.decl_on_line || ps.ind_level == 0 ? ps.decl_com_ind : ps.com_ind;
|
||||
ps.com_col = ps.decl_on_line || ps.ind_level == 0 ? opt.decl_com_ind : opt.com_ind;
|
||||
if (ps.com_col <= target_col)
|
||||
ps.com_col = tabsize * (1 + (target_col - 1) / tabsize) + 1;
|
||||
ps.com_col = opt.tabsize * (1 + (target_col - 1) / opt.tabsize) + 1;
|
||||
if (ps.com_col + 24 > adj_max_col)
|
||||
adj_max_col = ps.com_col + 24;
|
||||
}
|
||||
@ -193,11 +194,11 @@ pr_comment(void)
|
||||
char *t = e_com;
|
||||
e_com = s_com + 2;
|
||||
*e_com = 0;
|
||||
if (blanklines_before_blockcomments && ps.last_token != lbrace)
|
||||
if (opt.blanklines_before_blockcomments && ps.last_token != lbrace)
|
||||
prefix_blankline_requested = 1;
|
||||
dump_line();
|
||||
e_com = s_com = t;
|
||||
if (!ps.box_com && star_comment_cont)
|
||||
if (!ps.box_com && opt.star_comment_cont)
|
||||
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
|
||||
}
|
||||
|
||||
@ -213,7 +214,7 @@ pr_comment(void)
|
||||
/* fix so dump_line uses a form feed */
|
||||
dump_line();
|
||||
last_bl = NULL;
|
||||
if (!ps.box_com && star_comment_cont)
|
||||
if (!ps.box_com && opt.star_comment_cont)
|
||||
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
|
||||
while (*++buf_ptr == ' ' || *buf_ptr == '\t')
|
||||
;
|
||||
@ -239,11 +240,11 @@ pr_comment(void)
|
||||
*e_com++ = ' ';
|
||||
if (!ps.box_com && e_com - s_com > 3) {
|
||||
dump_line();
|
||||
if (star_comment_cont)
|
||||
if (opt.star_comment_cont)
|
||||
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
|
||||
}
|
||||
dump_line();
|
||||
if (!ps.box_com && star_comment_cont)
|
||||
if (!ps.box_com && opt.star_comment_cont)
|
||||
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
|
||||
}
|
||||
else {
|
||||
@ -324,14 +325,14 @@ pr_comment(void)
|
||||
*/
|
||||
if (last_bl == NULL) {
|
||||
dump_line();
|
||||
if (!ps.box_com && star_comment_cont)
|
||||
if (!ps.box_com && opt.star_comment_cont)
|
||||
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
|
||||
break;
|
||||
}
|
||||
*e_com = '\0';
|
||||
e_com = last_bl;
|
||||
dump_line();
|
||||
if (!ps.box_com && star_comment_cont)
|
||||
if (!ps.box_com && opt.star_comment_cont)
|
||||
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
|
||||
for (t_ptr = last_bl + 1; *t_ptr == ' ' || *t_ptr == '\t';
|
||||
t_ptr++)
|
||||
|
Loading…
Reference in New Issue
Block a user