From: Nick Ing-Simmons Date: Mon, 16 Dec 1996 21:53:56 +0000 (+0000) Subject: xsubpp patch to add #line X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1f0c0aa312112c4a139416a2dda63880ddd621a;p=p5sagit%2Fp5-mst-13.2.git xsubpp patch to add #line Here is revised xsubpp patch that adds #line directives so that compile errors are directed at .xs file. (Relative to 5.003_11) p5p-msgid: <199612162153.VAA03590@ni-s.u-net.com> --- diff --git a/lib/ExtUtils/xsubpp b/lib/ExtUtils/xsubpp index 70796bd..d43eb1c 100755 --- a/lib/ExtUtils/xsubpp +++ b/lib/ExtUtils/xsubpp @@ -169,6 +169,7 @@ foreach $typemap (@tm) { $current = \$junk; while () { next if /^\s*#/; + my $line_no = $. + 1; if (/^INPUT\s*$/) { $mode = 'Input'; $current = \$junk; next; } if (/^OUTPUT\s*$/) { $mode = 'Output'; $current = \$junk; next; } if (/^TYPEMAP\s*$/) { $mode = 'Typemap'; $current = \$junk; next; } @@ -228,8 +229,10 @@ sub check_keyword { sub print_section { + my $count = 0; $_ = shift(@line) while !/\S/ && @line; for (; defined($_) && !/^$BLOCK_re/o; $_ = shift(@line)) { + print line_directive() unless ($count++); print "$_\n"; } } @@ -241,6 +244,7 @@ sub process_keyword($) &{"${kwd}_handler"}() while $kwd = check_keyword($pattern) ; + print line_directive(); } sub CASE_handler { @@ -317,6 +321,7 @@ sub OUTPUT_handler { unless defined($args_match{$outarg}); blurt("Error: No input definition for OUTPUT argument '$outarg' - ignored"), next unless defined $var_types{$outarg} ; + print line_directive(); if ($outcode) { print "\t$outcode\n"; } else { @@ -634,7 +639,7 @@ print <) { last if ($Module, $Package, $Prefix) = @@ -646,7 +651,6 @@ while (<$FH>) { $lastline = $_; $lastline_no = $.; - # Read next xsub into @line from ($lastline, <$FH>). sub fetch_para { # parse paragraph @@ -772,7 +776,7 @@ while (fetch_para()) { if (check_keyword("BOOT")) { &check_cpp; - push (@BootCode, $_, @line, "") ; + push (@BootCode, $_, line_directive(), @line, "") ; next PARAGRAPH ; } @@ -984,6 +988,7 @@ EOF } elsif ($gotRETVAL || $wantRETVAL) { &generate_output($ret_type, 0, 'RETVAL'); } + print line_directive(); # do cleanup process_keyword("CLEANUP|ALIAS|PROTOTYPE") ; @@ -1136,6 +1141,15 @@ sub output_init { eval qq/print " $init\\\n"/; } +sub line_directive +{ + # work out the line number + my $line_no = $line_no[@line_no - @line -1] ; + + return "#line $line_no \"$filename\"\n" ; + +} + sub Warn { # work out the line number