develooper Front page | perl.perl5.porters | Postings from December 2011

[perl #34496] h2ph is unable to parse do { ... } while (0) constructs in macros

From:
James E Keenan via RT
Date:
December 28, 2011 16:05
Subject:
[perl #34496] h2ph is unable to parse do { ... } while (0) constructs in macros
Message ID:
rt-3.6.HEAD-14510-1325117140-1939.34496-15-0@perl.org
On Sat Mar 19 09:59:22 2005, at@altlinux.ru wrote:
> This is a bug report for perl from at@solemn.turbinal.org,
> generated with the help of perlbug 1.35 running under perl v5.8.6.
> 

> Again, I know h2ph is a rough tool that doesn't handle all C
>    constructs.
> This is the last bug report for today. :)
> 
> $ cat while0.h
> #define NOOP \
>         do { \
>                 int x = 1 + 1; \
>         } while (0)
> $ h2ph -d . while0.h
> while0.h -> while0.ph
> $ perl -c while0.ph
> syntax error at while0.ph line 6, near "&do { "
> syntax error at while0.ph line 7, near "}"
> while0.ph had compilation errors.
> $ cat while0.ph
> require '_h2ph_pre.ph';
> 
> no warnings 'redefine';
> 
> unless(defined(&NOOP)) {
>     sub NOOP () {        &do { 'int'  &x = 1+ 1; }  &while (0);}
> }
> 1;
> $
> 

Trying this today with Perl 5.14.2 on Darwin/PPC, I get better results:

#####
$ h2ph -d . while0.h
while0.h -> while0.ph

$ cat while0.ph
require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&NOOP)) {
    sub NOOP () {       1;}
}
1;

$ perl -c while0.ph
while0.ph syntax OK
#####

If so, can we close this ticket?

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=34496



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About