On Sat, Mar 19, 2005 at 12:24:37PM -0000, Alexey Tourbin wrote: > h2ph fails to convert the following simple header file. > > $ cat asm/unistd.h > #ifndef _ASM_X86_64_UNISTD_H_ > #define _ASM_X86_64_UNISTD_H_ > > extern inline long exit(int error_code) > { > sys_exit(error_code); > } > > #endif > $ > > Please note that its location under asm/ directory is essential.
And even the following simple header file suffers wrong conversion: $ cat test.h #ifndef TEST_H #define TEST_H #ifdef __LANGUAGE_PASCAL__ #endif #endif $ Note that asm/ location is unrelated for this time. $ h2ph -d . test.h test.h -> test.ph $ perl -c test.ph Missing right curly or square bracket at test.ph line 7, at end of line syntax error at test.ph line 7, at EOF test.ph had compilation errors. $ cat test.ph require '_h2ph_pre.ph'; no warnings 'redefine'; unless(defined(&TEST_H)) { eval 'sub TEST_H () {1;}' unless defined(&TEST_H); 1; $ The problem seems to be inside next_line(): READ: while (not eof IN) { $in .= <IN>; chomp $in; next unless length $in; while (length $in) { ... if ($in =~ /^\#ifdef __LANGUAGE_PASCAL__/) { # Tru64 disassembler.h evilness: mixed C and Pascal. while (<IN>) { last if /^\#endif/; } next READ; } if ($in =~ /^extern inline / && # Inlined assembler. $^O eq 'linux' && $file =~ m!(?:^|/)asm/[^/]+\.h$!) { while (<IN>) { last if /^}/; } next READ; } The problem is that $in varialbe is not reset and "if" conditons hold true till the end of file. Here is a patch (which has not been tested yet, but seems to be reasonable offhand). --- perl-5.9.2.24046/utils/h2ph.PL- 2005-01-30 15:19:00 +0000 +++ perl-5.9.2.24046/utils/h2ph.PL 2005-03-19 13:32:26 +0000 @@ -556,6 +556,7 @@ sub next_line while (<IN>) { last if /^\#endif/; } + $in = ""; next READ; } if ($in =~ /^extern inline / && # Inlined assembler. @@ -563,6 +564,7 @@ sub next_line while (<IN>) { last if /^}/; } + $in = ""; next READ; } if ($in =~ s/\\$//) { # \-newline End of patch > $ h2ph -d . asm/unistd.h > asm/unistd.h -> asm/unistd.ph > $ perl -c asm/unistd.ph > Missing right curly or square bracket at asm/unistd.ph line 7, at end of line > syntax error at asm/unistd.ph line 7, at EOF > asm/unistd.ph had compilation errors. > $ cat asm/unistd.ph > require '_h2ph_pre.ph'; > > no warnings 'redefine'; > > unless(defined(&_ASM_X86_64_UNISTD_H_)) { > eval 'sub _ASM_X86_64_UNISTD_H_ () {1;}' unless > defined(&_ASM_X86_64_UNISTD_H_); > 1; > $ -- Alexey Tourbin ALT Linux Team
pgpE1nsnAUZ6K.pgp
Description: PGP signature