Re: WIP pgindent replacement - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: WIP pgindent replacement
Date
Msg-id 4E01F5BD.8090201@dunslane.net
Whole thread Raw
In response to Re: WIP pgindent replacement  (Bruce Momjian <bruce@momjian.us>)
Responses Re: WIP pgindent replacement
List pgsql-hackers

On 06/22/2011 09:08 AM, Bruce Momjian wrote:
> Andrew Dunstan wrote:
>>
>> On 06/22/2011 08:35 AM, Andrew Dunstan wrote:
>>>
>>> On 06/22/2011 02:03 AM, David Christensen wrote:
>>>>>      # Avoid bug that converts 'x =- 1' to 'x = -1'
>>>>>       $source =~ s!=- !-= !g;
>>>> I haven't looked at the shell script this replaces, but is that the
>>>> correct substitution pattern?  (BTW, I'm not seeing the token =-
>>>> anywhere except in the Makefile, which wouldn't be run against, no?
>>>> Am I missing something?)
>>>>
>>>>
>>>
>>> It's exactly what the current script does. The reason you don't see
>>> this anywhere is that previous pgindent runs have removed it. We don't
>>> undo the transformation. But maybe we should just get rid of it.
>>>
>>>
>> Further research shows that C89 explicitly dropped support for the old
>> K&R "=-" operator, so we probably *should* remove this in case it
>> introduces an unintended bug.
> Well, the point is if someone does use that, it isn't going to generate
> a pgindent error, but rather produce incorrect C code because =- is
> going to be changed.  FYI, my gcc 2.95.3 allows =- and does work as
> intended.
>

As intended by whom? If the effect of "x=4; x =- 1;" is to subtract 1 
from x then that's simply wrong by C89. It should assign -1 to x. The 
"=-" must be parsed as two operators in C89, assignment and unary minus. 
pgindent should not under any circumstances change the semantics of the 
program being indented, and that's what this transformation does for 
compilers conforming to the standard we explicitly follow.

What happens when your ancient gcc is told to apply the ansi standard?

cheers

andrew


pgsql-hackers by date:

Previous
From: Jeff MacDonald
Date:
Subject: Re: Indication of db-shared tables
Next
From: Bruce Momjian
Date:
Subject: Re: WIP pgindent replacement