34static char sccsid[] =
"@(#)indent.c 5.17 (Berkeley) 6/7/93";
50#define DECLARE_INDENT_GLOBALS 1
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);
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");
1207 char buff[8 * 1024];
1212 while (p >
in_name && *p !=
'/')
1219 bakchn = creat(
bakfile, 0600);
1222 while ((n =
read(fileno(
input), buff,
sizeof(buff))) > 0)
1223 if (
write(bakchn, buff, n) != n)
1262 cur_dec_ind >= tpos +
tabsize) ?
'\t' :
' ';
1267 while (pos < cur_dec_ind) {
void set_profile(const char *profile_name)
void err(int eval, const char *fmt,...)
void errx(int eval, const char *fmt,...)
static void bakcopy(void)
int main(int argc, char **argv)
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
#define CHECK_SIZE_CODE(desired_size)
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 XLogRecPtr startpos
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