indent(1): don't produce unneeded space character in function declarators.
This commit is contained in:
parent
56e91aa977
commit
a3abcad0b7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=321381
@ -535,11 +535,12 @@ main(int argc, char **argv)
|
||||
ps.p_l_follow--;
|
||||
}
|
||||
if (ps.want_blank && *token != '[' &&
|
||||
(ps.last_token != ident || proc_calls_space ||
|
||||
((ps.last_token != ident && ps.last_token != funcname) ||
|
||||
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 + Bill_Shannon > 2))
|
||||
*e_code++ = ' ';
|
||||
ps.want_blank = false;
|
||||
if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent &&
|
||||
@ -576,7 +577,6 @@ main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case rparen: /* got a ')' or ']' */
|
||||
rparen_count--;
|
||||
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;
|
||||
@ -738,7 +738,7 @@ main(int argc, char **argv)
|
||||
* structure declaration */
|
||||
scase = false; /* these will only need resetting in an error */
|
||||
squest = 0;
|
||||
if (ps.last_token == rparen && rparen_count == 0)
|
||||
if (ps.last_token == rparen)
|
||||
ps.in_parameter_declaration = 0;
|
||||
ps.cast_mask = 0;
|
||||
ps.not_cast_mask = 0;
|
||||
@ -838,6 +838,7 @@ main(int argc, char **argv)
|
||||
&& ps.in_parameter_declaration)
|
||||
postfix_blankline_requested = 1;
|
||||
ps.in_parameter_declaration = 0;
|
||||
ps.in_decl = false;
|
||||
}
|
||||
dec_ind = 0;
|
||||
parse(lbrace); /* let parser know about this */
|
||||
@ -935,7 +936,6 @@ main(int argc, char **argv)
|
||||
case decl: /* we have a declaration type (int, etc.) */
|
||||
parse(decl); /* let parser worry about indentation */
|
||||
if (ps.last_token == rparen && ps.tos <= 1) {
|
||||
ps.in_parameter_declaration = 1;
|
||||
if (s_code != e_code) {
|
||||
dump_line();
|
||||
ps.want_blank = 0;
|
||||
@ -964,10 +964,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
goto copy_id;
|
||||
|
||||
case funcname:
|
||||
case ident: /* got an identifier or constant */
|
||||
if (ps.in_decl) { /* if we are in a declaration, we must indent
|
||||
* identifier */
|
||||
if (is_procname == 0 || !procnames_start_line) {
|
||||
if (type_code != funcname || !procnames_start_line) {
|
||||
if (!ps.block_init && !ps.dumped_decl_indent) {
|
||||
if (troff) {
|
||||
if (ps.want_blank)
|
||||
@ -980,7 +981,8 @@ main(int argc, char **argv)
|
||||
ps.want_blank = false;
|
||||
}
|
||||
} else {
|
||||
if (ps.want_blank)
|
||||
if (ps.want_blank && !(procnames_start_line &&
|
||||
type_code == funcname))
|
||||
*e_code++ = ' ';
|
||||
ps.want_blank = false;
|
||||
if (dec_ind && s_code != e_code) {
|
||||
@ -1014,7 +1016,8 @@ main(int argc, char **argv)
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = *t_ptr;
|
||||
}
|
||||
ps.want_blank = true;
|
||||
if (type_code != funcname)
|
||||
ps.want_blank = true;
|
||||
break;
|
||||
|
||||
case strpfx:
|
||||
|
@ -70,3 +70,4 @@
|
||||
#define period 32
|
||||
#define strpfx 33
|
||||
#define storage 34
|
||||
#define funcname 35
|
||||
|
@ -330,6 +330,5 @@ struct parser_state {
|
||||
} ps;
|
||||
|
||||
int ifdef_level;
|
||||
int rparen_count;
|
||||
struct parser_state state_stack[5];
|
||||
struct parser_state match_state[5];
|
||||
|
@ -353,7 +353,8 @@ lexi(void)
|
||||
return (ident);
|
||||
} /* end of switch */
|
||||
} /* end of if (found_it) */
|
||||
if (*buf_ptr == '(' && ps.tos <= 1 && ps.ind_level == 0) {
|
||||
if (*buf_ptr == '(' && ps.tos <= 1 && ps.ind_level == 0 &&
|
||||
ps.in_parameter_declaration == 0 && ps.block_init == 0) {
|
||||
char *tp = buf_ptr;
|
||||
while (tp < buf_end)
|
||||
if (*tp++ == ')' && (*tp == ';' || *tp == ','))
|
||||
@ -361,7 +362,7 @@ lexi(void)
|
||||
strncpy(ps.procname, token, sizeof ps.procname - 1);
|
||||
if (ps.in_decl)
|
||||
ps.in_parameter_declaration = 1;
|
||||
rparen_count = 1;
|
||||
return (last_code = funcname);
|
||||
not_proc:;
|
||||
}
|
||||
/*
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
#define b00101010 -1
|
||||
void
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
unsigned a[] = {0b00101010, 0x00005678, 02, 17U};
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303597, r303598, r309219, and r309343 */
|
||||
void
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
/*
|
||||
|
@ -1,6 +1,32 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303570 */
|
||||
void t(void) {
|
||||
|
||||
static const struct
|
||||
{
|
||||
double x;
|
||||
double y, z;
|
||||
} n[m + 1] =
|
||||
{
|
||||
{
|
||||
.0,
|
||||
.9,
|
||||
5
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct Complex
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
} Complex;
|
||||
|
||||
void
|
||||
t1 (char *a, int b,
|
||||
void (*fn)(void))
|
||||
{}
|
||||
|
||||
void t2 (char *x, int y)
|
||||
{
|
||||
int a,
|
||||
b,
|
||||
c;
|
||||
@ -19,3 +45,32 @@ void t(void) {
|
||||
,o
|
||||
;
|
||||
}
|
||||
|
||||
const int int_minimum_size =
|
||||
MAXALIGN(offsetof(int, test)) + MAXIMUM_ALIGNOF;
|
||||
|
||||
int *int_create(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
_attribute_printf(1, 2)
|
||||
void
|
||||
print_error(const char *fmt,...)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static LIST_HEAD(, alq) ald_active;
|
||||
static int ald_shutingdown = 0;
|
||||
struct thread *ald_thread;
|
||||
|
||||
static int
|
||||
do_execve(td, args, mac_p)
|
||||
struct thread *td;
|
||||
struct image_args *args;
|
||||
struct mac *mac_p;
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,31 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303570 */
|
||||
void
|
||||
t(void)
|
||||
|
||||
static const struct {
|
||||
double x;
|
||||
double y, z;
|
||||
} n[m + 1] =
|
||||
{
|
||||
{
|
||||
.0,
|
||||
.9,
|
||||
5
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct Complex {
|
||||
double x;
|
||||
double y;
|
||||
} Complex;
|
||||
|
||||
void
|
||||
t1(char *a, int b,
|
||||
void (*fn) (void))
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
t2(char *x, int y)
|
||||
{
|
||||
int a, b, c;
|
||||
int
|
||||
@ -13,3 +37,33 @@ t(void)
|
||||
,o
|
||||
;
|
||||
}
|
||||
|
||||
const int int_minimum_size =
|
||||
MAXALIGN(offsetof(int, test)) + MAXIMUM_ALIGNOF;
|
||||
|
||||
int *
|
||||
int_create(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
_attribute_printf(1, 2)
|
||||
void
|
||||
print_error(const char *fmt,...)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static LIST_HEAD(, alq) ald_active;
|
||||
static int ald_shutingdown = 0;
|
||||
struct thread *ald_thread;
|
||||
|
||||
static int
|
||||
do_execve(td, args, mac_p)
|
||||
struct thread *td;
|
||||
struct image_args *args;
|
||||
struct mac *mac_p;
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303484 and r309342 */
|
||||
void
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
if (0)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303499 */
|
||||
void
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
unsigned long x = 314UL;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303489 */
|
||||
void
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
switch (1) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
void
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int a = (double)8;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303718 */
|
||||
void
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int n = malloc(offsetof(struct s, f) + 1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
void
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int a = (double) 8;
|
||||
|
Loading…
Reference in New Issue
Block a user