Mailing List Archive

h2ph buglets and corresponding patches
I have been "messing about" with h2ph. The old define problem
(NETaa13531) was cleaned up nicely by 5.001m, however, there are a
few problems that still need to be corrected.

First, there is the question of '#' in preprocessor commands. These
cause perl to hiccough when encountered. I have made changes so they
are ignored.

Second, when the defined variable is an array, h2ph still places
a '&' before it when this should really be a '$'.

Third, as reported recently by Phillip Moore <wpm@morgan.com>, some
define statements can be mis-parsed when a 'sizeof' is involved.

Fourth, also reported recently by Phillip Moore, it was noticed that
for AIX in /usr/include/syslog.h there is a line that looks like
#include<sys/syslog.h>
The lack of a space following #include causes h2ph to ignore the
statement.

Below will be found the header file lines that prompt the problem,
the artifact that results, and what the patch below will produce.
These examples are randomly chosen but seem to be indicative of the
type of header source that will cause the resulting .ph file to
generate an error when fed to perl.

The patches are against 5.001m.

I hope this helps someone and the patches can make it into the next
release.

Thanks,

-- Richard



----------------------------
#define assert(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
----------------------------

OLD output:

sub assert {
local($EX) = @_;
eval "( &void)(($EX) || ( &__assert(#$EX, &__FILE__, &__LINE__), 0))";
}
1;

NEW output:

sub assert {
local($EX) = @_;
eval "( &void)(($EX) || ( &__assert($EX, &__FILE__, &__LINE__), 0))";
}
1;


----------------------------
#define fsid_dev val[0]
#define fsid_type val[1]
----------------------------

OLD output:

sub fsid_dev { &val[0];}
sub fsid_type { &val[1];}
1;

NEW output:

sub fsid_dev { $val[0];}
sub fsid_type { $val[1];}
1;


----------------------------
#define FD_ZERO(p) bzero((char *)(p), sizeof (*(p)))
----------------------------

OLD output:

sub FD_ZERO {
local($p) = @_;
eval " &bzero(($p), $sizeof{*($p}))";
}
1;

NEW output:

sub FD_ZERO {
local($p) = @_;
eval " &bzero(($p), $sizeof{*($p)})";
}
1;


----------------------------
#include<sys/syslog.h>
----------------------------

OLD output:

1;

NEW output:

require 'sys/syslog.ph';
1;




#------------Patches against 5.001m follow---------------------#


*** h2ph.SH_orig Wed Nov 8 14:40:37 1995
--- h2ph.SH Thu Nov 9 12:26:57 1995
***************
*** 121,127 ****
}
}
}
! elsif (/^include\s+<(.*)>/) {
($incl = $1) =~ s/\.h$/.ph/;
print OUT $t,"require '$incl';\n";
}
--- 121,127 ----
}
}
}
! elsif (/^include\s*<(.*)>/) {
($incl = $1) =~ s/\.h$/.ph/;
print OUT $t,"require '$incl';\n";
}
***************
*** 187,193 ****
}
next;
};
! s/^sizeof\s*\(([^)]+)\)/{$1}/ && do {
$new .= '$sizeof';
next;
};
--- 187,193 ----
}
next;
};
! s/^sizeof\s*\(([^)]+\))\)/{$1}/ && do {
$new .= '$sizeof';
next;
};
***************
*** 228,240 ****
else {
if ($inif && $new !~ /defined\($/) {
$new .= '(defined(&' . $id . ') ? &' . $id . ' : 0)';
! } else {
$new .= ' &' . $id;
}
}
next;
};
! s/^(.)// && do {$new .= $1; next;};
}
}
##############################################################################
--- 228,244 ----
else {
if ($inif && $new !~ /defined\($/) {
$new .= '(defined(&' . $id . ') ? &' . $id . ' : 0)';
! }
! elsif (/^\[/) {
! $new .= ' $' . $id;
! }
! else {
$new .= ' &' . $id;
}
}
next;
};
! s/^(.)// && do { if ($1 ne '#') { $new .= $1; } next;};
}
}
##############################################################################

--
#include <disclaimer.h>
/* richard_england@mentorg.com, DES/CE, Mentor Graphics Corp. */
/* WYGIWYG 503.685.7000 x1240 */