| 1 |
Allow the quote mark delimiter also for those #include directives chased with
|
| 2 |
"h2ph -a". Debian bug #479762.
|
| 3 |
|
| 4 |
Also add the directory prefix of the current file when the quote syntax is
|
| 5 |
used; 'require' will only look in @INC, not the current directory.
|
| 6 |
|
| 7 |
Upstream change 33835.
|
| 8 |
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
|
| 9 |
index 0bfea18..a3ff285 100644
|
| 10 |
--- a/utils/h2ph.PL
|
| 11 |
+++ b/utils/h2ph.PL
|
| 12 |
@@ -85,7 +85,7 @@ sub reindent($) {
|
| 13 |
}
|
| 14 |
|
| 15 |
my ($t, $tab, %curargs, $new, $eval_index, $dir, $name, $args, $outfile);
|
| 16 |
-my ($incl, $incl_type, $next);
|
| 17 |
+my ($incl, $incl_type, $incl_quote, $next);
|
| 18 |
while (defined (my $file = next_file())) {
|
| 19 |
if (-l $file and -d $file) {
|
| 20 |
link_if_possible($file) if ($opt_l);
|
| 21 |
@@ -186,9 +186,10 @@ while (defined (my $file = next_file())) {
|
| 22 |
print OUT $t,"unless(defined(\&$name)) {\n sub $name () {\t",$new,";}\n}\n";
|
| 23 |
}
|
| 24 |
}
|
| 25 |
- } elsif (/^(include|import|include_next)\s*[<\"](.*)[>\"]/) {
|
| 26 |
+ } elsif (/^(include|import|include_next)\s*([<\"])(.*)[>\"]/) {
|
| 27 |
$incl_type = $1;
|
| 28 |
- $incl = $2;
|
| 29 |
+ $incl_quote = $2;
|
| 30 |
+ $incl = $3;
|
| 31 |
if (($incl_type eq 'include_next') ||
|
| 32 |
($opt_e && exists($bad_file{$incl}))) {
|
| 33 |
$incl =~ s/\.h$/.ph/;
|
| 34 |
@@ -221,6 +222,10 @@ while (defined (my $file = next_file())) {
|
| 35 |
"warn(\$\@) if \$\@;\n");
|
| 36 |
} else {
|
| 37 |
$incl =~ s/\.h$/.ph/;
|
| 38 |
+ # copy the prefix in the quote syntax (#include "x.h") case
|
| 39 |
+ if ($incl !~ m|/| && $incl_quote eq q{"} && $file =~ m|^(.*)/|) {
|
| 40 |
+ $incl = "$1/$incl";
|
| 41 |
+ }
|
| 42 |
print OUT $t,"require '$incl';\n";
|
| 43 |
}
|
| 44 |
} elsif (/^ifdef\s+(\w+)/) {
|
| 45 |
@@ -724,8 +729,13 @@ sub queue_includes_from
|
| 46 |
$line .= <HEADER>;
|
| 47 |
}
|
| 48 |
|
| 49 |
- if ($line =~ /^#\s*include\s+<(.*?)>/) {
|
| 50 |
- push(@ARGV, $1) unless $Is_converted{$1};
|
| 51 |
+ if ($line =~ /^#\s*include\s+([<"])(.*?)[>"]/) {
|
| 52 |
+ my ($delimiter, $new_file) = ($1, $2);
|
| 53 |
+ # copy the prefix in the quote syntax (#include "x.h") case
|
| 54 |
+ if ($delimiter eq q{"} && $file =~ m|^(.*)/|) {
|
| 55 |
+ $new_file = "$1/$new_file";
|
| 56 |
+ }
|
| 57 |
+ push(@ARGV, $new_file) unless $Is_converted{$new_file};
|
| 58 |
}
|
| 59 |
}
|
| 60 |
close HEADER;
|