Re: do {} while (0) nitpick

2020-05-07 Thread Andrew Dunstan
On 5/6/20 6:39 PM, David Steele wrote: > On 5/6/20 6:28 PM, Andrew Dunstan wrote: >> On 5/6/20 3:24 PM, Tom Lane wrote: >> >>> BTW, I looked around and could not find a package-provided ppport.h >>> at all on my Red Hat systems.  What package is it in? >> >> perl-Devel-PPPort contains a perl

Re: do {} while (0) nitpick

2020-05-06 Thread David Steele
On 5/6/20 6:28 PM, Andrew Dunstan wrote: On 5/6/20 3:24 PM, Tom Lane wrote: BTW, I looked around and could not find a package-provided ppport.h at all on my Red Hat systems. What package is it in? perl-Devel-PPPort contains a perl module that will write the file for you like this:

Re: do {} while (0) nitpick

2020-05-06 Thread Andrew Dunstan
On 5/6/20 3:24 PM, Tom Lane wrote: > Andrew Dunstan writes: >> I tried this out with ppport.h from perl 5.30.2 which is what's on my >> Fedora 31 workstation. It compiled fine, no warnings and the tests all >> ran fine. >> So we could update it. I'm just not sure there would be any great >>

Re: do {} while (0) nitpick

2020-05-06 Thread Tom Lane
Andrew Dunstan writes: > I tried this out with ppport.h from perl 5.30.2 which is what's on my > Fedora 31 workstation. It compiled fine, no warnings and the tests all > ran fine. > So we could update it. I'm just not sure there would be any great > benefit from doing so until we want to use some

Re: do {} while (0) nitpick

2020-05-06 Thread Andrew Dunstan
On 5/4/20 6:44 PM, Andrew Dunstan wrote: > On 5/1/20 5:32 PM, Tom Lane wrote: >> There are remaining instances of this antipattern in the flex-generated >> scanners, which we can't do anything about; and in pl/plperl/ppport.h, >> which we shouldn't do anything about because that's

Re: do {} while (0) nitpick

2020-05-04 Thread Andrew Dunstan
On 5/1/20 5:32 PM, Tom Lane wrote: > > There are remaining instances of this antipattern in the flex-generated > scanners, which we can't do anything about; and in pl/plperl/ppport.h, > which we shouldn't do anything about because that's upstream-generated > code. (I wonder though if there's a

Re: do {} while (0) nitpick

2020-05-04 Thread Tom Lane
Jesse Zhang writes: > On Fri, May 1, 2020 at 2:32 PM Tom Lane wrote: >> Grepping showed me that there were some not-do-while macros that >> also had trailing semicolons. These seem just as broken, so I >> fixed 'em all. > I'm curious: *How* are you able to discover those occurrences with grep?

Re: do {} while (0) nitpick

2020-05-04 Thread Jesse Zhang
Hi Tom, On Fri, May 1, 2020 at 2:32 PM Tom Lane wrote: > > Grepping showed me that there were some not-do-while macros that > also had trailing semicolons. These seem just as broken, so I > fixed 'em all. > I'm curious: *How* are you able to discover those occurrences with grep? I understand

Re: do {} while (0) nitpick

2020-05-04 Thread Oleksandr Shulgin
On Fri, May 1, 2020 at 3:52 AM Bruce Momjian wrote: > > On Thu, Apr 30, 2020 at 09:51:10PM -0400, Tom Lane wrote: > > John Naylor writes: > > > As I understand it, the point of having "do {} while (0)" in a > > > multi-statement macro is to turn it into a simple statement. > > > > Right. > > > >

Re: do {} while (0) nitpick

2020-05-01 Thread David Steele
On 4/30/20 9:52 PM, Bruce Momjian wrote: On Thu, Apr 30, 2020 at 09:51:10PM -0400, Tom Lane wrote: John Naylor writes: As I understand it, the point of having "do {} while (0)" in a multi-statement macro is to turn it into a simple statement. Right. As such, ending with a semicolon in

Re: do {} while (0) nitpick

2020-04-30 Thread Bruce Momjian
On Thu, Apr 30, 2020 at 09:51:10PM -0400, Tom Lane wrote: > John Naylor writes: > > As I understand it, the point of having "do {} while (0)" in a > > multi-statement macro is to turn it into a simple statement. > > Right. > > > As such, > > ending with a semicolon in both the macro definition

Re: do {} while (0) nitpick

2020-04-30 Thread Tom Lane
John Naylor writes: > As I understand it, the point of having "do {} while (0)" in a > multi-statement macro is to turn it into a simple statement. Right. > As such, > ending with a semicolon in both the macro definition and the > invocation will turn it back into multiple statements, creating

do {} while (0) nitpick

2020-04-30 Thread John Naylor
Hi, As I understand it, the point of having "do {} while (0)" in a multi-statement macro is to turn it into a simple statement. As such, ending with a semicolon in both the macro definition and the invocation will turn it back into multiple statements, creating confusion if someone were to invoke