5 xsubpp - compiler to convert Perl XS code into C code
9 B<xsubpp> [B<-v>] [B<-C++>] [B<-except>] [B<-s pattern>] [B<-prototypes>] [B<-noversioncheck>] [B<-nolinenumbers>] [B<-nooptimize>] [B<-typemap typemap>] ... file.xs
13 This compiler is typically run by the makefiles created by L<ExtUtils::MakeMaker>.
15 I<xsubpp> will compile XS code into C code by embedding the constructs
16 necessary to let C functions manipulate Perl values and creates the glue
17 necessary to let Perl access those functions. The compiler uses typemaps to
18 determine how to map C function parameters and variables to Perl values.
20 The compiler will search for typemap files called I<typemap>. It will use
21 the following search path to find default typemaps, with the rightmost
22 typemap taking precedence.
24 ../../../typemap:../../typemap:../typemap:typemap
28 Note that the C<XSOPT> MakeMaker option may be used to add these options to
29 any makefiles generated by MakeMaker.
35 Adds ``extern "C"'' to the C code.
39 Adds exception handling stubs to the C code.
41 =item B<-typemap typemap>
43 Indicates that a user-supplied typemap should take precedence over the
44 default typemaps. This option may be used multiple times, with the last
45 typemap having the highest precedence.
49 Prints the I<xsubpp> version number to standard output, then exits.
53 By default I<xsubpp> will not automatically generate prototype code for
54 all xsubs. This flag will enable prototypes.
56 =item B<-noversioncheck>
58 Disables the run time test that determines if the object file (derived
59 from the C<.xs> file) and the C<.pm> files have the same version
62 =item B<-nolinenumbers>
64 Prevents the inclusion of `#line' directives in the output.
68 Disables certain optimizations. The only optimization that is currently
69 affected is the use of I<target>s by the output C code (see L<perlguts>).
70 This may significantly slow down the generated code, but this is the way
71 B<xsubpp> of 5.005 and earlier operated.
75 Disable recognition of C<IN>, C<OUT_LIST> and C<INOUT_LIST> declarations.
79 Disable recognition of ANSI-like descriptions of function signature.
85 No environment variables are used.
91 =head1 MODIFICATION HISTORY
93 See the file F<changes.pod>.
97 perl(1), perlxs(1), perlxstut(1)
103 use vars '$cplusplus';
112 $XSUBPP_version = "1.9508";
114 my ($Is_VMS, $SymSet);
117 # Establish set of global symbols with max length 28, since xsubpp
118 # will later add the 'XS_' prefix.
119 require ExtUtils::XSSymSet;
120 $SymSet = new ExtUtils::XSSymSet 28;
125 $usage = "Usage: xsubpp [-v] [-C++] [-except] [-prototypes] [-noversioncheck] [-nolinenumbers] [-nooptimize] [-noinout] [-noargtypes] [-s pattern] [-typemap typemap]... file.xs\n";
127 $proto_re = "[" . quotemeta('\$%&*@;') . "]" ;
130 $WantPrototypes = -1 ;
131 $WantVersionChk = 1 ;
133 $WantLineNumbers = 1 ;
136 my $process_inout = 1;
137 my $process_argtypes = 1;
139 SWITCH: while (@ARGV and $ARGV[0] =~ /^-./) {
142 $spat = quotemeta shift, next SWITCH if $flag eq 's';
143 $cplusplus = 1, next SWITCH if $flag eq 'C++';
144 $WantPrototypes = 0, next SWITCH if $flag eq 'noprototypes';
145 $WantPrototypes = 1, next SWITCH if $flag eq 'prototypes';
146 $WantVersionChk = 0, next SWITCH if $flag eq 'noversioncheck';
147 $WantVersionChk = 1, next SWITCH if $flag eq 'versioncheck';
148 # XXX left this in for compat
149 next SWITCH if $flag eq 'object_capi';
150 $except = " TRY", next SWITCH if $flag eq 'except';
151 push(@tm,shift), next SWITCH if $flag eq 'typemap';
152 $WantLineNumbers = 0, next SWITCH if $flag eq 'nolinenumbers';
153 $WantLineNumbers = 1, next SWITCH if $flag eq 'linenumbers';
154 $WantOptimize = 0, next SWITCH if $flag eq 'nooptimize';
155 $WantOptimize = 1, next SWITCH if $flag eq 'optimize';
156 $process_inout = 0, next SWITCH if $flag eq 'noinout';
157 $process_inout = 1, next SWITCH if $flag eq 'inout';
158 $process_argtypes = 0, next SWITCH if $flag eq 'noargtypes';
159 $process_argtypes = 1, next SWITCH if $flag eq 'argtypes';
160 (print "xsubpp version $XSUBPP_version\n"), exit
164 if ($WantPrototypes == -1)
165 { $WantPrototypes = 0}
170 @ARGV == 1 or die $usage;
171 ($dir, $filename) = $ARGV[0] =~ m#(.*)/(.*)#
172 or ($dir, $filename) = $ARGV[0] =~ m#(.*)\\(.*)#
173 or ($dir, $filename) = $ARGV[0] =~ m#(.*[>\]])(.*)#
174 or ($dir, $filename) = ('.', $ARGV[0]);
178 ++ $IncludedFiles{$ARGV[0]} ;
180 my(@XSStack) = ({type => 'none'}); # Stack of conditionals and INCLUDEs
181 my($XSS_work_idx, $cpp_next_tmp) = (0, "XSubPPtmpAAAA");
186 $_[0] =~ s/^\s+|\s+$//go ;
193 # rationalise any '*' by joining them into bunches and removing whitespace
197 # change multiple whitespace into a single space
200 # trim leading & trailing whitespace
206 $typemap = shift @ARGV;
207 foreach $typemap (@tm) {
208 die "Can't find $typemap in $pwd\n" unless -r $typemap;
210 unshift @tm, qw(../../../../lib/ExtUtils/typemap ../../../lib/ExtUtils/typemap
211 ../../lib/ExtUtils/typemap ../../../typemap ../../typemap
213 foreach $typemap (@tm) {
214 next unless -e $typemap ;
215 # skip directories, binary files etc.
216 warn("Warning: ignoring non-text typemap file '$typemap'\n"), next
218 open(TYPEMAP, $typemap)
219 or warn ("Warning: could not open typemap file '$typemap': $!\n"), next;
225 my $line_no = $. + 1;
226 if (/^INPUT\s*$/) { $mode = 'Input'; $current = \$junk; next; }
227 if (/^OUTPUT\s*$/) { $mode = 'Output'; $current = \$junk; next; }
228 if (/^TYPEMAP\s*$/) { $mode = 'Typemap'; $current = \$junk; next; }
229 if ($mode eq 'Typemap') {
233 # skip blank lines and comment lines
234 next if /^$/ or /^#/ ;
235 my($type,$kind, $proto) = /^\s*(.*?\S)\s+(\S+)\s*($proto_re*)\s*$/ or
236 warn("Warning: File '$typemap' Line $. '$line' TYPEMAP entry needs 2 or 3 columns\n"), next;
237 $type = TidyType($type) ;
238 $type_kind{$type} = $kind ;
239 # prototype defaults to '$'
240 $proto = "\$" unless $proto ;
241 warn("Warning: File '$typemap' Line $. '$line' Invalid prototype '$proto'\n")
242 unless ValidProtoString($proto) ;
243 $proto_letter{$type} = C_string($proto) ;
248 elsif ($mode eq 'Input') {
250 $input_expr{$_} = '';
251 $current = \$input_expr{$_};
255 $output_expr{$_} = '';
256 $current = \$output_expr{$_};
262 foreach $key (keys %input_expr) {
263 $input_expr{$key} =~ s/\n+$//;
266 $bal = qr[(?:(?>[^()]+)|\((??{ $bal })\))*]; # ()-balanced
267 $cast = qr[(?:\(\s*SV\s*\*\s*\)\s*)?]; # Optional (SV*) cast
268 $size = qr[,\s* (??{ $bal }) ]x; # Third arg (to setpvn)
270 foreach $key (keys %output_expr) {
273 my ($t, $with_size, $arg, $sarg) =
274 ($output_expr{$key} =~
275 m[^ \s+ sv_set ( [iunp] ) v (n)? # Type, is_setpvn
276 \s* \( \s* $cast \$arg \s* ,
277 \s* ( (??{ $bal }) ) # Set from
278 ( (??{ $size }) )? # Possible sizeof set-from
281 $targetable{$key} = [$t, $with_size, $arg, $sarg] if $t;
284 $END = "!End!\n\n"; # "impossible" keyword (multiple newline)
286 # Match an XS keyword
287 $BLOCK_re= '\s*(' . join('|', qw(
288 REQUIRE BOOT CASE PREINIT INPUT INIT CODE PPCODE OUTPUT
289 CLEANUP ALIAS ATTRS PROTOTYPES PROTOTYPE VERSIONCHECK INCLUDE
290 SCOPE INTERFACE INTERFACE_MACRO C_ARGS POSTCALL
293 # Input: ($_, @line) == unparsed input.
294 # Output: ($_, @line) == (rest of line, following lines).
295 # Return: the matched keyword if found, otherwise 0
297 $_ = shift(@line) while !/\S/ && @line;
298 s/^(\s*)($_[0])\s*:\s*(?:#.*)?/$1/s && $2;
301 my ($C_group_rex, $C_arg);
302 # Group in C (no support for comments or literals)
303 $C_group_rex = qr/ [({\[]
304 (?: (?> [^()\[\]{}]+ ) | (??{ $C_group_rex }) )*
306 # Chunk in C without comma at toplevel (no comments):
307 $C_arg = qr/ (?: (?> [^()\[\]{},"']+ )
308 | (??{ $C_group_rex })
309 | " (?: (?> [^\\"]+ )
311 )* " # String literal
312 | ' (?: (?> [^\\']+ ) | \\. )* ' # Char literal
315 if ($WantLineNumbers) {
317 package xsubpp::counter;
319 my ($class, $cfile) = @_;
321 $SECTION_END_MARKER = "#line --- \"$cfile\"";
330 while ($$self =~ s/^([^\n]*\n)//) {
333 $line =~ s|^\#line\s+---(?=\s)|#line $line_no|;
342 $self->PRINT(sprintf($fmt, @_));
346 # Not necessary if we're careful to end with a "\n"
352 my $cfile = $filename;
353 $cfile =~ s/\.xs$/.c/i or $cfile .= ".c";
354 tie(*PSEUDO_STDOUT, 'xsubpp::counter', $cfile);
355 select PSEUDO_STDOUT;
359 # the "do" is required for right semantics
360 do { $_ = shift(@line) } while !/\S/ && @line;
362 print("#line ", $line_no[@line_no - @line -1], " \"$filename\"\n")
363 if $WantLineNumbers && !/^\s*#\s*line\b/ && !/^#if XSubPPtmp/;
364 for (; defined($_) && !/^$BLOCK_re/o; $_ = shift(@line)) {
367 print "$xsubpp::counter::SECTION_END_MARKER\n" if $WantLineNumbers;
373 while (!/\S/ && @line) {
377 for (; defined($_) && !/^$BLOCK_re/o; $_ = shift(@line)) {
384 sub process_keyword($)
389 &{"${kwd}_handler"}()
390 while $kwd = check_keyword($pattern) ;
394 blurt ("Error: `CASE:' after unconditional `CASE:'")
395 if $condnum && $cond eq '';
397 TrimWhitespace($cond);
398 print " ", ($condnum++ ? " else" : ""), ($cond ? " if ($cond)\n" : "\n");
403 for (; !/^$BLOCK_re/o; $_ = shift(@line)) {
404 last if /^\s*NOT_IMPLEMENTED_YET/;
405 next unless /\S/; # skip blank lines
410 # remove trailing semicolon if no initialisation
411 s/\s*;$//g unless /[=;+].*\S/ ;
413 # check for optional initialisation code
415 $var_init = $1 if s/\s*([=;+].*)$//s ;
416 $var_init =~ s/"/\\"/g;
419 my ($var_type, $var_addr, $var_name) = /^(.*?[^&\s])\s*(\&?)\s*\b(\w+)$/s
420 or blurt("Error: invalid argument declaration '$line'"), next;
422 # Check for duplicate definitions
423 blurt ("Error: duplicate definition of argument '$var_name' ignored"), next
424 if $arg_list{$var_name}++
425 or defined $arg_types{$var_name} and not $processing_arg_with_types;
427 $thisdone |= $var_name eq "THIS";
428 $retvaldone |= $var_name eq "RETVAL";
429 $var_types{$var_name} = $var_type;
430 # XXXX This check is a safeguard against the unfinished conversion of
431 # generate_init(). When generate_init() is fixed,
432 # one can use 2-args map_type() unconditionally.
433 if ($var_type =~ / \( \s* \* \s* \) /x) {
434 # Function pointers are not yet supported with &output_init!
435 print "\t" . &map_type($var_type, $var_name);
438 print "\t" . &map_type($var_type);
441 $var_num = $args_match{$var_name};
443 $proto_arg[$var_num] = ProtoString($var_type)
445 $func_args =~ s/\b($var_name)\b/&$1/ if $var_addr;
446 if ($var_init =~ /^[=;]\s*NO_INIT\s*;?\s*$/
447 or $in_out{$var_name} and $in_out{$var_name} =~ /^OUT/
448 and $var_init !~ /\S/) {
452 print "\t$var_name;\n";
454 } elsif ($var_init =~ /\S/) {
455 &output_init($var_type, $var_num, $var_name, $var_init, $name_printed);
457 # generate initialization code
458 &generate_init($var_type, $var_num, $var_name, $name_printed);
466 for (; !/^$BLOCK_re/o; $_ = shift(@line)) {
468 if (/^\s*SETMAGIC\s*:\s*(ENABLE|DISABLE)\s*/) {
469 $DoSetMagic = ($1 eq "ENABLE" ? 1 : 0);
472 my ($outarg, $outcode) = /^\s*(\S+)\s*(.*?)\s*$/s ;
473 blurt ("Error: duplicate OUTPUT argument '$outarg' ignored"), next
474 if $outargs{$outarg} ++ ;
475 if (!$gotRETVAL and $outarg eq 'RETVAL') {
476 # deal with RETVAL last
477 $RETVAL_code = $outcode ;
481 blurt ("Error: OUTPUT $outarg not an argument"), next
482 unless defined($args_match{$outarg});
483 blurt("Error: No input definition for OUTPUT argument '$outarg' - ignored"), next
484 unless defined $var_types{$outarg} ;
485 $var_num = $args_match{$outarg};
487 print "\t$outcode\n";
488 print "\tSvSETMAGIC(ST(" , $var_num-1 , "));\n" if $DoSetMagic;
490 &generate_output($var_types{$outarg}, $var_num, $outarg, $DoSetMagic);
492 delete $in_out{$outarg} # No need to auto-OUTPUT
493 if exists $in_out{$outarg} and $in_out{$outarg} =~ /OUT$/;
497 sub C_ARGS_handler() {
498 my $in = merge_section();
504 sub INTERFACE_MACRO_handler() {
505 my $in = merge_section();
508 if ($in =~ /\s/) { # two
509 ($interface_macro, $interface_macro_set) = split ' ', $in;
511 $interface_macro = $in;
512 $interface_macro_set = 'UNKNOWN_CVT'; # catch later
514 $interface = 1; # local
515 $Interfaces = 1; # global
518 sub INTERFACE_handler() {
519 my $in = merge_section();
523 foreach (split /[\s,]+/, $in) {
524 $Interfaces{$_} = $_;
527 # XSFUNCTION = $interface_macro($ret_type,cv,XSANY.any_dptr);
529 $interface = 1; # local
530 $Interfaces = 1; # global
533 sub CLEANUP_handler() { print_section() }
534 sub PREINIT_handler() { print_section() }
535 sub POSTCALL_handler() { print_section() }
536 sub INIT_handler() { print_section() }
545 # Parse alias definitions
547 # alias = value alias = value ...
549 while ($line =~ s/^\s*([\w:]+)\s*=\s*(\w+)\s*//) {
551 $orig_alias = $alias ;
554 # check for optional package definition in the alias
555 $alias = $Packprefix . $alias if $alias !~ /::/ ;
557 # check for duplicate alias name & duplicate value
558 Warn("Warning: Ignoring duplicate alias '$orig_alias'")
559 if defined $XsubAliases{$alias} ;
561 Warn("Warning: Aliases '$orig_alias' and '$XsubAliasValues{$value}' have identical values")
562 if $XsubAliasValues{$value} ;
565 $XsubAliases{$alias} = $value ;
566 $XsubAliasValues{$value} = $orig_alias ;
569 blurt("Error: Cannot parse ALIAS definitions from '$orig'")
575 for (; !/^$BLOCK_re/o; $_ = shift(@line)) {
578 push @Attributes, $_;
584 for (; !/^$BLOCK_re/o; $_ = shift(@line)) {
587 GetAliases($_) if $_ ;
591 sub REQUIRE_handler ()
593 # the rest of the current line should contain a version number
596 TrimWhitespace($Ver) ;
598 death ("Error: REQUIRE expects a version number")
601 # check that the version number is of the form n.n
602 death ("Error: REQUIRE: expected a number, got '$Ver'")
603 unless $Ver =~ /^\d+(\.\d*)?/ ;
605 death ("Error: xsubpp $Ver (or better) required--this is only $XSUBPP_version.")
606 unless $XSUBPP_version >= $Ver ;
609 sub VERSIONCHECK_handler ()
611 # the rest of the current line should contain either ENABLE or
616 # check for ENABLE/DISABLE
617 death ("Error: VERSIONCHECK: ENABLE/DISABLE")
618 unless /^(ENABLE|DISABLE)/i ;
620 $WantVersionChk = 1 if $1 eq 'ENABLE' ;
621 $WantVersionChk = 0 if $1 eq 'DISABLE' ;
625 sub PROTOTYPE_handler ()
629 death("Error: Only 1 PROTOTYPE definition allowed per xsub")
630 if $proto_in_this_xsub ++ ;
632 for (; !/^$BLOCK_re/o; $_ = shift(@line)) {
636 if ($_ eq 'DISABLE') {
639 elsif ($_ eq 'ENABLE') {
643 # remove any whitespace
645 death("Error: Invalid prototype '$_'")
646 unless ValidProtoString($_) ;
647 $ProtoThisXSUB = C_string($_) ;
651 # If no prototype specified, then assume empty prototype ""
652 $ProtoThisXSUB = 2 unless $specified ;
660 death("Error: Only 1 SCOPE declaration allowed per xsub")
661 if $scope_in_this_xsub ++ ;
663 for (; !/^$BLOCK_re/o; $_ = shift(@line)) {
666 if ($_ =~ /^DISABLE/i) {
669 elsif ($_ =~ /^ENABLE/i) {
676 sub PROTOTYPES_handler ()
678 # the rest of the current line should contain either ENABLE or
683 # check for ENABLE/DISABLE
684 death ("Error: PROTOTYPES: ENABLE/DISABLE")
685 unless /^(ENABLE|DISABLE)/i ;
687 $WantPrototypes = 1 if $1 eq 'ENABLE' ;
688 $WantPrototypes = 0 if $1 eq 'DISABLE' ;
693 sub INCLUDE_handler ()
695 # the rest of the current line should contain a valid filename
699 death("INCLUDE: filename missing")
702 death("INCLUDE: output pipe is illegal")
705 # simple minded recursion detector
706 death("INCLUDE loop detected")
707 if $IncludedFiles{$_} ;
709 ++ $IncludedFiles{$_} unless /\|\s*$/ ;
711 # Save the current file context.
714 LastLine => $lastline,
715 LastLineNo => $lastline_no,
718 Filename => $filename,
725 open ($FH, "$_") or death("Cannot open '$_': $!") ;
729 #/* INCLUDE: Including '$_' from '$filename' */
735 # Prime the pump by reading the first
738 # skip leading blank lines
740 last unless /^\s*$/ ;
750 return 0 unless $XSStack[-1]{type} eq 'file' ;
752 my $data = pop @XSStack ;
753 my $ThisFile = $filename ;
754 my $isPipe = ($filename =~ /\|\s*$/) ;
756 -- $IncludedFiles{$filename}
761 $FH = $data->{Handle} ;
762 $filename = $data->{Filename} ;
763 $lastline = $data->{LastLine} ;
764 $lastline_no = $data->{LastLineNo} ;
765 @line = @{ $data->{Line} } ;
766 @line_no = @{ $data->{LineNo} } ;
768 if ($isPipe and $? ) {
770 print STDERR "Error reading from pipe '$ThisFile': $! in $filename, line $lastline_no\n" ;
776 #/* INCLUDE: Returning to '$filename' from '$ThisFile' */
783 sub ValidProtoString ($)
787 if ( $string =~ /^$proto_re+$/ ) {
798 $string =~ s[\\][\\\\]g ;
806 $proto_letter{$type} or "\$" ;
810 my @cpp = grep(/^\#\s*(?:if|e\w+)/, @line);
812 my ($cpp, $cpplevel);
814 if ($cpp =~ /^\#\s*if/) {
816 } elsif (!$cpplevel) {
817 Warn("Warning: #else/elif/endif without #if in this function");
818 print STDERR " (precede it with a blank line if the matching #if is outside the function)\n"
819 if $XSStack[-1]{type} eq 'if';
821 } elsif ($cpp =~ /^\#\s*endif/) {
825 Warn("Warning: #if without #endif in this function") if $cpplevel;
838 open($FH, $filename) or die "cannot open $filename: $!\n";
840 # Identify the version of xsubpp used
843 * This file was generated automatically by xsubpp version $XSUBPP_version from the
844 * contents of $filename. Do not edit this file, edit $filename instead.
846 * ANY CHANGES MADE HERE WILL BE LOST!
853 print("#line 1 \"$filename\"\n")
859 my $podstartline = $.;
862 print("/* Skipped embedded POD. */\n");
863 printf("#line %d \"$filename\"\n", $. + 1)
869 # At this point $. is at end of file so die won't state the start
870 # of the problem, and as we haven't yet read any lines &death won't
871 # show the correct line in the message either.
872 die ("Error: Unterminated pod in $filename, line $podstartline\n")
875 last if ($Module, $Package, $Prefix) =
876 /^MODULE\s*=\s*([\w:]+)(?:\s+PACKAGE\s*=\s*([\w:]+))?(?:\s+PREFIX\s*=\s*(\S+))?\s*$/;
880 &Exit unless defined $_;
882 print "$xsubpp::counter::SECTION_END_MARKER\n" if $WantLineNumbers;
887 # Read next xsub into @line from ($lastline, <$FH>).
890 death ("Error: Unterminated `#if/#ifdef/#ifndef'")
891 if !defined $lastline && $XSStack[-1]{type} eq 'if';
894 return PopFile() if !defined $lastline;
897 /^MODULE\s*=\s*([\w:]+)(?:\s+PACKAGE\s*=\s*([\w:]+))?(?:\s+PREFIX\s*=\s*(\S+))?\s*$/) {
899 $Package = defined($2) ? $2 : ''; # keep -w happy
900 $Prefix = defined($3) ? $3 : ''; # keep -w happy
901 $Prefix = quotemeta $Prefix ;
902 ($Module_cname = $Module) =~ s/\W/_/g;
903 ($Packid = $Package) =~ tr/:/_/;
904 $Packprefix = $Package;
905 $Packprefix .= "::" if $Packprefix ne "";
911 while ($lastline =~ /^=/) {
912 while ($lastline = <$FH>) {
913 last if ($lastline =~ /^=cut\s*$/);
915 death ("Error: Unterminated pod") unless $lastline;
918 $lastline =~ s/^\s+$//;
920 if ($lastline !~ /^\s*#/ ||
922 # ANSI: if ifdef ifndef elif else endif define undef
924 # gcc: warning include_next
926 # others: ident (gcc notes that some cpps have this one)
927 $lastline =~ /^#[ \t]*(?:(?:if|ifn?def|elif|else|endif|define|undef|pragma|error|warning|line\s+\d+|ident)\b|(?:include(?:_next)?|import)\s*["<].*[>"])/) {
928 last if $lastline =~ /^\S/ && @line && $line[-1] eq "";
929 push(@line, $lastline);
930 push(@line_no, $lastline_no) ;
933 # Read next line and continuation lines
934 last unless defined($lastline = <$FH>);
937 $lastline .= $tmp_line
938 while ($lastline =~ /\\$/ && defined($tmp_line = <$FH>));
941 $lastline =~ s/^\s+$//;
943 pop(@line), pop(@line_no) while @line && $line[-1] eq "";
948 while (fetch_para()) {
949 # Print initial preprocessor statements and blank lines
950 while (@line && $line[0] !~ /^[^\#]/) {
951 my $line = shift(@line);
953 next unless $line =~ /^\#\s*((if)(?:n?def)?|elsif|else|endif)\b/;
955 if ($statement eq 'if') {
956 $XSS_work_idx = @XSStack;
957 push(@XSStack, {type => 'if'});
959 death ("Error: `$statement' with no matching `if'")
960 if $XSStack[-1]{type} ne 'if';
961 if ($XSStack[-1]{varname}) {
962 push(@InitFileCode, "#endif\n");
963 push(@BootCode, "#endif");
966 my(@fns) = keys %{$XSStack[-1]{functions}};
967 if ($statement ne 'endif') {
968 # Hide the functions defined in other #if branches, and reset.
969 @{$XSStack[-1]{other_functions}}{@fns} = (1) x @fns;
970 @{$XSStack[-1]}{qw(varname functions)} = ('', {});
972 my($tmp) = pop(@XSStack);
973 0 while (--$XSS_work_idx
974 && $XSStack[$XSS_work_idx]{type} ne 'if');
975 # Keep all new defined functions
976 push(@fns, keys %{$tmp->{other_functions}});
977 @{$XSStack[$XSS_work_idx]{functions}}{@fns} = (1) x @fns;
982 next PARAGRAPH unless @line;
984 if ($XSS_work_idx && !$XSStack[$XSS_work_idx]{varname}) {
985 # We are inside an #if, but have not yet #defined its xsubpp variable.
986 print "#define $cpp_next_tmp 1\n\n";
987 push(@InitFileCode, "#if $cpp_next_tmp\n");
988 push(@BootCode, "#if $cpp_next_tmp");
989 $XSStack[$XSS_work_idx]{varname} = $cpp_next_tmp++;
992 death ("Code is not inside a function"
993 ." (maybe last function was ended by a blank line "
994 ." followed by a statement on column one?)")
995 if $line[0] =~ /^\s/;
997 # initialize info arrays
1004 undef($wantRETVAL) ;
1005 undef($RETVAL_no_return) ;
1008 undef(@arg_with_types) ;
1009 undef($processing_arg_with_types) ;
1013 undef($proto_in_this_xsub) ;
1014 undef($scope_in_this_xsub) ;
1016 undef($prepush_done);
1017 $interface_macro = 'XSINTERFACE_FUNC' ;
1018 $interface_macro_set = 'XSINTERFACE_FUNC_SET' ;
1019 $ProtoThisXSUB = $WantPrototypes ;
1024 while ($kwd = check_keyword("REQUIRE|PROTOTYPES|VERSIONCHECK|INCLUDE")) {
1025 &{"${kwd}_handler"}() ;
1026 next PARAGRAPH unless @line ;
1030 if (check_keyword("BOOT")) {
1032 push (@BootCode, "#line $line_no[@line_no - @line] \"$filename\"")
1033 if $WantLineNumbers && $line[0] !~ /^\s*#\s*line\b/;
1034 push (@BootCode, @line, "") ;
1039 # extract return type, function name and arguments
1040 ($ret_type) = TidyType($_);
1041 $RETVAL_no_return = 1 if $ret_type =~ s/^NO_OUTPUT\s+//;
1043 # Allow one-line ANSI-like declaration
1045 if $process_argtypes
1046 and $ret_type =~ s/^(.*?\w.*?)\s*\b(\w+\s*\(.*)/$1/s;
1048 # a function definition needs at least 2 lines
1049 blurt ("Error: Function definition too short '$ret_type'"), next PARAGRAPH
1052 $static = 1 if $ret_type =~ s/^static\s+//;
1054 $func_header = shift(@line);
1055 blurt ("Error: Cannot parse function definition from '$func_header'"), next PARAGRAPH
1056 unless $func_header =~ /^(?:([\w:]*)::)?(\w+)\s*\(\s*(.*?)\s*\)\s*(const)?\s*(;\s*)?$/s;
1058 ($class, $func_name, $orig_args) = ($1, $2, $3) ;
1059 $class = "$4 $class" if $4;
1060 ($pname = $func_name) =~ s/^($Prefix)?/$Packprefix/;
1061 ($clean_func_name = $func_name) =~ s/^$Prefix//;
1062 $Full_func_name = "${Packid}_$clean_func_name";
1063 if ($Is_VMS) { $Full_func_name = $SymSet->addsym($Full_func_name); }
1065 # Check for duplicate function definition
1066 for $tmp (@XSStack) {
1067 next unless defined $tmp->{functions}{$Full_func_name};
1068 Warn("Warning: duplicate function definition '$clean_func_name' detected");
1071 $XSStack[$XSS_work_idx]{functions}{$Full_func_name} ++ ;
1072 %XsubAliases = %XsubAliasValues = %Interfaces = @Attributes = ();
1075 $orig_args =~ s/\\\s*/ /g; # process line continuations
1078 if ($process_argtypes and $orig_args =~ /\S/) {
1079 my $args = "$orig_args ,";
1080 if ($args =~ /^( (??{ $C_arg }) , )* $ /x) {
1081 @args = ($args =~ /\G ( (??{ $C_arg }) ) , /xg);
1087 ($arg, $default) = / ( [^=]* ) ( (?: = .* )? ) /x;
1088 my ($pre, $name) = ($arg =~ /(.*?) \s* \b(\w+) \s* $ /x);
1089 next unless length $pre;
1092 if ($process_inout and s/^(IN|IN_OUTLIST|OUTLIST|OUT|IN_OUT)\s+//) {
1094 $out_type = $type if $type ne 'IN';
1095 $arg =~ s/^(IN|IN_OUTLIST|OUTLIST|OUT|IN_OUT)\s+//;
1097 if (/\W/) { # Has a type
1098 push @arg_with_types, $arg;
1099 # warn "pushing '$arg'\n";
1100 $arg_types{$name} = $arg;
1101 $_ = "$name$default";
1103 $only_outlist{$_} = 1 if $out_type eq "OUTLIST";
1104 push @outlist, $name if $out_type =~ /OUTLIST$/;
1105 $in_out{$name} = $out_type if $out_type;
1108 @args = split(/\s*,\s*/, $orig_args);
1109 Warn("Warning: cannot parse argument list '$orig_args', fallback to split");
1112 @args = split(/\s*,\s*/, $orig_args);
1114 if ($process_inout and s/^(IN|IN_OUTLIST|OUTLIST|IN_OUT|OUT)\s+//) {
1116 next if $out_type eq 'IN';
1117 $only_outlist{$_} = 1 if $out_type eq "OUTLIST";
1118 push @outlist, $name if $out_type =~ /OUTLIST$/;
1119 $in_out{$_} = $out_type;
1123 if (defined($class)) {
1124 my $arg0 = ((defined($static) or $func_name eq 'new')
1125 ? "CLASS" : "THIS");
1126 unshift(@args, $arg0);
1127 ($report_args = "$arg0, $report_args") =~ s/^\w+, $/$arg0/;
1132 my $report_args = '';
1133 foreach $i (0 .. $#args) {
1134 if ($args[$i] =~ s/\.\.\.//) {
1136 if ($args[$i] eq '' && $i == $#args) {
1137 $report_args .= ", ...";
1142 if ($only_outlist{$args[$i]}) {
1143 push @args_num, undef;
1145 push @args_num, ++$num_args;
1146 $report_args .= ", $args[$i]";
1148 if ($args[$i] =~ /^([^=]*[^\s=])\s*=\s*(.*)/s) {
1151 $defaults{$args[$i]} = $2;
1152 $defaults{$args[$i]} =~ s/"/\\"/g;
1154 $proto_arg[$i+1] = "\$" ;
1156 $min_args = $num_args - $extra_args;
1157 $report_args =~ s/"/\\"/g;
1158 $report_args =~ s/^,\s+//;
1159 my @func_args = @args;
1160 shift @func_args if defined($class);
1163 s/^/&/ if $in_out{$_};
1165 $func_args = join(", ", @func_args);
1166 @args_match{@args} = @args_num;
1168 $PPCODE = grep(/^\s*PPCODE\s*:/, @line);
1169 $CODE = grep(/^\s*CODE\s*:/, @line);
1170 # Detect CODE: blocks which use ST(n)= or XST_m*(n,v)
1171 # to set explicit return values.
1172 $EXPLICIT_RETURN = ($CODE &&
1173 ("@line" =~ /(\bST\s*\([^;]*=) | (\bXST_m\w+\s*\()/x ));
1174 $ALIAS = grep(/^\s*ALIAS\s*:/, @line);
1175 $INTERFACE = grep(/^\s*INTERFACE\s*:/, @line);
1177 $xsreturn = 1 if $EXPLICIT_RETURN;
1179 # print function header
1181 #XS(XS_${Full_func_name}); /* prototype to pass -Wmissing-prototypes */
1182 #XS(XS_${Full_func_name})
1186 print Q<<"EOF" if $ALIAS ;
1189 print Q<<"EOF" if $INTERFACE ;
1190 # dXSFUNCTION($ret_type);
1193 $cond = ($min_args ? qq(items < $min_args) : 0);
1195 elsif ($min_args == $num_args) {
1196 $cond = qq(items != $min_args);
1199 $cond = qq(items < $min_args || items > $num_args);
1202 print Q<<"EOF" if $except;
1203 # char errbuf[1024];
1208 { print Q<<"EOF" if $cond }
1210 # Perl_croak(aTHX_ "Usage: %s($report_args)", GvNAME(CvGV(cv)));
1213 { print Q<<"EOF" if $cond }
1215 # Perl_croak(aTHX_ "Usage: $pname($report_args)");
1218 #gcc -Wall: if an xsub has no arguments and PPCODE is used
1219 #it is likely none of ST, XSRETURN or XSprePUSH macros are used
1220 #hence `ax' (setup by dXSARGS) is unused
1221 #XXX: could breakup the dXSARGS; into dSP;dMARK;dITEMS
1222 #but such a move could break third-party extensions
1223 print Q<<"EOF" if $PPCODE and $num_args == 0;
1224 # PERL_UNUSED_VAR(ax); /* -Wall */
1227 print Q<<"EOF" if $PPCODE;
1231 # Now do a block of some sort.
1234 $cond = ''; # last CASE: condidional
1235 push(@line, "$END:");
1236 push(@line_no, $line_no[-1]);
1240 &CASE_handler if check_keyword("CASE");
1245 # do initialization of input variables
1253 process_keyword("INPUT|PREINIT|INTERFACE_MACRO|C_ARGS|ALIAS|ATTRS|PROTOTYPE|SCOPE") ;
1255 print Q<<"EOF" if $ScopeThisXSUB;
1260 if (!$thisdone && defined($class)) {
1261 if (defined($static) or $func_name eq 'new') {
1263 $var_types{"CLASS"} = "char *";
1264 &generate_init("char *", 1, "CLASS");
1268 $var_types{"THIS"} = "$class *";
1269 &generate_init("$class *", 1, "THIS");
1274 if (/^\s*NOT_IMPLEMENTED_YET/) {
1275 print "\n\tPerl_croak(aTHX_ \"$pname: not implemented yet\");\n";
1278 if ($ret_type ne "void") {
1279 print "\t" . &map_type($ret_type, 'RETVAL') . ";\n"
1281 $args_match{"RETVAL"} = 0;
1282 $var_types{"RETVAL"} = $ret_type;
1283 print "\tdXSTARG;\n"
1284 if $WantOptimize and $targetable{$type_kind{$ret_type}};
1287 if (@arg_with_types) {
1288 unshift @line, @arg_with_types, $_;
1290 $processing_arg_with_types = 1;
1295 process_keyword("INIT|ALIAS|ATTRS|PROTOTYPE|INTERFACE_MACRO|INTERFACE|C_ARGS") ;
1297 if (check_keyword("PPCODE")) {
1299 death ("PPCODE must be last thing") if @line;
1300 print "\tLEAVE;\n" if $ScopeThisXSUB;
1301 print "\tPUTBACK;\n\treturn;\n";
1302 } elsif (check_keyword("CODE")) {
1304 } elsif (defined($class) and $func_name eq "DESTROY") {
1306 print "delete THIS;\n";
1309 if ($ret_type ne "void") {
1313 if (defined($static)) {
1314 if ($func_name eq 'new') {
1315 $func_name = "$class";
1319 } elsif (defined($class)) {
1320 if ($func_name eq 'new') {
1321 $func_name .= " $class";
1326 $func_name =~ s/^($spat)//
1328 $func_name = 'XSFUNCTION' if $interface;
1329 print "$func_name($func_args);\n";
1333 # do output variables
1334 $gotRETVAL = 0; # 1 if RETVAL seen in OUTPUT section;
1335 undef $RETVAL_code ; # code to set RETVAL (from OUTPUT section);
1336 # $wantRETVAL set if 'RETVAL =' autogenerated
1337 ($wantRETVAL, $ret_type) = (0, 'void') if $RETVAL_no_return;
1339 process_keyword("POSTCALL|OUTPUT|ALIAS|ATTRS|PROTOTYPE");
1341 &generate_output($var_types{$_}, $args_match{$_}, $_, $DoSetMagic)
1342 for grep $in_out{$_} =~ /OUT$/, keys %in_out;
1344 # all OUTPUT done, so now push the return value on the stack
1345 if ($gotRETVAL && $RETVAL_code) {
1346 print "\t$RETVAL_code\n";
1347 } elsif ($gotRETVAL || $wantRETVAL) {
1348 my $t = $WantOptimize && $targetable{$type_kind{$ret_type}};
1350 my $type = $ret_type;
1352 # 0: type, 1: with_size, 2: how, 3: how_size
1353 if ($t and not $t->[1] and $t->[0] eq 'p') {
1354 # PUSHp corresponds to setpvn. Treate setpv directly
1355 my $what = eval qq("$t->[2]");
1358 print "\tsv_setpv(TARG, $what); XSprePUSH; PUSHTARG;\n";
1362 my $what = eval qq("$t->[2]");
1366 $size = '' unless defined $size;
1367 $size = eval qq("$size");
1369 print "\tXSprePUSH; PUSH$t->[0]($what$size);\n";
1373 # RETVAL almost never needs SvSETMAGIC()
1374 &generate_output($ret_type, 0, 'RETVAL', 0);
1378 $xsreturn = 1 if $ret_type ne "void";
1379 my $num = $xsreturn;
1381 print "\tXSprePUSH;" if $c and not $prepush_done;
1382 print "\tEXTEND(SP,$c);\n" if $c;
1384 generate_output($var_types{$_}, $num++, $_, 0, 1) for @outlist;
1387 process_keyword("CLEANUP|ALIAS|ATTRS|PROTOTYPE") ;
1389 print Q<<"EOF" if $ScopeThisXSUB;
1392 print Q<<"EOF" if $ScopeThisXSUB and not $PPCODE;
1396 # print function trailer
1400 print Q<<EOF if $except;
1403 # sprintf(errbuf, "%s: %s\\tpropagated", Xname, Xreason);
1406 if (check_keyword("CASE")) {
1407 blurt ("Error: No `CASE:' at top of function")
1409 $_ = "CASE: $_"; # Restore CASE: label
1412 last if $_ eq "$END:";
1413 death(/^$BLOCK_re/o ? "Misplaced `$1:'" : "Junk at end of function");
1416 print Q<<EOF if $except;
1418 # Perl_croak(aTHX_ errbuf);
1422 print Q<<EOF unless $PPCODE;
1423 # XSRETURN($xsreturn);
1426 print Q<<EOF unless $PPCODE;
1436 my $newXS = "newXS" ;
1439 # Build the prototype string for the xsub
1440 if ($ProtoThisXSUB) {
1441 $newXS = "newXSproto";
1443 if ($ProtoThisXSUB eq 2) {
1444 # User has specified empty prototype
1447 elsif ($ProtoThisXSUB ne 1) {
1448 # User has specified a prototype
1449 $proto = ', "' . $ProtoThisXSUB . '"';
1453 if ($min_args < $num_args) {
1455 $proto_arg[$min_args] .= ";" ;
1457 push @proto_arg, "$s\@"
1460 $proto = ', "' . join ("", @proto_arg) . '"';
1465 $XsubAliases{$pname} = 0
1466 unless defined $XsubAliases{$pname} ;
1467 while ( ($name, $value) = each %XsubAliases) {
1468 push(@InitFileCode, Q<<"EOF");
1469 # cv = newXS(\"$name\", XS_$Full_func_name, file);
1470 # XSANY.any_i32 = $value ;
1472 push(@InitFileCode, Q<<"EOF") if $proto;
1473 # sv_setpv((SV*)cv$proto) ;
1477 elsif (@Attributes) {
1478 push(@InitFileCode, Q<<"EOF");
1479 # cv = newXS(\"$pname\", XS_$Full_func_name, file);
1480 # apply_attrs_string("$Package", cv, "@Attributes", 0);
1483 elsif ($interface) {
1484 while ( ($name, $value) = each %Interfaces) {
1485 $name = "$Package\::$name" unless $name =~ /::/;
1486 push(@InitFileCode, Q<<"EOF");
1487 # cv = newXS(\"$name\", XS_$Full_func_name, file);
1488 # $interface_macro_set(cv,$value) ;
1490 push(@InitFileCode, Q<<"EOF") if $proto;
1491 # sv_setpv((SV*)cv$proto) ;
1497 " ${newXS}(\"$pname\", XS_$Full_func_name, file$proto);\n");
1501 # print initialization routine
1510 #XS(boot_$Module_cname); /* prototype to pass -Wmissing-prototypes */
1511 #XS(boot_$Module_cname)
1519 #-Wall: if there is no $Full_func_name there are no xsubs in this .xs
1520 #so `file' is unused
1521 print Q<<"EOF" if $Full_func_name;
1522 # char* file = __FILE__;
1527 print Q<<"EOF" if $WantVersionChk ;
1528 # XS_VERSION_BOOTCHECK ;
1532 print Q<<"EOF" if defined $XsubAliases or defined $Interfaces ;
1538 print @InitFileCode;
1540 print Q<<"EOF" if defined $XsubAliases or defined $Interfaces ;
1546 print "\n /* Initialisation Section */\n\n" ;
1549 print "\n /* End of Initialisation Section */\n\n" ;
1558 warn("Please specify prototyping behavior for $filename (see perlxs manual)\n")
1563 local($type, $num, $var, $init, $name_printed) = @_;
1564 local($arg) = "ST(" . ($num - 1) . ")";
1566 if( $init =~ /^=/ ) {
1567 if ($name_printed) {
1568 eval qq/print " $init\\n"/;
1570 eval qq/print "\\t$var $init\\n"/;
1574 if( $init =~ s/^\+// && $num ) {
1575 &generate_init($type, $num, $var, $name_printed);
1576 } elsif ($name_printed) {
1580 eval qq/print "\\t$var;\\n"/;
1584 $deferred .= eval qq/"\\n\\t$init\\n"/;
1591 # work out the line number
1592 my $line_no = $line_no[@line_no - @line -1] ;
1594 print STDERR "@_ in $filename, line $line_no\n" ;
1610 local($type, $num, $var) = @_;
1611 local($arg) = "ST(" . ($num - 1) . ")";
1612 local($argoff) = $num - 1;
1616 $type = TidyType($type) ;
1617 blurt("Error: '$type' not in typemap"), return
1618 unless defined($type_kind{$type});
1620 ($ntype = $type) =~ s/\s*\*/Ptr/g;
1621 ($subtype = $ntype) =~ s/(?:Array)?(?:Ptr)?$//;
1622 $tk = $type_kind{$type};
1623 $tk =~ s/OBJ$/REF/ if $func_name =~ /DESTROY$/;
1625 blurt("Error: No INPUT definition for type '$type', typekind '$type_kind{$type}' found"), return
1626 unless defined $input_expr{$tk} ;
1627 $expr = $input_expr{$tk};
1628 if ($expr =~ /DO_ARRAY_ELEM/) {
1629 blurt("Error: '$subtype' not in typemap"), return
1630 unless defined($type_kind{$subtype});
1631 blurt("Error: No INPUT definition for type '$subtype', typekind '$type_kind{$subtype}' found"), return
1632 unless defined $input_expr{$type_kind{$subtype}} ;
1633 $subexpr = $input_expr{$type_kind{$subtype}};
1634 $subexpr =~ s/\$type/\$subtype/g;
1635 $subexpr =~ s/ntype/subtype/g;
1636 $subexpr =~ s/\$arg/ST(ix_$var)/g;
1637 $subexpr =~ s/\n\t/\n\t\t/g;
1638 $subexpr =~ s/is not of (.*\")/[arg %d] is not of $1, ix_$var + 1/g;
1639 $subexpr =~ s/\$var/${var}[ix_$var - $argoff]/;
1640 $expr =~ s/DO_ARRAY_ELEM/$subexpr/;
1642 if ($expr =~ m#/\*.*scope.*\*/#i) { # "scope" in C comments
1645 if (defined($defaults{$var})) {
1646 $expr =~ s/(\t+)/$1 /g;
1648 if ($name_printed) {
1651 eval qq/print "\\t$var;\\n"/;
1654 if ($defaults{$var} eq 'NO_INIT') {
1655 $deferred .= eval qq/"\\n\\tif (items >= $num) {\\n$expr;\\n\\t}\\n"/;
1657 $deferred .= eval qq/"\\n\\tif (items < $num)\\n\\t $var = $defaults{$var};\\n\\telse {\\n$expr;\\n\\t}\\n"/;
1660 } elsif ($ScopeThisXSUB or $expr !~ /^\t\$var =/) {
1661 if ($name_printed) {
1664 eval qq/print "\\t$var;\\n"/;
1667 $deferred .= eval qq/"\\n$expr;\\n"/;
1670 die "panic: do not know how to handle this branch for function pointers"
1672 eval qq/print "$expr;\\n"/;
1677 sub generate_output {
1678 local($type, $num, $var, $do_setmagic, $do_push) = @_;
1679 local($arg) = "ST(" . ($num - ($num != 0)) . ")";
1680 local($argoff) = $num - 1;
1683 $type = TidyType($type) ;
1684 if ($type =~ /^array\(([^,]*),(.*)\)/) {
1685 print "\t$arg = sv_newmortal();\n";
1686 print "\tsv_setpvn($arg, (char *)$var, $2 * sizeof($1));\n";
1687 print "\tSvSETMAGIC($arg);\n" if $do_setmagic;
1689 blurt("Error: '$type' not in typemap"), return
1690 unless defined($type_kind{$type});
1691 blurt("Error: No OUTPUT definition for type '$type', typekind '$type_kind{$type}' found"), return
1692 unless defined $output_expr{$type_kind{$type}} ;
1693 ($ntype = $type) =~ s/\s*\*/Ptr/g;
1694 $ntype =~ s/\(\)//g;
1695 ($subtype = $ntype) =~ s/(?:Array)?(?:Ptr)?$//;
1696 $expr = $output_expr{$type_kind{$type}};
1697 if ($expr =~ /DO_ARRAY_ELEM/) {
1698 blurt("Error: '$subtype' not in typemap"), return
1699 unless defined($type_kind{$subtype});
1700 blurt("Error: No OUTPUT definition for type '$subtype', typekind '$type_kind{$subtype}' found"), return
1701 unless defined $output_expr{$type_kind{$subtype}} ;
1702 $subexpr = $output_expr{$type_kind{$subtype}};
1703 $subexpr =~ s/ntype/subtype/g;
1704 $subexpr =~ s/\$arg/ST(ix_$var)/g;
1705 $subexpr =~ s/\$var/${var}[ix_$var]/g;
1706 $subexpr =~ s/\n\t/\n\t\t/g;
1707 $expr =~ s/DO_ARRAY_ELEM\n/$subexpr/;
1708 eval "print qq\a$expr\a";
1710 print "\t\tSvSETMAGIC(ST(ix_$var));\n" if $do_setmagic;
1712 elsif ($var eq 'RETVAL') {
1713 if ($expr =~ /^\t\$arg = new/) {
1714 # We expect that $arg has refcnt 1, so we need to
1716 eval "print qq\a$expr\a";
1718 print "\tsv_2mortal(ST($num));\n";
1719 print "\tSvSETMAGIC(ST($num));\n" if $do_setmagic;
1721 elsif ($expr =~ /^\s*\$arg\s*=/) {
1722 # We expect that $arg has refcnt >=1, so we need
1724 eval "print qq\a$expr\a";
1726 print "\tsv_2mortal(ST(0));\n";
1727 print "\tSvSETMAGIC(ST(0));\n" if $do_setmagic;
1730 # Just hope that the entry would safely write it
1731 # over an already mortalized value. By
1732 # coincidence, something like $arg = &sv_undef
1734 print "\tST(0) = sv_newmortal();\n";
1735 eval "print qq\a$expr\a";
1737 # new mortals don't have set magic
1741 print "\tPUSHs(sv_newmortal());\n";
1743 eval "print qq\a$expr\a";
1745 print "\tSvSETMAGIC($arg);\n" if $do_setmagic;
1747 elsif ($arg =~ /^ST\(\d+\)$/) {
1748 eval "print qq\a$expr\a";
1750 print "\tSvSETMAGIC($arg);\n" if $do_setmagic;
1756 my($type, $varname) = @_;
1759 $type =~ s/^array\(([^,]*),(.*)\).*/$1 */s;
1761 if ($varname && $type =~ / \( \s* \* (?= \s* \) ) /xg) {
1762 (substr $type, pos $type, 0) = " $varname ";
1764 $type .= "\t$varname";
1772 # If this is VMS, the exit status has meaning to the shell, so we
1773 # use a predictable value (SS$_Normal or SS$_Abort) rather than an
1775 # exit ($Is_VMS ? ($errors ? 44 : 1) : $errors) ;
1776 exit ($errors ? 1 : 0);