Definition at line 66 of file indent.c.
86 const char *profile_name = NULL;
133 sp_sw = force_nl =
false;
182 for (
i = 1;
i < argc; ++
i)
183 if (strcmp(argv[
i],
"-npro") == 0)
185 else if (argv[
i][0] ==
'-' && argv[
i][1] ==
'P' && argv[
i][2] !=
'\0')
186 profile_name = argv[
i];
191 for (
i = 1;
i < argc; ++
i) {
196 if (argv[
i][0] !=
'-') {
204 else if (
output == NULL) {
208 errx(1,
"input and output files must be different");
215 errx(1,
"unknown parameter: %s", argv[
i]);
267 int comment_buffered =
false;
313 comment_buffered =
true;
324 diag2(1,
"Internal buffer overflow - Move big comment from right after if, while, or whatever");
347 while (isspace((
unsigned char)*
buf_ptr)) {
378 (!comment_buffered && remove_newlines)) {
379 force_nl = !remove_newlines;
393 diag2(0,
"Line broken");
395 for (t_ptr =
token; *t_ptr; ++t_ptr)
416 if (type_code != 0) {
440 errx(1,
"input too long");
447 transient_state =
ps;
448 type_code =
lexi(&transient_state);
450 type_code !=
comment && !transient_state.search_brace) {
451 ps = transient_state;
457 if (type_code == 0) {
462 diag2(1,
"Stuff missing from end of file");
465 printf(
"There were %d output lines and %d comments\n",
467 printf(
"(Lines with comments)/(Lines with code): %6.3f\n",
483 diag2(0,
"Line broken");
538 diag3(0,
"Reached internal limit of %d unclosed parens",
747 diag2(1,
"Unbalanced parens");
796 diag2(1,
"Unbalanced parens");
811 diag3(0,
"Reached internal limit of %d struct levels",
844 diag2(1,
"Unbalanced parens");
853 diag2(0,
"Line broken");
896 diag2(0,
"Line broken");
907 diag2(0,
"Line broken");
1072 if (*
buf_ptr ==
'*' && !in_comment && !quote) {
1087 if (*
buf_ptr ==
'/' && in_comment) {
1112 errx(1,
"input too long");
1113 memmove(
sc_end,
s_lab + com_start, com_end - com_start);
1114 sc_end += com_end - com_start;
1132 if (strncmp(
s_lab,
"#if", 3) == 0) {
1138 diag2(1,
"#if stack overflow");
1140 else if (strncmp(
s_lab,
"#el", 3) == 0) {
1142 diag2(1,
s_lab[3] ==
'i' ?
"Unmatched #elif" :
"Unmatched #else");
1148 else if (strncmp(
s_lab,
"#endif", 6) == 0) {
1150 diag2(1,
"Unmatched #endif");
1166 int d =
nitems(recognized);
1168 if (strncmp(
s_lab + 1, recognized[d].
string, recognized[d].
size) == 0)
1171 diag2(1,
"Unrecognized cpp directive");
void set_profile(const char *profile_name)
void errx(int eval, const char *fmt,...)
static void bakcopy(void)
static void indent_declaration(int cur_dec_ind, int tabs_to_var)
int compute_code_target(void)
int lexi(struct parser_state *)
void diag2(int, const char *)
void diag3(int, const char *, int)
int count_spaces_until(int, char *, char *)
void alloc_typenames(void)
int block_comment_max_col
int blanklines_after_procs
int postfix_blankline_requested
struct parser_state state_stack[5]
int prefix_blankline_requested
int extra_expression_indent
int format_block_comments
int comment_delimiter_on_blankline
#define CHECK_SIZE_LAB(desired_size)
struct parser_state match_state[5]
int blanklines_around_conditional_compilation
int swallow_optional_blanklines
int lineup_to_parens_always
int blanklines_after_declarations_at_proctop
if(TABLE==NULL||TABLE_index==NULL)
static void const char fflush(stdout)
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
static pg_noinline void Size size
int in_parameter_declaration
References alloc_typenames(), BACKSLASH, bakcopy(), be_save, Bill_Shannon, binary_op, parser_state::bl_line, blanklines_after_declarations_at_proctop, blanklines_after_procs, blanklines_around_conditional_compilation, block_comment_max_col, parser_state::block_init, parser_state::block_init_level, bp_save, break_comma, btype_2, buf_end, buf_ptr, bufsize, parser_state::case_indent, casestmt, parser_state::cast_mask, CHECK_SIZE_CODE, CHECK_SIZE_LAB, code_lines, codebuf, colon, parser_state::com_ind, parser_state::com_lines, combuf, comma, comment, comment_delimiter_on_blankline, compute_code_target(), continuation_indent, count_spaces_until(), cuddle_else, parser_state::dec_nest, decl, parser_state::decl_com_ind, parser_state::decl_indent, parser_state::decl_on_line, diag2(), diag3(), dolit, dump_line(), parser_state::dumped_decl_indent, e_code, e_com, e_lab, e_token, parser_state::else_if, elselit, err(), errx(), exit(), extra_expression_indent, fflush(), fill_buffer(), form_feed, format_block_comments, format_col1_comments, forstmt, found_err, funcname, function_brace_split, had_eof, i, parser_state::i_l_follow, ident, if(), ifdef_level, ifhead, ifstmt, parser_state::il, in_buffer, in_buffer_limit, parser_state::in_decl, in_name, parser_state::in_or_st, parser_state::in_parameter_declaration, parser_state::in_stmt, parser_state::ind_level, parser_state::ind_size, parser_state::ind_stmt, indent_declaration(), parser_state::indent_parameters, input, parser_state::just_saw_decl, parser_state::keyword, l_code, l_com, l_lab, l_token, labbuf, parser_state::last_nl, parser_state::last_token, parser_state::last_u_d, lbrace, parser_state::leave_comma, len, lexi(), line_no, lineup_to_parens, lineup_to_parens_always, parser_state::ljust_decl, parser_state::local_decl_indent, lparen, malloc, match_state, max_col, n_real_blanklines, newline, nitems, parser_state::not_cast_mask, parser_state::out_coms, parser_state::out_lines, out_name, output, parser_state::p_l_follow, parser_state::p_stack, parser_state::paren_indents, parser_state::paren_level, parse(), parser_state::pcase, period, postfix_blankline_requested, postop, pr_comment(), preesc, prefix_blankline_requested, printf, proc_calls_space, parser_state::procname, procnames_start_line, ps, question, rbrace, rparen, s_code, s_com, s_lab, s_token, save_com, sc_buf, sc_end, sc_size, parser_state::search_brace, semicolon, set_defaults(), set_option, set_profile(), size, sp_nparen, sp_paren, space_after_cast, star_comment_cont, state_stack, generate_unaccent_rules::stdout, stmt, storage, strpfx, structure, swallow_optional_blanklines, swstmt, tabsize, token, tokenbuf, parser_state::tos, type_def, unary_op, parser_state::unindent_displace, parser_state::use_ff, use_tabs, verbose, parser_state::want_blank, and whilestmt.