From owner-svn-src-head@freebsd.org Sun Jul 23 14:04:48 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50C98D7EF76; Sun, 23 Jul 2017 14:04:48 +0000 (UTC) (envelope-from pstef@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C8152F1B; Sun, 23 Jul 2017 14:04:48 +0000 (UTC) (envelope-from pstef@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6NE4lXv033202; Sun, 23 Jul 2017 14:04:47 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6NE4kBv033188; Sun, 23 Jul 2017 14:04:46 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201707231404.v6NE4kBv033188@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 23 Jul 2017 14:04:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321381 - in head/usr.bin/indent: . tests X-SVN-Group: head X-SVN-Commit-Author: pstef X-SVN-Commit-Paths: in head/usr.bin/indent: . tests X-SVN-Commit-Revision: 321381 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jul 2017 14:04:48 -0000 Author: pstef Date: Sun Jul 23 14:04:45 2017 New Revision: 321381 URL: https://svnweb.freebsd.org/changeset/base/321381 Log: indent(1): don't produce unneeded space character in function declarators. Modified: head/usr.bin/indent/indent.c head/usr.bin/indent/indent_codes.h head/usr.bin/indent/indent_globs.h head/usr.bin/indent/lexi.c head/usr.bin/indent/tests/binary.0.stdout head/usr.bin/indent/tests/comments.0.stdout head/usr.bin/indent/tests/declarations.0 head/usr.bin/indent/tests/declarations.0.stdout head/usr.bin/indent/tests/elsecomment.0.stdout head/usr.bin/indent/tests/float.0.stdout head/usr.bin/indent/tests/label.0.stdout head/usr.bin/indent/tests/nsac.0.stdout head/usr.bin/indent/tests/offsetof.0.stdout head/usr.bin/indent/tests/sac.0.stdout Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/indent.c Sun Jul 23 14:04:45 2017 (r321381) @@ -535,11 +535,12 @@ check_type: 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 @@ check_type: 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 @@ check_type: * 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 @@ check_type: && 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 @@ check_type: 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 @@ check_type: } 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 @@ check_type: 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 @@ check_type: CHECK_SIZE_CODE; *e_code++ = *t_ptr; } - ps.want_blank = true; + if (type_code != funcname) + ps.want_blank = true; break; case strpfx: Modified: head/usr.bin/indent/indent_codes.h ============================================================================== --- head/usr.bin/indent/indent_codes.h Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/indent_codes.h Sun Jul 23 14:04:45 2017 (r321381) @@ -70,3 +70,4 @@ #define period 32 #define strpfx 33 #define storage 34 +#define funcname 35 Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/indent_globs.h Sun Jul 23 14:04:45 2017 (r321381) @@ -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]; Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/lexi.c Sun Jul 23 14:04:45 2017 (r321381) @@ -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:; } /* Modified: head/usr.bin/indent/tests/binary.0.stdout ============================================================================== --- head/usr.bin/indent/tests/binary.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/binary.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define b00101010 -1 -void +void t(void) { unsigned a[] = {0b00101010, 0x00005678, 02, 17U}; Modified: head/usr.bin/indent/tests/comments.0.stdout ============================================================================== --- head/usr.bin/indent/tests/comments.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/comments.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* See r303597, r303598, r309219, and r309343 */ -void +void t(void) { /* Modified: head/usr.bin/indent/tests/declarations.0 ============================================================================== --- head/usr.bin/indent/tests/declarations.0 Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/declarations.0 Sun Jul 23 14:04:45 2017 (r321381) @@ -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; @@ -18,4 +44,33 @@ void t(void) { ,n ,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; +{ + } Modified: head/usr.bin/indent/tests/declarations.0.stdout ============================================================================== --- head/usr.bin/indent/tests/declarations.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/declarations.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,8 +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; int *d, *e, *f; @@ -12,4 +36,34 @@ t(void) ,n ,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; +{ + } Modified: head/usr.bin/indent/tests/elsecomment.0.stdout ============================================================================== --- head/usr.bin/indent/tests/elsecomment.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/elsecomment.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* See r303484 and r309342 */ -void +void t(void) { if (0) Modified: head/usr.bin/indent/tests/float.0.stdout ============================================================================== --- head/usr.bin/indent/tests/float.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/float.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* See r303499 */ -void +void t(void) { unsigned long x = 314UL; Modified: head/usr.bin/indent/tests/label.0.stdout ============================================================================== --- head/usr.bin/indent/tests/label.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/label.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* See r303489 */ -void +void t(void) { switch (1) { Modified: head/usr.bin/indent/tests/nsac.0.stdout ============================================================================== --- head/usr.bin/indent/tests/nsac.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/nsac.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,5 +1,5 @@ /* $FreeBSD$ */ -void +void t(void) { int a = (double)8; Modified: head/usr.bin/indent/tests/offsetof.0.stdout ============================================================================== --- head/usr.bin/indent/tests/offsetof.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/offsetof.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* See r303718 */ -void +void t(void) { int n = malloc(offsetof(struct s, f) + 1); Modified: head/usr.bin/indent/tests/sac.0.stdout ============================================================================== --- head/usr.bin/indent/tests/sac.0.stdout Sun Jul 23 07:10:41 2017 (r321380) +++ head/usr.bin/indent/tests/sac.0.stdout Sun Jul 23 14:04:45 2017 (r321381) @@ -1,5 +1,5 @@ /* $FreeBSD$ */ -void +void t(void) { int a = (double) 8;