Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Jul 2016 09:13:41 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        "Pedro F. Giffuni" <pfg@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r303485 - head/usr.bin/indent
Message-ID:  <20160730085927.B1012@besplex.bde.org>
In-Reply-To: <201607291623.u6TGN08u064305@repo.freebsd.org>
References:  <201607291623.u6TGN08u064305@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 29 Jul 2016, Pedro F. Giffuni wrote:

> Log:
>  indent(1): fix struct termination detection.
>
>  Semicolons inside struct declarations don't end the declarations.
>
>  Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
>  Obtained from:	Piotr Stefaniak
>
> Modified:
>  head/usr.bin/indent/indent.c
>
> Modified: head/usr.bin/indent/indent.c
> ==============================================================================
> --- head/usr.bin/indent/indent.c	Fri Jul 29 16:17:54 2016	(r303484)
> +++ head/usr.bin/indent/indent.c	Fri Jul 29 16:23:00 2016	(r303485)
> @@ -701,8 +701,10 @@ check_type:
> 	    break;
>
> 	case semicolon:	/* got a ';' */
> -	    ps.in_or_st = false;/* we are not in an initialization or
> -				 * structure declaration */
> +	    if (ps.dec_nest == 0) {
> +		/* we are not in an initialization or structure declaration */
> +		ps.in_or_st = false;
> +	    }

This adds some style bugs.  indent is written in a bad style that is very
far from KNF, but perhaps it could format itself if it had an indent.pro.

Part of its bad style is to use unnecessary parentheses a lot.  But it
mostly doesn't use unecessary braces.  Except here.

Another part of its bad style is to put comments to the right of the
code, even when this requires misformatting them across multiple lines.
The changed code gave example of both (the misformatting was to not
have any whitespace between the semicolon and the comment so as to
minimise comment indentation.  This was actually another style bug.
indent normally puts comments at the right at a tab stop even when
this gives very narrow comments split across several lines).  The
changed code puts the comment on a line by itself.  indent almost never
does that elsewhere for comments about single statements.  The comment
here is technically for a block of compound statements, but the block
has only 1 statement and was created by using excessive braces.

> 	    scase = false;	/* these will only need resetting in an error */
> 	    squest = 0;
> 	    if (ps.last_token == rparen && rparen_count == 0)

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160730085927.B1012>