NetBSD Problem Report #55453

From www@netbsd.org  Fri Jul  3 17:08:32 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id AB53E1A9217
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  3 Jul 2020 17:08:32 +0000 (UTC)
Message-Id: <20200703170831.DCF9D1A9218@mollari.NetBSD.org>
Date: Fri,  3 Jul 2020 17:08:31 +0000 (UTC)
From: roland.illig@gmx.de
Reply-To: roland.illig@gmx.de
To: gnats-bugs@NetBSD.org
Subject: indent(1) wrongly indents second to last enum constant
X-Send-Pr-Version: www-1.0

>Number:         55453
>Category:       bin
>Synopsis:       indent(1) wrongly indents second to last enum constant
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    rillig
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 03 17:10:00 +0000 2020
>Closed-Date:    Sat Feb 12 20:41:43 +0000 2022
>Last-Modified:  Sat Feb 12 20:41:43 +0000 2022
>Originator:     Roland Illig
>Release:        indent from 9.99 (built on 2020-07-03)
>Organization:
>Environment:
>Description:
cvs up -p -r1.241 usr.bin/make/var.c > var.c
indent -bap -br -ncdb -ci4 -i4 var.c

In line 201, VAR_IN_USE is indented correctly.
In line 203, VAR_FROM_ENV is indented too far to the right.

>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/55453: indent(1) wrongly indents second to last enum constant
Date: Sat, 4 Jul 2020 01:41:30 +0300

 The minimal test case would be the following:

 $ cat enum.c
 typedef enum {
     A0,
     A1
 } E;
 $ indent -bap -br -ncdb -ci4 -i4 enum.c 
 $ cat enum.c
 typedef enum {
     A0,
 	A1
 } E;

 typedef is important here.  Compare also:

 $ cat enum.c
 enum {
     A0,
     A1
 } E;
 $ indent -bap -br -ncdb -ci4 -i4 enum.c 
 $ cat enum.c
 typedef enum {
     A0,
     A1
 }		E;


 -uwe

Responsible-Changed-From-To: bin-bug-people->rillig
Responsible-Changed-By: rillig@NetBSD.org
Responsible-Changed-When: Sat, 12 Feb 2022 01:46:30 +0000
Responsible-Changed-Why:
Broken since 2019.04.04.15.27.35, like several other things.
I'll take this one.


From: "Roland Illig" <rillig@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55453 CVS commit: src/tests/usr.bin/indent
Date: Sat, 12 Feb 2022 13:38:29 +0000

 Module Name:	src
 Committed By:	rillig
 Date:		Sat Feb 12 13:38:29 UTC 2022

 Modified Files:
 	src/tests/usr.bin/indent: lsym_typedef.c

 Log Message:
 tests/indent: demonstrate wrong formatting of enum (since 2019-04-04)

 Reported by me in PR#55453.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_typedef.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Roland Illig" <rillig@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55453 CVS commit: src/usr.bin/indent
Date: Sat, 12 Feb 2022 15:50:14 +0000

 Module Name:	src
 Committed By:	rillig
 Date:		Sat Feb 12 15:50:14 UTC 2022

 Modified Files:
 	src/usr.bin/indent: lexi.c

 Log Message:
 indent: extend debug logging for the parser state

 The member names in struct parser_state are not trustworthy, for example
 in_decl does not correspond to the intuitive definition of "inside a
 declaration".  To cope with this uncertainty, output the full state of
 the parser state to the debug log, not only the changes.  This helps to
 track the inner state for small differences in the input, such as
 between 'typedef enum { TA, TB } TT' and 'enum { EA, EB } ET'.

 This hopefully helps in fixing PR#55453.

 No functional change outside debug mode.


 To generate a diff of this commit:
 cvs rdiff -u -r1.167 -r1.168 src/usr.bin/indent/lexi.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Roland Illig" <rillig@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55453 CVS commit: src/tests/usr.bin/indent
Date: Sat, 12 Feb 2022 19:46:56 +0000

 Module Name:	src
 Committed By:	rillig
 Date:		Sat Feb 12 19:46:56 UTC 2022

 Modified Files:
 	src/tests/usr.bin/indent: lsym_tag.c

 Log Message:
 tests/indent: add another test for indentation of enum constants

 To prevent an overzealous quick hack for indenting enum constants in a
 typedef, as part of fixing PR#55453.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_tag.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Roland Illig" <rillig@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55453 CVS commit: src
Date: Sat, 12 Feb 2022 19:56:53 +0000

 Module Name:	src
 Committed By:	rillig
 Date:		Sat Feb 12 19:56:53 UTC 2022

 Modified Files:
 	src/tests/usr.bin/indent: lsym_typedef.c
 	src/usr.bin/indent: indent.h io.c lexi.c

 Log Message:
 indent: fix indentation of enum constants in typedef (since 2019-04-04)

 The solution is not elegant since it adds a small state machine inside
 the parser state, but at least these states only depend on the sequence
 of token types and not on any other part of the parser state.

 Reported in PR#55453.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_typedef.c
 cvs rdiff -u -r1.107 -r1.108 src/usr.bin/indent/indent.h
 cvs rdiff -u -r1.143 -r1.144 src/usr.bin/indent/io.c
 cvs rdiff -u -r1.168 -r1.169 src/usr.bin/indent/lexi.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: rillig@NetBSD.org
State-Changed-When: Sat, 12 Feb 2022 20:41:43 +0000
State-Changed-Why:
Fixed for NetBSD 10.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.