Module Name: src Committed By: rillig Date: Sat Sep 25 17:36:51 UTC 2021
Modified Files: src/usr.bin/indent: indent.c indent.h indent_globs.h io.c lexi.c parse.c pr_comment.c Log Message: indent: convert remaining ibool to bool No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/usr.bin/indent/indent.c cvs rdiff -u -r1.21 -r1.22 src/usr.bin/indent/indent.h cvs rdiff -u -r1.31 -r1.32 src/usr.bin/indent/indent_globs.h cvs rdiff -u -r1.61 -r1.62 src/usr.bin/indent/io.c cvs rdiff -u -r1.54 -r1.55 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/indent/parse.c cvs rdiff -u -r1.43 -r1.44 src/usr.bin/indent/pr_comment.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.74 src/usr.bin/indent/indent.c:1.75 --- src/usr.bin/indent/indent.c:1.74 Sat Sep 25 17:29:13 2021 +++ src/usr.bin/indent/indent.c Sat Sep 25 17:36:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.74 2021/09/25 17:29:13 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.75 2021/09/25 17:36:51 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.74 2021/09/25 17:29:13 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.75 2021/09/25 17:36:51 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -107,13 +107,13 @@ char *be_save; int found_err; int n_real_blanklines; -ibool prefix_blankline_requested; -ibool postfix_blankline_requested; -ibool break_comma; +bool prefix_blankline_requested; +bool postfix_blankline_requested; +bool break_comma; float case_ind; -ibool had_eof; +bool had_eof; int line_no; -ibool inhibit_formatting; +bool inhibit_formatting; int suppress_blanklines; int ifdef_level; @@ -124,7 +124,7 @@ FILE *input; FILE *output; static void bakcopy(void); -static void indent_declaration(int, ibool); +static void indent_declaration(int, bool); const char *in_name = "Standard Input"; /* will always point to name of input * file */ @@ -181,8 +181,8 @@ init_capsicum(void) #endif static void -search_brace(token_type *inout_ttype, ibool *inout_force_nl, - ibool *inout_comment_buffered, ibool *inout_last_else) +search_brace(token_type *inout_ttype, bool *inout_force_nl, + bool *inout_comment_buffered, bool *inout_last_else) { while (ps.search_brace) { switch (*inout_ttype) { @@ -263,7 +263,7 @@ search_brace(token_type *inout_ttype, ib /* FALLTHROUGH */ default: /* it is the start of a normal statement */ { - ibool remove_newlines; + bool remove_newlines; remove_newlines = /* "} else" */ @@ -524,7 +524,7 @@ process_end_of_file(void) } static void -process_comment_in_code(token_type ttype, ibool *inout_force_nl) +process_comment_in_code(token_type ttype, bool *inout_force_nl) { if (*inout_force_nl && ttype != semicolon && @@ -576,7 +576,7 @@ process_newline(void) } static void -process_lparen_or_lbracket(int dec_ind, ibool tabs_to_var, ibool sp_sw) +process_lparen_or_lbracket(int dec_ind, bool tabs_to_var, bool sp_sw) { /* count parens to make Healy happy */ if (++ps.p_l_follow == nitems(ps.paren_indents)) { @@ -626,8 +626,8 @@ process_lparen_or_lbracket(int dec_ind, } static void -process_rparen_or_rbracket(ibool *inout_sp_sw, ibool *inout_force_nl, - token_type hd_type) +process_rparen_or_rbracket(bool *inout_sp_sw, bool *inout_force_nl, + token_type hd_type) { if ((ps.cast_mask & (1 << ps.p_l_follow) & ~ps.not_cast_mask) != 0) { ps.last_u_d = true; @@ -663,7 +663,7 @@ process_rparen_or_rbracket(ibool *inout_ } static void -process_unary_op(int dec_ind, ibool tabs_to_var) +process_unary_op(int dec_ind, bool tabs_to_var) { if (!ps.dumped_decl_indent && ps.in_decl && !ps.block_init && ps.procname[0] == '\0' && ps.paren_level == 0) { @@ -726,7 +726,7 @@ process_question(int *inout_squest) } static void -process_colon(int *inout_squest, ibool *inout_force_nl, ibool *inout_scase) +process_colon(int *inout_squest, bool *inout_force_nl, bool *inout_scase) { if (*inout_squest > 0) { /* it is part of the <c>?<n>: <n> construct */ --*inout_squest; @@ -766,10 +766,10 @@ process_colon(int *inout_squest, ibool * } static void -process_semicolon(ibool *inout_scase, int *inout_squest, int dec_ind, - ibool tabs_to_var, ibool *inout_sp_sw, +process_semicolon(bool *inout_scase, int *inout_squest, int dec_ind, + bool tabs_to_var, bool *inout_sp_sw, token_type hd_type, - ibool *inout_force_nl) + bool *inout_force_nl) { if (ps.dec_nest == 0) ps.in_or_st = false; /* we are not in an initialization or @@ -822,7 +822,7 @@ process_semicolon(ibool *inout_scase, in } static void -process_lbrace(ibool *inout_force_nl, ibool *inout_sp_sw, token_type hd_type, +process_lbrace(bool *inout_force_nl, bool *inout_sp_sw, token_type hd_type, int *di_stack, int di_stack_cap, int *inout_dec_ind) { ps.in_stmt = false; /* dont indent the {} */ @@ -895,7 +895,7 @@ process_lbrace(ibool *inout_force_nl, ib } static void -process_rbrace(ibool *inout_sp_sw, int *inout_dec_ind, const int *di_stack) +process_rbrace(bool *inout_sp_sw, int *inout_dec_ind, const int *di_stack) { if (ps.p_stack[ps.tos] == decl && !ps.block_init) /* semicolons can be * omitted in declarations */ @@ -931,7 +931,7 @@ process_rbrace(ibool *inout_sp_sw, int * } static void -process_keyword_do_else(ibool *inout_force_nl, ibool *inout_last_else) +process_keyword_do_else(bool *inout_force_nl, bool *inout_last_else) { ps.in_stmt = false; if (*token.s == 'e') { @@ -958,7 +958,7 @@ process_keyword_do_else(ibool *inout_for } static void -process_decl(int *out_dec_ind, ibool *out_tabs_to_var) +process_decl(int *out_dec_ind, bool *out_tabs_to_var) { parse(decl); /* let parser worry about indentation */ if (ps.last_token == rparen && ps.tos <= 1) { @@ -992,8 +992,8 @@ process_decl(int *out_dec_ind, ibool *ou } static void -process_ident(token_type ttype, int dec_ind, ibool tabs_to_var, - ibool *inout_sp_sw, ibool *inout_force_nl, token_type hd_type) +process_ident(token_type ttype, int dec_ind, bool tabs_to_var, + bool *inout_sp_sw, bool *inout_force_nl, token_type hd_type) { if (ps.in_decl) { if (ttype == funcname) { @@ -1055,7 +1055,7 @@ process_period(void) } static void -process_comma(int dec_ind, ibool tabs_to_var, ibool *inout_force_nl) +process_comma(int dec_ind, bool tabs_to_var, bool *inout_force_nl) { ps.want_blank = (code.s != code.e); /* only put blank after comma * if comma does not start the line */ @@ -1086,7 +1086,7 @@ process_preprocessing(void) *lab.e++ = '#'; /* move whole line to 'label' buffer */ { - ibool in_comment = false; + bool in_comment = false; int com_start = 0; char quote = '\0'; int com_end = 0; @@ -1203,11 +1203,7 @@ process_preprocessing(void) } } if (opt.blanklines_around_conditional_compilation) { -#ifdef lint postfix_blankline_requested = true; -#else - postfix_blankline_requested++; -#endif n_real_blanklines = 0; } else { postfix_blankline_requested = false; @@ -1224,19 +1220,19 @@ static void __attribute__((__noreturn__) main_loop(void) { token_type ttype; - ibool force_nl; /* when true, code must be broken */ - ibool last_else = false; /* true iff last keyword was an else */ + bool force_nl; /* when true, code must be broken */ + bool last_else = false; /* true iff last keyword was an else */ int dec_ind; /* current indentation for declarations */ int di_stack[20]; /* a stack of structure indentation levels */ - ibool tabs_to_var; /* true if using tabs to indent to var name */ - ibool sp_sw; /* when true, we are in the expression of + bool tabs_to_var; /* true if using tabs to indent to var name */ + bool sp_sw; /* when true, we are in the expression of * if(...), while(...), etc. */ token_type hd_type = end_of_file; /* used to store type of stmt * for if (...), for (...), etc */ int squest; /* when this is positive, we have seen a '?' * without the matching ':' in a <c>?<s>:<s> * construct */ - ibool scase; /* set to true when we see a case, so we will + bool scase; /* set to true when we see a case, so we will * know what to do with the following colon */ sp_sw = force_nl = false; @@ -1248,7 +1244,7 @@ main_loop(void) for (;;) { /* this is the main loop. it will go until we * reach eof */ - ibool comment_buffered = false; + bool comment_buffered = false; ttype = lexi(&ps); /* Read the next token. The actual characters * read are stored in "token". */ @@ -1473,7 +1469,7 @@ bakcopy(void) } static void -indent_declaration(int cur_dec_ind, ibool tabs_to_var) +indent_declaration(int cur_dec_ind, bool tabs_to_var) { int pos = (int)(code.e - code.s); char *startpos = code.e; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.21 src/usr.bin/indent/indent.h:1.22 --- src/usr.bin/indent/indent.h:1.21 Sat Sep 25 17:11:23 2021 +++ src/usr.bin/indent/indent.h Sat Sep 25 17:36:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.21 2021/09/25 17:11:23 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.22 2021/09/25 17:36:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -34,12 +34,6 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/ #include <stdbool.h> -#ifdef lint -typedef bool ibool; -#else -typedef int ibool; -#endif - #include "indent_codes.h" #include "indent_globs.h" Index: src/usr.bin/indent/indent_globs.h diff -u src/usr.bin/indent/indent_globs.h:1.31 src/usr.bin/indent/indent_globs.h:1.32 --- src/usr.bin/indent/indent_globs.h:1.31 Sat Sep 25 17:29:13 2021 +++ src/usr.bin/indent/indent_globs.h Sat Sep 25 17:36:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent_globs.h,v 1.31 2021/09/25 17:29:13 rillig Exp $ */ +/* $NetBSD: indent_globs.h,v 1.32 2021/09/25 17:36:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -175,15 +175,15 @@ enum rwcode { extern int found_err; extern int n_real_blanklines; -extern ibool prefix_blankline_requested; -extern ibool postfix_blankline_requested; -extern ibool break_comma; /* when true and not in parens, break after a +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 * n:" */ -extern ibool had_eof; /* set to true when input is exhausted */ +extern bool had_eof; /* set to true when input is exhausted */ extern int line_no; /* the current line number. */ -extern ibool inhibit_formatting; /* true if INDENT OFF is in effect */ +extern bool inhibit_formatting; /* true if INDENT OFF is in effect */ extern int suppress_blanklines;/* set iff following blanklines should be * suppressed */ Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.61 src/usr.bin/indent/io.c:1.62 --- src/usr.bin/indent/io.c:1.61 Sat Sep 25 17:29:13 2021 +++ src/usr.bin/indent/io.c Sat Sep 25 17:36:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.61 2021/09/25 17:29:13 rillig Exp $ */ +/* $NetBSD: io.c,v 1.62 2021/09/25 17:36:51 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.61 2021/09/25 17:29:13 rillig Exp $"); +__RCSID("$NetBSD: io.c,v 1.62 2021/09/25 17:36:51 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $"); #endif @@ -57,7 +57,7 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/ #include "indent.h" -ibool comment_open; +bool comment_open; static int paren_indent; static void @@ -112,7 +112,7 @@ void dump_line(void) { int cur_col; - static ibool not_first_line; + static bool not_first_line; if (ps.procname[0] != '\0') { ps.ind_level = 0; @@ -374,11 +374,7 @@ parse_indent_comment(void) if (com.s != com.e || lab.s != lab.e || code.s != code.e) dump_line(); -#ifdef lint - if (!(inhibit_formatting = (on_off - 1) != 0)) { -#else - if (!(inhibit_formatting = on_off - 1)) { -#endif + if (!(inhibit_formatting = (on_off == 2))) { n_real_blanklines = 0; postfix_blankline_requested = false; prefix_blankline_requested = false; Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.54 src/usr.bin/indent/lexi.c:1.55 --- src/usr.bin/indent/lexi.c:1.54 Sat Sep 25 17:11:23 2021 +++ src/usr.bin/indent/lexi.c Sat Sep 25 17:36:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.54 2021/09/25 17:11:23 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.55 2021/09/25 17:36:51 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.54 2021/09/25 17:11:23 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.55 2021/09/25 17:36:51 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); #endif @@ -336,7 +336,7 @@ lex_char_or_string(void) token_type lexi(struct parser_state *state) { - ibool unary_delim; /* whether the current token + bool unary_delim; /* whether the current token * forces a following operator to be unary */ token_type ttype; Index: src/usr.bin/indent/parse.c diff -u src/usr.bin/indent/parse.c:1.24 src/usr.bin/indent/parse.c:1.25 --- src/usr.bin/indent/parse.c:1.24 Sat Sep 25 17:11:23 2021 +++ src/usr.bin/indent/parse.c Sat Sep 25 17:36:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.24 2021/09/25 17:11:23 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.25 2021/09/25 17:36:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -234,7 +234,7 @@ parse(token_type ttype) * Try to combine the statement on the top of the parse stack with the symbol * directly below it, replacing these two symbols with a single symbol. */ -static ibool +static bool reduce_stmt(void) { switch (ps.p_stack[ps.tos - 1]) { Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.43 src/usr.bin/indent/pr_comment.c:1.44 --- src/usr.bin/indent/pr_comment.c:1.43 Sat Sep 25 17:11:23 2021 +++ src/usr.bin/indent/pr_comment.c Sat Sep 25 17:36:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.43 2021/09/25 17:11:23 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.44 2021/09/25 17:36:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: pr_comment.c,v 1.43 2021/09/25 17:11:23 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.44 2021/09/25 17:36:51 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $"); #endif @@ -94,7 +94,7 @@ process_comment(void) * that spill over the right margin */ ssize_t last_blank; /* index of the last blank in com.buf */ char *t_ptr; /* used for moving string */ - ibool break_delim = opt.comment_delimiter_on_blankline; + bool break_delim = opt.comment_delimiter_on_blankline; int l_just_saw_decl = ps.just_saw_decl; adj_max_line_length = opt.max_line_length;