diff options
author | Michael G. Schwern <schwern@pobox.com> | 2020-12-28 19:48:01 -0800 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-01-17 09:18:15 -0700 |
commit | 9824c081922f8e3697322536c3da1702e35e45ab (patch) | |
tree | a5c8f673282770dfddd88133421c8df984816e80 /regen | |
parent | 1604cfb0273418ed479719f39def5ee559bffda2 (diff) | |
download | perl-9824c081922f8e3697322536c3da1702e35e45ab.tar.gz |
style: Detabify regen files.
They generate C files.
Bump feature.pm and warnings.pm versions to satisfy cmpVERSION.pl.
I can't get it to easily ignore whitespace, `git diff --name-only`
does not respect the -w flag.
regen_perly.pl is left alone. That would require rebuilding
perly.* which is beyond a simple indentation change.
Diffstat (limited to 'regen')
-rw-r--r-- | regen/charset_translations.pl | 20 | ||||
-rwxr-xr-x | regen/embed.pl | 480 | ||||
-rw-r--r-- | regen/embed_lib.pl | 146 | ||||
-rwxr-xr-x | regen/keywords.pl | 14 | ||||
-rw-r--r-- | regen/lib_cleanup.pl | 2 | ||||
-rw-r--r-- | regen/mg_vtable.pl | 260 | ||||
-rw-r--r-- | regen/mk_PL_charclass.pl | 2 | ||||
-rw-r--r-- | regen/mk_invlists.pl | 6 | ||||
-rwxr-xr-x | regen/opcode.pl | 308 | ||||
-rw-r--r-- | regen/overload.pl | 10 | ||||
-rw-r--r-- | regen/reentr.pl | 704 | ||||
-rwxr-xr-x | regen/regcharclass.pl | 8 | ||||
-rw-r--r-- | regen/regen_lib.pl | 58 | ||||
-rw-r--r-- | regen/warnings.pl | 304 |
14 files changed, 1161 insertions, 1161 deletions
diff --git a/regen/charset_translations.pl b/regen/charset_translations.pl index d2a0014557..cb7f801b07 100644 --- a/regen/charset_translations.pl +++ b/regen/charset_translations.pl @@ -275,21 +275,21 @@ sub cp_2_utfbytes($$) { my $I8_2_utf = get_I8_2_utf($charset); my $len = $ucp < 0xA0 ? 1 : - $ucp < 0x400 ? 2 : - $ucp < 0x4000 ? 3 : - $ucp < 0x40000 ? 4 : - $ucp < 0x400000 ? 5 : - $ucp < 0x4000000 ? 6 : - $ucp < 0x40000000? 7 : + $ucp < 0x400 ? 2 : + $ucp < 0x4000 ? 3 : + $ucp < 0x40000 ? 4 : + $ucp < 0x400000 ? 5 : + $ucp < 0x4000000 ? 6 : + $ucp < 0x40000000? 7 : $CHARSET_TRANSLATIONS::UTF_EBCDIC_MAXBYTES; my @str; - for (1 .. $len - 1) { + for (1 .. $len - 1) { unshift @str, chr $I8_2_utf->[($ucp & 0x1f) | 0xA0]; - $ucp >>= 5; - } + $ucp >>= 5; + } - unshift @str, chr $I8_2_utf->[($ucp & _UTF_START_MASK($len)) | _UTF_START_MARK($len)]; + unshift @str, chr $I8_2_utf->[($ucp & _UTF_START_MASK($len)) | _UTF_START_MARK($len)]; return join "", @str; } diff --git a/regen/embed.pl b/regen/embed.pl index f5db51d51c..64a8da3f47 100755 --- a/regen/embed.pl +++ b/regen/embed.pl @@ -45,7 +45,7 @@ sub die_at_end ($) { # Keeps going for now, but makes sure the regen doesn't } sub full_name ($$) { # Returns the function name with potentially the - # prefixes 'S_' or 'Perl_' + # prefixes 'S_' or 'Perl_' my ($func, $flags) = @_; return "Perl_$func" if $flags =~ /p/; @@ -57,11 +57,11 @@ sub open_print_header { my ($file, $quote) = @_; return open_new($file, '>', - { file => $file, style => '*', by => 'regen/embed.pl', - from => ['data in embed.fnc', 'regen/embed.pl', - 'regen/opcodes', 'intrpvar.h', 'perlvars.h'], - final => "\nEdit those files and run 'make regen_headers' to effect changes.\n", - copyright => [1993 .. 2009], quote => $quote }); + { file => $file, style => '*', by => 'regen/embed.pl', + from => ['data in embed.fnc', 'regen/embed.pl', + 'regen/opcodes', 'intrpvar.h', 'perlvars.h'], + final => "\nEdit those files and run 'make regen_headers' to effect changes.\n", + copyright => [1993 .. 2009], quote => $quote }); } my ($embed, $core, $ext, $api) = setup_embed(); @@ -73,196 +73,196 @@ my ($embed, $core, $ext, $api) = setup_embed(); my $ret; foreach (@$embed) { - if (@$_ == 1) { - print $pr "$_->[0]\n"; - next; - } + if (@$_ == 1) { + print $pr "$_->[0]\n"; + next; + } - my ($flags,$retval,$plain_func,@args) = @$_; + my ($flags,$retval,$plain_func,@args) = @$_; if ($flags =~ / ( [^AabCDdEefFGhIiMmNnOoPpRrSsTUuWXx] ) /x) { - die_at_end "flag $1 is not legal (for function $plain_func)"; - } - my @nonnull; - my $args_assert_line = ( $flags !~ /G/ ); + die_at_end "flag $1 is not legal (for function $plain_func)"; + } + my @nonnull; + my $args_assert_line = ( $flags !~ /G/ ); my $has_depth = ( $flags =~ /W/ ); - my $has_context = ( $flags !~ /T/ ); - my $never_returns = ( $flags =~ /r/ ); - my $binarycompat = ( $flags =~ /b/ ); - my $commented_out = ( $flags =~ /m/ ); - my $is_malloc = ( $flags =~ /a/ ); - my $can_ignore = ( $flags !~ /R/ ) && ( $flags !~ /P/ ) && !$is_malloc; - my @names_of_nn; - my $func; - - if (! $can_ignore && $retval eq 'void') { - warn "It is nonsensical to require the return value of a void function ($plain_func) to be checked"; - } - - die_at_end "$plain_func: S and p flags are mutually exclusive" - if $flags =~ /S/ && $flags =~ /p/; - die_at_end "$plain_func: m and $1 flags are mutually exclusive" - if $flags =~ /m/ && $flags =~ /([pS])/; - - die_at_end "$plain_func: u flag only usable with m" if $flags =~ /u/ - && $flags !~ /m/; - - my $static_inline = 0; - if ($flags =~ /([SIi])/) { - my $type; - if ($never_returns) { - $type = { - 'S' => 'PERL_STATIC_NO_RET', - 'i' => 'PERL_STATIC_INLINE_NO_RET', - 'I' => 'PERL_STATIC_FORCE_INLINE_NO_RET' - }->{$1}; - } - else { - $type = { - 'S' => 'STATIC', - 'i' => 'PERL_STATIC_INLINE', - 'I' => 'PERL_STATIC_FORCE_INLINE' - }->{$1}; - } - $retval = "$type $retval"; - die_at_end "Don't declare static function '$plain_func' pure" if $flags =~ /P/; - $static_inline = $type =~ /^PERL_STATIC(?:_FORCE)?_INLINE/; - } - else { - if ($never_returns) { - $retval = "PERL_CALLCONV_NO_RET $retval"; - } - else { - $retval = "PERL_CALLCONV $retval"; - } - } - - die_at_end "For '$plain_func', M flag requires p flag" - if $flags =~ /M/ && $flags !~ /p/; - die_at_end "For '$plain_func', C flag requires one of [pIimb] flags" - if $flags =~ /C/ && $flags !~ /[Iibmp]/; - die_at_end "For '$plain_func', X flag requires one of [Iip] flags" - if $flags =~ /X/ && $flags !~ /[Iip]/; - die_at_end "For '$plain_func', X and m flags are mutually exclusive" - if $flags =~ /X/ && $flags =~ /m/; - die_at_end "For '$plain_func', [Ii] with [ACX] requires p flag" - if $flags =~ /[Ii]/ && $flags =~ /[ACX]/ && $flags !~ /p/; - die_at_end "For '$plain_func', b and m flags are mutually exclusive" - . " (try M flag)" if $flags =~ /b/ && $flags =~ /m/; - die_at_end "For '$plain_func', b flag without M flag requires D flag" - if $flags =~ /b/ && $flags !~ /M/ && $flags !~ /D/; - die_at_end "For '$plain_func', I and i flags are mutually exclusive" - if $flags =~ /I/ && $flags =~ /i/; - - $func = full_name($plain_func, $flags); - $ret = ""; - $ret .= "$retval\t$func("; - if ( $has_context ) { - $ret .= @args ? "pTHX_ " : "pTHX"; - } - if (@args) { - die_at_end "n flag is contradicted by having arguments" - if $flags =~ /n/; - my $n; - for my $arg ( @args ) { - ++$n; - if ( $arg =~ /\*/ && $arg !~ /\b(NN|NULLOK)\b/ ) { - warn "$func: $arg needs NN or NULLOK\n"; - ++$unflagged_pointers; - } - my $nn = ( $arg =~ s/\s*\bNN\b\s+// ); - push( @nonnull, $n ) if $nn; - - my $nullok = ( $arg =~ s/\s*\bNULLOK\b\s+// ); # strip NULLOK with no effect - - # Make sure each arg has at least a type and a var name. - # An arg of "int" is valid C, but want it to be "int foo". - my $temp_arg = $arg; - $temp_arg =~ s/\*//g; - $temp_arg =~ s/\s*\bstruct\b\s*/ /g; - if ( ($temp_arg ne "...") - && ($temp_arg !~ /\w+\s+(\w+)(?:\[\d+\])?\s*$/) ) { - die_at_end "$func: $arg ($n) doesn't have a name\n"; - } - if (defined $1 && $nn && !($commented_out && !$binarycompat)) { - push @names_of_nn, $1; - } - } - $ret .= join ", ", @args; - } - else { - $ret .= "void" if !$has_context; - } + my $has_context = ( $flags !~ /T/ ); + my $never_returns = ( $flags =~ /r/ ); + my $binarycompat = ( $flags =~ /b/ ); + my $commented_out = ( $flags =~ /m/ ); + my $is_malloc = ( $flags =~ /a/ ); + my $can_ignore = ( $flags !~ /R/ ) && ( $flags !~ /P/ ) && !$is_malloc; + my @names_of_nn; + my $func; + + if (! $can_ignore && $retval eq 'void') { + warn "It is nonsensical to require the return value of a void function ($plain_func) to be checked"; + } + + die_at_end "$plain_func: S and p flags are mutually exclusive" + if $flags =~ /S/ && $flags =~ /p/; + die_at_end "$plain_func: m and $1 flags are mutually exclusive" + if $flags =~ /m/ && $flags =~ /([pS])/; + + die_at_end "$plain_func: u flag only usable with m" if $flags =~ /u/ + && $flags !~ /m/; + + my $static_inline = 0; + if ($flags =~ /([SIi])/) { + my $type; + if ($never_returns) { + $type = { + 'S' => 'PERL_STATIC_NO_RET', + 'i' => 'PERL_STATIC_INLINE_NO_RET', + 'I' => 'PERL_STATIC_FORCE_INLINE_NO_RET' + }->{$1}; + } + else { + $type = { + 'S' => 'STATIC', + 'i' => 'PERL_STATIC_INLINE', + 'I' => 'PERL_STATIC_FORCE_INLINE' + }->{$1}; + } + $retval = "$type $retval"; + die_at_end "Don't declare static function '$plain_func' pure" if $flags =~ /P/; + $static_inline = $type =~ /^PERL_STATIC(?:_FORCE)?_INLINE/; + } + else { + if ($never_returns) { + $retval = "PERL_CALLCONV_NO_RET $retval"; + } + else { + $retval = "PERL_CALLCONV $retval"; + } + } + + die_at_end "For '$plain_func', M flag requires p flag" + if $flags =~ /M/ && $flags !~ /p/; + die_at_end "For '$plain_func', C flag requires one of [pIimb] flags" + if $flags =~ /C/ && $flags !~ /[Iibmp]/; + die_at_end "For '$plain_func', X flag requires one of [Iip] flags" + if $flags =~ /X/ && $flags !~ /[Iip]/; + die_at_end "For '$plain_func', X and m flags are mutually exclusive" + if $flags =~ /X/ && $flags =~ /m/; + die_at_end "For '$plain_func', [Ii] with [ACX] requires p flag" + if $flags =~ /[Ii]/ && $flags =~ /[ACX]/ && $flags !~ /p/; + die_at_end "For '$plain_func', b and m flags are mutually exclusive" + . " (try M flag)" if $flags =~ /b/ && $flags =~ /m/; + die_at_end "For '$plain_func', b flag without M flag requires D flag" + if $flags =~ /b/ && $flags !~ /M/ && $flags !~ /D/; + die_at_end "For '$plain_func', I and i flags are mutually exclusive" + if $flags =~ /I/ && $flags =~ /i/; + + $func = full_name($plain_func, $flags); + $ret = ""; + $ret .= "$retval\t$func("; + if ( $has_context ) { + $ret .= @args ? "pTHX_ " : "pTHX"; + } + if (@args) { + die_at_end "n flag is contradicted by having arguments" + if $flags =~ /n/; + my $n; + for my $arg ( @args ) { + ++$n; + if ( $arg =~ /\*/ && $arg !~ /\b(NN|NULLOK)\b/ ) { + warn "$func: $arg needs NN or NULLOK\n"; + ++$unflagged_pointers; + } + my $nn = ( $arg =~ s/\s*\bNN\b\s+// ); + push( @nonnull, $n ) if $nn; + + my $nullok = ( $arg =~ s/\s*\bNULLOK\b\s+// ); # strip NULLOK with no effect + + # Make sure each arg has at least a type and a var name. + # An arg of "int" is valid C, but want it to be "int foo". + my $temp_arg = $arg; + $temp_arg =~ s/\*//g; + $temp_arg =~ s/\s*\bstruct\b\s*/ /g; + if ( ($temp_arg ne "...") + && ($temp_arg !~ /\w+\s+(\w+)(?:\[\d+\])?\s*$/) ) { + die_at_end "$func: $arg ($n) doesn't have a name\n"; + } + if (defined $1 && $nn && !($commented_out && !$binarycompat)) { + push @names_of_nn, $1; + } + } + $ret .= join ", ", @args; + } + else { + $ret .= "void" if !$has_context; + } $ret .= " _pDEPTH" if $has_depth; - $ret .= ")"; - my @attrs; - if ( $flags =~ /r/ ) { - push @attrs, "__attribute__noreturn__"; - } - if ( $flags =~ /D/ ) { - push @attrs, "__attribute__deprecated__"; - } - if ( $is_malloc ) { - push @attrs, "__attribute__malloc__"; - } - if ( !$can_ignore ) { - push @attrs, "__attribute__warn_unused_result__"; - } - if ( $flags =~ /P/ ) { - push @attrs, "__attribute__pure__"; - } - if ( $flags =~ /I/ ) { - push @attrs, "__attribute__always_inline__"; - } - if( $flags =~ /f/ ) { - my $prefix = $has_context ? 'pTHX_' : ''; - my ($args, $pat); - if ($args[-1] eq '...') { - $args = scalar @args; - $pat = $args - 1; - $args = $prefix . $args; - } - else { - # don't check args, and guess which arg is the pattern - # (one of 'fmt', 'pat', 'f'), - $args = 0; - my @fmts = grep $args[$_] =~ /\b(f|pat|fmt)$/, 0..$#args; - if (@fmts != 1) { - die "embed.pl: '$plain_func': can't determine pattern arg\n"; - } - $pat = $fmts[0] + 1; - } - my $macro = grep($_ == $pat, @nonnull) - ? '__attribute__format__' - : '__attribute__format__null_ok__'; - if ($plain_func =~ /strftime/) { - push @attrs, sprintf "%s(__strftime__,%s1,0)", $macro, $prefix; - } - else { - push @attrs, sprintf "%s(__printf__,%s%d,%s)", $macro, - $prefix, $pat, $args; - } - } - elsif ((grep { $_ eq '...' } @args) && $flags !~ /F/) { - die_at_end "$plain_func: Function with '...' arguments must have" - . " f or F flag"; - } - if ( @attrs ) { - $ret .= "\n"; - $ret .= join( "\n", map { "\t\t\t$_" } @attrs ); - } - $ret .= ";"; - $ret = "/* $ret */" if $commented_out; - - $ret .= "\n#define PERL_ARGS_ASSERT_\U$plain_func\E" - if $args_assert_line || @names_of_nn; - $ret .= "\t\\\n\t" . join '; ', map "assert($_)", @names_of_nn - if @names_of_nn; - - $ret = "#ifndef PERL_NO_INLINE_FUNCTIONS\n$ret\n#endif" if $static_inline; - $ret = "#ifndef NO_MATHOMS\n$ret\n#endif" if $binarycompat; - $ret .= @attrs ? "\n\n" : "\n"; - - print $pr $ret; + $ret .= ")"; + my @attrs; + if ( $flags =~ /r/ ) { + push @attrs, "__attribute__noreturn__"; + } + if ( $flags =~ /D/ ) { + push @attrs, "__attribute__deprecated__"; + } + if ( $is_malloc ) { + push @attrs, "__attribute__malloc__"; + } + if ( !$can_ignore ) { + push @attrs, "__attribute__warn_unused_result__"; + } + if ( $flags =~ /P/ ) { + push @attrs, "__attribute__pure__"; + } + if ( $flags =~ /I/ ) { + push @attrs, "__attribute__always_inline__"; + } + if( $flags =~ /f/ ) { + my $prefix = $has_context ? 'pTHX_' : ''; + my ($args, $pat); + if ($args[-1] eq '...') { + $args = scalar @args; + $pat = $args - 1; + $args = $prefix . $args; + } + else { + # don't check args, and guess which arg is the pattern + # (one of 'fmt', 'pat', 'f'), + $args = 0; + my @fmts = grep $args[$_] =~ /\b(f|pat|fmt)$/, 0..$#args; + if (@fmts != 1) { + die "embed.pl: '$plain_func': can't determine pattern arg\n"; + } + $pat = $fmts[0] + 1; + } + my $macro = grep($_ == $pat, @nonnull) + ? '__attribute__format__' + : '__attribute__format__null_ok__'; + if ($plain_func =~ /strftime/) { + push @attrs, sprintf "%s(__strftime__,%s1,0)", $macro, $prefix; + } + else { + push @attrs, sprintf "%s(__printf__,%s%d,%s)", $macro, + $prefix, $pat, $args; + } + } + elsif ((grep { $_ eq '...' } @args) && $flags !~ /F/) { + die_at_end "$plain_func: Function with '...' arguments must have" + . " f or F flag"; + } + if ( @attrs ) { + $ret .= "\n"; + $ret .= join( "\n", map { "\t\t\t$_" } @attrs ); + } + $ret .= ";"; + $ret = "/* $ret */" if $commented_out; + + $ret .= "\n#define PERL_ARGS_ASSERT_\U$plain_func\E" + if $args_assert_line || @names_of_nn; + $ret .= "\t\\\n\t" . join '; ', map "assert($_)", @names_of_nn + if @names_of_nn; + + $ret = "#ifndef PERL_NO_INLINE_FUNCTIONS\n$ret\n#endif" if $static_inline; + $ret = "#ifndef NO_MATHOMS\n$ret\n#endif" if $binarycompat; + $ret .= @attrs ? "\n\n" : "\n"; + + print $pr $ret; } print $pr <<'EOF'; @@ -282,13 +282,13 @@ sub readvars { local (*FILE, $_); my %seen; open(FILE, '<', $file) - or die "embed.pl: Can't open $file: $!\n"; + or die "embed.pl: Can't open $file: $!\n"; while (<FILE>) { - s/[ \t]*#.*//; # Delete comments. - if (/PERLVARA?I?C?\($pre,\s*(\w+)/) { - die_at_end "duplicate symbol $1 while processing $file line $.\n" - if $seen{$1}++; - } + s/[ \t]*#.*//; # Delete comments. + if (/PERLVARA?I?C?\($pre,\s*(\w+)/) { + die_at_end "duplicate symbol $1 while processing $file line $.\n" + if $seen{$1}++; + } } close(FILE); return sort keys %seen; @@ -334,37 +334,37 @@ sub embed_h { my $lines; foreach (@$funcs) { - if (@$_ == 1) { - my $cond = $_->[0]; - # Indent the conditionals if we are wrapped in an #if/#endif pair. - $cond =~ s/#(.*)/# $1/ if $guard; - $lines .= "$cond\n"; - next; - } - my $ret = ""; - my ($flags,$retval,$func,@args) = @$_; - unless ($flags =~ /[omM]/) { - my $args = scalar @args; - if ($flags =~ /T/) { - my $full_name = full_name($func, $flags); - next if $full_name eq $func; # Don't output a no-op. - $ret = hide($func, $full_name); - } - elsif ($args and $args[$args-1] =~ /\.\.\./) { - if ($flags =~ /p/) { - # we're out of luck for varargs functions under CPP - # So we can only do these macros for no implicit context: - $ret = "#ifndef PERL_IMPLICIT_CONTEXT\n" - . hide($func, full_name($func, $flags)) . "#endif\n"; - } - } - else { - my $alist = join(",", @az[0..$args-1]); - $ret = "#define $func($alist)"; - my $t = int(length($ret) / 8); - $ret .= "\t" x ($t < 4 ? 4 - $t : 1); - $ret .= full_name($func, $flags) . "(aTHX"; - $ret .= "_ " if $alist; + if (@$_ == 1) { + my $cond = $_->[0]; + # Indent the conditionals if we are wrapped in an #if/#endif pair. + $cond =~ s/#(.*)/# $1/ if $guard; + $lines .= "$cond\n"; + next; + } + my $ret = ""; + my ($flags,$retval,$func,@args) = @$_; + unless ($flags =~ /[omM]/) { + my $args = scalar @args; + if ($flags =~ /T/) { + my $full_name = full_name($func, $flags); + next if $full_name eq $func; # Don't output a no-op. + $ret = hide($func, $full_name); + } + elsif ($args and $args[$args-1] =~ /\.\.\./) { + if ($flags =~ /p/) { + # we're out of luck for varargs functions under CPP + # So we can only do these macros for no implicit context: + $ret = "#ifndef PERL_IMPLICIT_CONTEXT\n" + . hide($func, full_name($func, $flags)) . "#endif\n"; + } + } + else { + my $alist = join(",", @az[0..$args-1]); + $ret = "#define $func($alist)"; + my $t = int(length($ret) / 8); + $ret .= "\t" x ($t < 4 ? 4 - $t : 1); + $ret .= full_name($func, $flags) . "(aTHX"; + $ret .= "_ " if $alist; $ret .= $alist; if ($flags =~ /W/) { if ($alist) { @@ -374,10 +374,10 @@ sub embed_h { } } $ret .= ")\n"; - } - $ret = "#ifndef NO_MATHOMS\n$ret#endif\n" if $flags =~ /b/; - } - $lines .= $ret; + } + $ret = "#ifndef NO_MATHOMS\n$ret#endif\n" if $flags =~ /b/; + } + $lines .= $ret; } # Prune empty #if/#endif pairs. while ($lines =~ s/#\s*if[^\n]+\n#\s*endif\n//) { @@ -438,14 +438,14 @@ my @nocontext; { my (%has_va, %has_nocontext); foreach (@$embed) { - next unless @$_ > 1; - ++$has_va{$_->[2]} if $_->[-1] =~ /\.\.\./; - ++$has_nocontext{$1} if $_->[2] =~ /(.*)_nocontext/; + next unless @$_ > 1; + ++$has_va{$_->[2]} if $_->[-1] =~ /\.\.\./; + ++$has_nocontext{$1} if $_->[2] =~ /(.*)_nocontext/; } @nocontext = sort grep { - $has_nocontext{$_} - && !/printf/ # Not clear to me why these are skipped but they are. + $has_nocontext{$_} + && !/printf/ # Not clear to me why these are skipped but they are. } keys %has_va; } @@ -515,11 +515,11 @@ my $sym; for $sym (@intrp) { if ($sym eq 'sawampersand') { - print $em "#ifndef PL_sawampersand\n"; + print $em "#ifndef PL_sawampersand\n"; } print $em multon($sym,'I','vTHX->'); if ($sym eq 'sawampersand') { - print $em "#endif\n"; + print $em "#endif\n"; } } diff --git a/regen/embed_lib.pl b/regen/embed_lib.pl index 774b4f25a3..0ef91b2144 100644 --- a/regen/embed_lib.pl +++ b/regen/embed_lib.pl @@ -19,8 +19,8 @@ sub current_group { # For embed.fnc, ordering within the && isn't relevant, so we can # sort them to try to group more functions together. foreach (sort @state) { - $group->{$_} ||= {}; - $group = $group->{$_}; + $group->{$_} ||= {}; + $group = $group->{$_}; } return $group->{''} ||= []; } @@ -30,27 +30,27 @@ sub add_level { my $funcs = $level->{''}; my @entries; if ($funcs) { - if (!defined $wanted) { - @entries = @$funcs; - } else { - foreach (@$funcs) { + if (!defined $wanted) { + @entries = @$funcs; + } else { + foreach (@$funcs) { if ($_->[0] =~ /[AC]/) { # 'C' is like 'A' for our purposes # here - push @entries, $_ if $wanted eq 'A'; - } elsif ($_->[0] =~ /E/) { - push @entries, $_ if $wanted eq 'E'; - } else { - push @entries, $_ if $wanted eq ''; - } - } - } - @entries = sort {$a->[2] cmp $b->[2]} @entries; + push @entries, $_ if $wanted eq 'A'; + } elsif ($_->[0] =~ /E/) { + push @entries, $_ if $wanted eq 'E'; + } else { + push @entries, $_ if $wanted eq ''; + } + } + } + @entries = sort {$a->[2] cmp $b->[2]} @entries; } foreach (sort grep {length $_} keys %$level) { - my @conditional = add_level($level->{$_}, $indent . ' ', $wanted); - push @entries, - ["#${indent}if $_"], @conditional, ["#${indent}endif"] - if @conditional; + my @conditional = add_level($level->{$_}, $indent . ' ', $wanted); + push @entries, + ["#${indent}if $_"], @conditional, ["#${indent}endif"] + if @conditional; } return @entries; } @@ -64,31 +64,31 @@ sub setup_embed { my $macro_depth = 0; while (<IN>) { - chomp; - next if /^:/; - next if /^$/; - while (s|\\$||) { - $_ .= <IN>; - chomp; - } - s/\s+$//; - my @args; - if (/^\s*(#|$)/) { - @args = $_; - } - else { - @args = split /\s*\|\s*/, $_; - } - if (@args == 1) { + chomp; + next if /^:/; + next if /^$/; + while (s|\\$||) { + $_ .= <IN>; + chomp; + } + s/\s+$//; + my @args; + if (/^\s*(#|$)/) { + @args = $_; + } + else { + @args = split /\s*\|\s*/, $_; + } + if (@args == 1) { if ($args[0] !~ /^#\s*(?:if|ifdef|ifndef|else|endif)/) { die "Illegal line $. '$args[0]' in embed.fnc"; } $macro_depth++ if $args[0] =~/^#\s*if(n?def)?\b/; $macro_depth-- if $args[0] =~/^#\s*endif\b/; die "More #endif than #if in embed.fnc:$." if $macro_depth < 0; - } + } else { - die "Illegal line (less than 3 fields) in embed.fnc:$.: $_" + die "Illegal line (less than 3 fields) in embed.fnc:$.: $_" unless @args >= 3; my $name = $args[2]; # only check for duplicates outside of #if's - otherwise @@ -100,7 +100,7 @@ sub setup_embed { $seen{$name} = 1; } - push @embed, \@args; + push @embed, \@args; } die "More #if than #endif by the end of embed.fnc" if $macro_depth != 0; @@ -108,18 +108,18 @@ sub setup_embed { open IN, '<', $prefix . 'regen/opcodes' or die $!; { - my %syms; - - while (<IN>) { - chomp; - next unless $_; - next if /^#/; - my $check = (split /\t+/, $_)[2]; - next if $syms{$check}++; - - # These are all indirectly referenced by globals.c. - push @embed, ['pR', 'OP *', $check, 'NN OP *o']; - } + my %syms; + + while (<IN>) { + chomp; + next unless $_; + next if /^#/; + my $check = (split /\t+/, $_)[2]; + next if $syms{$check}++; + + # These are all indirectly referenced by globals.c. + push @embed, ['pR', 'OP *', $check, 'NN OP *o']; + } } close IN or die "Problem reading regen/opcodes: $!"; @@ -133,32 +133,32 @@ sub setup_embed { my $current = current_group(); foreach (@embed) { - if (@$_ > 1) { - push @$current, $_; - next; - } - $_->[0] =~ s/^#\s+/#/; - $_->[0] =~ /^\S*/; - $_->[0] =~ s/^#ifdef\s+(\S+)/#if defined($1)/; - $_->[0] =~ s/^#ifndef\s+(\S+)/#if !defined($1)/; - if ($_->[0] =~ /^#if\s*(.*)/) { - push @state, $1; - } elsif ($_->[0] =~ /^#else\s*$/) { - die "Unmatched #else in embed.fnc" unless @state; - $state[-1] = "!($state[-1])"; - } elsif ($_->[0] =~ m!^#endif\s*(?:/\*.*\*/)?$!) { - die "Unmatched #endif in embed.fnc" unless @state; - pop @state; - } else { - die "Unhandled pre-processor directive '$_->[0]' in embed.fnc"; - } - $current = current_group(); + if (@$_ > 1) { + push @$current, $_; + next; + } + $_->[0] =~ s/^#\s+/#/; + $_->[0] =~ /^\S*/; + $_->[0] =~ s/^#ifdef\s+(\S+)/#if defined($1)/; + $_->[0] =~ s/^#ifndef\s+(\S+)/#if !defined($1)/; + if ($_->[0] =~ /^#if\s*(.*)/) { + push @state, $1; + } elsif ($_->[0] =~ /^#else\s*$/) { + die "Unmatched #else in embed.fnc" unless @state; + $state[-1] = "!($state[-1])"; + } elsif ($_->[0] =~ m!^#endif\s*(?:/\*.*\*/)?$!) { + die "Unmatched #endif in embed.fnc" unless @state; + pop @state; + } else { + die "Unhandled pre-processor directive '$_->[0]' in embed.fnc"; + } + $current = current_group(); } return ([add_level(\%groups, '')], - [add_level(\%groups, '', '')], # core - [add_level(\%groups, '', 'E')], # ext - [add_level(\%groups, '', 'A')]); # api + [add_level(\%groups, '', '')], # core + [add_level(\%groups, '', 'E')], # ext + [add_level(\%groups, '', 'A')]); # api } 1; diff --git a/regen/keywords.pl b/regen/keywords.pl index ffc4882efa..b9ae8cf0f2 100755 --- a/regen/keywords.pl +++ b/regen/keywords.pl @@ -14,11 +14,11 @@ use Devel::Tokenizer::C 0.05; require './regen/regen_lib.pl'; my $h = open_new('keywords.h', '>', - { by => 'regen/keywords.pl', from => 'its data', - file => 'keywords.h', style => '*', - copyright => [1994 .. 1997, 1999 .. 2002, 2005 .. 2007]}); + { by => 'regen/keywords.pl', from => 'its data', + file => 'keywords.h', style => '*', + copyright => [1994 .. 1997, 1999 .. 2002, 2005 .. 2007]}); my $c = open_new('keywords.c', '>', - { by => 'regen/keywords.pl', from => 'its data', style => '*'}); + { by => 'regen/keywords.pl', from => 'its data', style => '*'}); my %by_strength; @@ -52,9 +52,9 @@ my %feature_kw = ( my %pos = map { ($_ => 1) } @{$by_strength{'+'}}; my $t = Devel::Tokenizer::C->new(TokenFunc => \&perl_keyword, - TokenString => 'name', - StringLength => 'len', - MergeSwitches => 1, + TokenString => 'name', + StringLength => 'len', + MergeSwitches => 1, ); $t->add_tokens(@{$by_strength{'+'}}, @{$by_strength{'-'}}, 'elseif'); diff --git a/regen/lib_cleanup.pl b/regen/lib_cleanup.pl index 5c5c4e24ef..d80a33ce02 100644 --- a/regen/lib_cleanup.pl +++ b/regen/lib_cleanup.pl @@ -48,7 +48,7 @@ foreach my $file (@ext) { or die "Can't parse '$file'"; if ($path =~ /\.yml$/) { - next unless $path =~ s!^lib/!!; + next unless $path =~ s!^lib/!!; } elsif ($path =~ /\.pod$/) { unless ($path =~ s!^lib/!!) { # ExtUtils::MakeMaker will install it to a path based on the diff --git a/regen/mg_vtable.pl b/regen/mg_vtable.pl index 019beef990..ebd3413082 100644 --- a/regen/mg_vtable.pl +++ b/regen/mg_vtable.pl @@ -121,94 +121,94 @@ BEGIN { my %mg = ( sv => { char => "\0", vtable => 'sv', readonly_acceptable => 1, - desc => 'Special scalar variable' }, + desc => 'Special scalar variable' }, # overload, or type "A" magic, used to be here. Hence overloaded is # often called AMAGIC internally, even though it does not use "A" # magic any more. overload_table => { char => 'c', vtable => 'ovrld', - desc => 'Holds overload table (AMT) on stash' }, + desc => 'Holds overload table (AMT) on stash' }, bm => { char => 'B', vtable => 'regexp', value_magic => 1, - readonly_acceptable => 1, - desc => 'Boyer-Moore (fast string search)' }, + readonly_acceptable => 1, + desc => 'Boyer-Moore (fast string search)' }, regdata => { char => 'D', vtable => 'regdata', - desc => "Regex match position data\n(\@+ and \@- vars)" }, + desc => "Regex match position data\n(\@+ and \@- vars)" }, regdatum => { char => 'd', vtable => 'regdatum', - desc => 'Regex match position data element' }, + desc => 'Regex match position data element' }, env => { char => 'E', vtable => 'env', desc => '%ENV hash' }, envelem => { char => 'e', vtable => 'envelem', - desc => '%ENV hash element' }, + desc => '%ENV hash element' }, fm => { char => 'f', vtable => 'regexp', value_magic => 1, - readonly_acceptable => 1, desc => "Formline ('compiled' format)" }, + readonly_acceptable => 1, desc => "Formline ('compiled' format)" }, regex_global => { char => 'g', vtable => 'mglob', value_magic => 1, - readonly_acceptable => 1, desc => 'm//g target' }, + readonly_acceptable => 1, desc => 'm//g target' }, hints => { char => 'H', vtable => 'hints', desc => '%^H hash' }, hintselem => { char => 'h', vtable => 'hintselem', - desc => '%^H hash element' }, + desc => '%^H hash element' }, isa => { char => 'I', vtable => 'isa', desc => '@ISA array' }, isaelem => { char => 'i', vtable => 'isaelem', - desc => '@ISA array element' }, + desc => '@ISA array element' }, nkeys => { char => 'k', vtable => 'nkeys', value_magic => 1, - desc => 'scalar(keys()) lvalue' }, + desc => 'scalar(keys()) lvalue' }, dbfile => { char => 'L', - desc => 'Debugger %_<filename' }, + desc => 'Debugger %_<filename' }, dbline => { char => 'l', vtable => 'dbline', - desc => 'Debugger %_<filename element' }, + desc => 'Debugger %_<filename element' }, shared => { char => 'N', desc => 'Shared between threads', - unknown_to_sv_magic => 1 }, + unknown_to_sv_magic => 1 }, shared_scalar => { char => 'n', desc => 'Shared between threads', - unknown_to_sv_magic => 1 }, + unknown_to_sv_magic => 1 }, collxfrm => { char => 'o', vtable => 'collxfrm', value_magic => 1, - desc => 'Locale transformation' }, + desc => 'Locale transformation' }, tied => { char => 'P', vtable => 'pack', - value_magic => 1, # treat as value, so 'local @tied' isn't tied - desc => 'Tied array or hash' }, + value_magic => 1, # treat as value, so 'local @tied' isn't tied + desc => 'Tied array or hash' }, tiedelem => { char => 'p', vtable => 'packelem', - desc => 'Tied array or hash element' }, + desc => 'Tied array or hash element' }, tiedscalar => { char => 'q', vtable => 'packelem', - desc => 'Tied scalar or handle' }, + desc => 'Tied scalar or handle' }, qr => { char => 'r', vtable => 'regexp', value_magic => 1, - readonly_acceptable => 1, desc => 'Precompiled qr// regex' }, + readonly_acceptable => 1, desc => 'Precompiled qr// regex' }, sig => { char => 'S', desc => '%SIG hash' }, sigelem => { char => 's', vtable => 'sigelem', - desc => '%SIG hash element' }, + desc => '%SIG hash element' }, taint => { char => 't', vtable => 'taint', value_magic => 1, - desc => 'Taintedness' }, + desc => 'Taintedness' }, uvar => { char => 'U', vtable => 'uvar', - desc => 'Available for use by extensions' }, + desc => 'Available for use by extensions' }, uvar_elem => { char => 'u', desc => 'Reserved for use by extensions', - unknown_to_sv_magic => 1 }, + unknown_to_sv_magic => 1 }, vec => { char => 'v', vtable => 'vec', value_magic => 1, - desc => 'vec() lvalue' }, + desc => 'vec() lvalue' }, vstring => { char => 'V', value_magic => 1, - desc => 'SV was vstring literal' }, + desc => 'SV was vstring literal' }, utf8 => { char => 'w', vtable => 'utf8', value_magic => 1, - desc => 'Cached UTF-8 information' }, + desc => 'Cached UTF-8 information' }, substr => { char => 'x', vtable => 'substr', value_magic => 1, - desc => 'substr() lvalue' }, + desc => 'substr() lvalue' }, defelem => { char => 'y', vtable => 'defelem', value_magic => 1, - desc => "Shadow \"foreach\" iterator variable /\nsmart parameter vivification" }, + desc => "Shadow \"foreach\" iterator variable /\nsmart parameter vivification" }, nonelem => { char => 'Y', vtable => 'nonelem', value_magic => 1, - desc => "Array element that does not exist" }, + desc => "Array element that does not exist" }, arylen => { char => '#', vtable => 'arylen', value_magic => 1, - desc => 'Array length ($#ary)' }, + desc => 'Array length ($#ary)' }, pos => { char => '.', vtable => 'pos', value_magic => 1, - desc => 'pos() lvalue' }, + desc => 'pos() lvalue' }, backref => { char => '<', vtable => 'backref', value_magic => 1, - readonly_acceptable => 1, desc => 'For weak ref data' }, + readonly_acceptable => 1, desc => 'For weak ref data' }, symtab => { char => ':', value_magic => 1, - desc => 'Extra data for symbol tables' }, + desc => 'Extra data for symbol tables' }, rhash => { char => '%', value_magic => 1, - desc => 'Extra data for restricted hashes' }, + desc => 'Extra data for restricted hashes' }, arylen_p => { char => '@', value_magic => 1, - desc => 'To move arylen out of XPVAV' }, + desc => 'To move arylen out of XPVAV' }, ext => { char => '~', desc => 'Available for use by extensions', - readonly_acceptable => 1 }, + readonly_acceptable => 1 }, checkcall => { char => ']', value_magic => 1, vtable => 'checkcall', - desc => 'Inlining/mutation of call to this CV'}, + desc => 'Inlining/mutation of call to this CV'}, debugvar => { char => '*', desc => '$DB::single, signal, trace vars', - vtable => 'debugvar' }, + vtable => 'debugvar' }, lvref => { char => '\\', vtable => 'lvref', - desc => "Lvalue reference constructor" }, + desc => "Lvalue reference constructor" }, ); @@ -252,7 +252,7 @@ my %sig = 'env' => {set => 'set_all_env', clear => 'clear_all_env'}, 'envelem' => {set => 'setenv', clear => 'clearenv'}, 'sigelem' => {get => 'getsig', set => 'setsig', clear => 'clearsig', - cond => '#ifndef PERL_MICRO'}, + cond => '#ifndef PERL_MICRO'}, 'pack' => {len => 'sizepack', clear => 'wipepack'}, 'packelem' => {get => 'getpack', set => 'setpack', clear => 'clearpack'}, 'dbline' => {set => 'setdbline'}, @@ -279,7 +279,7 @@ my %sig = free => 'freeutf8' }, 'collxfrm' => {set => 'setcollxfrm', free => 'freecollxfrm', - cond => '#ifdef USE_LOCALE_COLLATE'}, + cond => '#ifdef USE_LOCALE_COLLATE'}, 'hintselem' => {set => 'sethint', clear => 'clearhint'}, 'hints' => {clear => 'clearhints'}, 'checkcall' => {copy => 'copycallchecker'}, @@ -296,7 +296,7 @@ my %sig = my ($vt, $raw, $names) = map { open_new($_, '>', - { by => 'regen/mg_vtable.pl', file => $_, style => '*' }); + { by => 'regen/mg_vtable.pl', file => $_, style => '*' }); } 'mg_vtable.h', 'mg_raw.h', 'mg_names.inc'; my $guts = open_new("pod/perlguts.pod", ">"); @@ -323,112 +323,112 @@ EOH { my $longest = 0; foreach (keys %mg) { - $longest = length $_ if length $_ > $longest; + $longest = length $_ if length $_ > $longest; } my $longest_p1 = $longest + 1; my %mg_order; while (my ($name, $data) = each %mg) { - my $byte = $data->{char}; - if ($byte =~ /[[:print:]]/) { - $data->{r_char} = $byte; # readable char - ($data->{c_char} = $byte) =~ s/([\\"])/\\$1/g; # for C strings - } - else { - $data->{c_char} = $data->{r_char} = '\\'.ord $byte; - } - $mg_order{(uc $byte) . $byte} = $name; + my $byte = $data->{char}; + if ($byte =~ /[[:print:]]/) { + $data->{r_char} = $byte; # readable char + ($data->{c_char} = $byte) =~ s/([\\"])/\\$1/g; # for C strings + } + else { + $data->{c_char} = $data->{r_char} = '\\'.ord $byte; + } + $mg_order{(uc $byte) . $byte} = $name; } my @rows; my @names; foreach (sort keys %mg_order) { - my $name = $mg_order{$_}; + my $name = $mg_order{$_}; push @names, $name; - my $data = $mg{$name}; - my $i = ord $data->{char}; + my $data = $mg{$name}; + my $i = ord $data->{char}; # add entry to mg_raw.h - unless ($data->{unknown_to_sv_magic}) { - my $value = $data->{vtable} - ? "want_vtbl_$data->{vtable}" : 'magic_vtable_max'; - $value .= ' | PERL_MAGIC_READONLY_ACCEPTABLE' - if $data->{readonly_acceptable}; - $value .= ' | PERL_MAGIC_VALUE_MAGIC' if $data->{value_magic}; - my $comment = "/* $name '$data->{r_char}' $data->{desc} */"; - $comment =~ s/([\\"])/\\$1/g; - $comment =~ tr/\n/ /; - print $raw qq{ { '$data->{c_char}', "$value",\n "$comment" },\n}; - } + unless ($data->{unknown_to_sv_magic}) { + my $value = $data->{vtable} + ? "want_vtbl_$data->{vtable}" : 'magic_vtable_max'; + $value .= ' | PERL_MAGIC_READONLY_ACCEPTABLE' + if $data->{readonly_acceptable}; + $value .= ' | PERL_MAGIC_VALUE_MAGIC' if $data->{value_magic}; + my $comment = "/* $name '$data->{r_char}' $data->{desc} */"; + $comment =~ s/([\\"])/\\$1/g; + $comment =~ tr/\n/ /; + print $raw qq{ { '$data->{c_char}', "$value",\n "$comment" },\n}; + } # add #define PERL_MAGIC_foo entry to vt_table.h - my $comment = $data->{desc}; - my $leader = ' ' x ($longest + 27); - $comment =~ s/\n/\n$leader/s; - printf $vt "#define PERL_MAGIC_%-${longest}s '%s' /* %s */\n", - $name, $data->{c_char}, $comment; + my $comment = $data->{desc}; + my $leader = ' ' x ($longest + 27); + $comment =~ s/\n/\n$leader/s; + printf $vt "#define PERL_MAGIC_%-${longest}s '%s' /* %s */\n", + $name, $data->{c_char}, $comment; # add entry to mg_names.inc - my $char = $data->{r_char}; - $char =~ s/([\\"])/\\$1/g; - printf $names qq[\t{ PERL_MAGIC_%-${longest_p1}s "%s(%s)" },\n], - "$name,", $name, $char; + my $char = $data->{r_char}; + $char =~ s/([\\"])/\\$1/g; + printf $names qq[\t{ PERL_MAGIC_%-${longest_p1}s "%s(%s)" },\n], + "$name,", $name, $char; # construct perlguts.pod entry - push @rows, [(sprintf "%-2s PERL_MAGIC_%s", $data->{r_char},$name), - $data->{vtable} ? "vtbl_$data->{vtable}" : '(none)', - $data->{desc}]; + push @rows, [(sprintf "%-2s PERL_MAGIC_%s", $data->{r_char},$name), + $data->{vtable} ? "vtbl_$data->{vtable}" : '(none)', + $data->{desc}]; } # output @rows to perlguts.pod select +(select($guts), do { - my @header = ('(old-style char and macro)', 'MGVTBL', 'Type of magic'); - my @widths = (0, 0); - foreach my $row (@rows) { - for (0, 1) { - $widths[$_] = length $row->[$_] - if length $row->[$_] > $widths[$_]; - } - } - my $indent = ' '; - my $format - = sprintf "$indent%%-%ds%%-%ds%%s\n", $widths[0] + 1, $widths[1] + 1; - my $desc_wrap = - 79 - 7 - (length $indent) - $widths[0] - $widths[1] - 2; - - open my $oldguts, "<", "pod/perlguts.pod" - or die "$0 cannot open pod/perlguts.pod for reading: $!"; - while (<$oldguts>) { - print; - last if /^=for mg_vtable.pl begin/ - } - - print "\n", $indent . "mg_type\n"; - printf $format, @header; - printf $format, map {'-' x length $_} @header; - foreach (@rows) { - my ($type, $vtbl, $desc) = @$_; - $desc =~ tr/\n/ /; - my @cont; - if (length $desc > $desc_wrap) { - # If it's too long, first split on '(', if there. - # [Which, if there, is always short enough, currently. - # Make this more robust if that changes] - ($desc, @cont) = split /(?=\()/, $desc; - if (!@cont) { - ($desc, @cont) = $desc =~ /(.{1,$desc_wrap})(?: |\z)/g - } - } - printf $format, $type, $vtbl, $desc; - printf $format, '', '', $_ foreach @cont; - } - print "\n\n"; + my @header = ('(old-style char and macro)', 'MGVTBL', 'Type of magic'); + my @widths = (0, 0); + foreach my $row (@rows) { + for (0, 1) { + $widths[$_] = length $row->[$_] + if length $row->[$_] > $widths[$_]; + } + } + my $indent = ' '; + my $format + = sprintf "$indent%%-%ds%%-%ds%%s\n", $widths[0] + 1, $widths[1] + 1; + my $desc_wrap = + 79 - 7 - (length $indent) - $widths[0] - $widths[1] - 2; + + open my $oldguts, "<", "pod/perlguts.pod" + or die "$0 cannot open pod/perlguts.pod for reading: $!"; + while (<$oldguts>) { + print; + last if /^=for mg_vtable.pl begin/ + } + + print "\n", $indent . "mg_type\n"; + printf $format, @header; + printf $format, map {'-' x length $_} @header; + foreach (@rows) { + my ($type, $vtbl, $desc) = @$_; + $desc =~ tr/\n/ /; + my @cont; + if (length $desc > $desc_wrap) { + # If it's too long, first split on '(', if there. + # [Which, if there, is always short enough, currently. + # Make this more robust if that changes] + ($desc, @cont) = split /(?=\()/, $desc; + if (!@cont) { + ($desc, @cont) = $desc =~ /(.{1,$desc_wrap})(?: |\z)/g + } + } + printf $format, $type, $vtbl, $desc; + printf $format, '', '', $_ foreach @cont; + } + print "\n\n"; my $first = 1; for my $magic (sort @names) { @@ -442,10 +442,10 @@ EOH } print "\n"; - while (<$oldguts>) { - last if /^=for mg_vtable.pl end/; - } - do { print } while <$oldguts>; + while (<$oldguts>) { + last if /^=for mg_vtable.pl end/; + } + do { print } while <$oldguts>; })[0]; } @@ -503,7 +503,7 @@ while (my $name = shift @names) { my $data = $sig{$name}; push @vtable_names, $name; my @funcs = map { - $data->{$_} ? "Perl_magic_$data->{$_}" : 0; + $data->{$_} ? "Perl_magic_$data->{$_}" : 0; } qw(get set len clear free copy dup local); $funcs[0] = "(int (*)(pTHX_ SV *, MAGIC *))" . $funcs[0] if $data->{const}; @@ -520,8 +520,8 @@ while (my $name = shift @names) { #endif EOH foreach(@{$data->{alias}}) { - push @aliases, "#define want_vtbl_$_ want_vtbl_$name\n"; - push @vtable_names, $_; + push @aliases, "#define want_vtbl_$_ want_vtbl_$name\n"; + push @vtable_names, $_; } } @@ -542,4 +542,4 @@ print $vt "#define PL_vtbl_$_ PL_magic_vtables[want_vtbl_$_]\n" die "Too many vtable names" if @vtable_names > 63; read_only_bottom_close_and_rename($_) foreach $vt, $raw, $names; - close_and_rename($guts); + close_and_rename($guts); diff --git a/regen/mk_PL_charclass.pl b/regen/mk_PL_charclass.pl index 10802d6ae8..57e3f63c24 100644 --- a/regen/mk_PL_charclass.pl +++ b/regen/mk_PL_charclass.pl @@ -282,7 +282,7 @@ foreach my $bit_name (sort keys %bit_names) { } my $out_fh = open_new('l1_char_class_tab.h', '>', - {style => '*', by => $0, + {style => '*', by => $0, from => "Unicode::UCD"}); print $out_fh <<END; diff --git a/regen/mk_invlists.pl b/regen/mk_invlists.pl index 8c243bef70..d58e63cba9 100644 --- a/regen/mk_invlists.pl +++ b/regen/mk_invlists.pl @@ -52,7 +52,7 @@ my $table_name_prefix = "UNI_"; my $enum_name_re = qr / ^ [[:alpha:]] \w* $ /ax; my $out_fh = open_new('charclass_invlists.h', '>', - {style => '*', by => 'regen/mk_invlists.pl', + {style => '*', by => 'regen/mk_invlists.pl', from => "Unicode::UCD"}); my $in_file_pound_if = ""; @@ -3329,7 +3329,7 @@ for my $i (0 .. @perl_prop_synonyms - 1) { } my $uni_pl = open_new('lib/unicore/uni_keywords.pl', '>', - {style => '*', by => 'regen/mk_invlists.pl', + {style => '*', by => 'regen/mk_invlists.pl', from => "Unicode::UCD"}); { print $uni_pl "\%Unicode::UCD::uni_prop_ptrs_indices = (\n"; @@ -3352,7 +3352,7 @@ sub token_name } my $keywords_fh = open_new('uni_keywords.h', '>', - {style => '*', by => 'regen/mk_invlists.pl', + {style => '*', by => 'regen/mk_invlists.pl', from => "mph.pl"}); print $keywords_fh "\n#if defined(PERL_CORE) || defined(PERL_EXT_RE_BUILD)\n\n"; diff --git a/regen/opcode.pl b/regen/opcode.pl index df66201e9e..6f631158b9 100755 --- a/regen/opcode.pl +++ b/regen/opcode.pl @@ -25,20 +25,20 @@ BEGIN { } my $oc = open_new('opcode.h', '>', - {by => 'regen/opcode.pl', from => 'its data', - file => 'opcode.h', style => '*', - copyright => [1993 .. 2007]}); + {by => 'regen/opcode.pl', from => 'its data', + file => 'opcode.h', style => '*', + copyright => [1993 .. 2007]}); my $on = open_new('opnames.h', '>', - { by => 'regen/opcode.pl', from => 'its data', style => '*', - file => 'opnames.h', copyright => [1999 .. 2008] }); + { by => 'regen/opcode.pl', from => 'its data', style => '*', + file => 'opnames.h', copyright => [1999 .. 2008] }); my $oprivpm = open_new('lib/B/Op_private.pm', '>', - { by => 'regen/opcode.pl', + { by => 'regen/opcode.pl', from => "data in\nregen/op_private " ."and pod embedded in regen/opcode.pl", style => '#', - file => 'lib/B/Op_private.pm', + file => 'lib/B/Op_private.pm', copyright => [2014 .. 2014] }); # Read 'opcodes' data. @@ -59,7 +59,7 @@ while (<OPS>) { if $seen{$desc} and $key !~ "concat|transr|(?:intro|clone)cv|lvref"; die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key}; die qq[Opcode "freed" is reserved for the slab allocator\n] - if $key eq 'freed'; + if $key eq 'freed'; $seen{$desc} = qq[description of opcode "$key"]; $seen{$key} = qq[opcode "$key"]; @@ -78,84 +78,84 @@ my %alias; # Format is "this function" => "does these op names" my @raw_alias = ( - Perl_do_kv => [qw( keys values )], - Perl_unimplemented_op => [qw(padany custom)], - # All the ops with a body of { return NORMAL; } - Perl_pp_null => [qw(scalar regcmaybe lineseq scope)], - - Perl_pp_goto => ['dump'], - Perl_pp_require => ['dofile'], - Perl_pp_untie => ['dbmclose'], - Perl_pp_sysread => {read => '', recv => '#ifdef HAS_SOCKET'}, - Perl_pp_sysseek => ['seek'], - Perl_pp_ioctl => ['fcntl'], - Perl_pp_ssockopt => {gsockopt => '#ifdef HAS_SOCKET'}, - Perl_pp_getpeername => {getsockname => '#ifdef HAS_SOCKET'}, - Perl_pp_stat => ['lstat'], - Perl_pp_ftrowned => [qw(fteowned ftzero ftsock ftchr ftblk - ftfile ftdir ftpipe ftsuid ftsgid - ftsvtx)], - Perl_pp_fttext => ['ftbinary'], - Perl_pp_gmtime => ['localtime'], - Perl_pp_semget => [qw(shmget msgget)], - Perl_pp_semctl => [qw(shmctl msgctl)], - Perl_pp_ghostent => [qw(ghbyname ghbyaddr)], - Perl_pp_gnetent => [qw(gnbyname gnbyaddr)], - Perl_pp_gprotoent => [qw(gpbyname gpbynumber)], - Perl_pp_gservent => [qw(gsbyname gsbyport)], - Perl_pp_gpwent => [qw(gpwnam gpwuid)], - Perl_pp_ggrent => [qw(ggrnam ggrgid)], - Perl_pp_ftis => [qw(ftsize ftmtime ftatime ftctime)], - Perl_pp_chown => [qw(unlink chmod utime kill)], - Perl_pp_link => ['symlink'], - Perl_pp_ftrread => [qw(ftrwrite ftrexec fteread ftewrite - fteexec)], - Perl_pp_shmwrite => [qw(shmread msgsnd msgrcv semop)], - Perl_pp_syswrite => {send => '#ifdef HAS_SOCKET'}, - Perl_pp_defined => [qw(dor dorassign)], + Perl_do_kv => [qw( keys values )], + Perl_unimplemented_op => [qw(padany custom)], + # All the ops with a body of { return NORMAL; } + Perl_pp_null => [qw(scalar regcmaybe lineseq scope)], + + Perl_pp_goto => ['dump'], + Perl_pp_require => ['dofile'], + Perl_pp_untie => ['dbmclose'], + Perl_pp_sysread => {read => '', recv => '#ifdef HAS_SOCKET'}, + Perl_pp_sysseek => ['seek'], + Perl_pp_ioctl => ['fcntl'], + Perl_pp_ssockopt => {gsockopt => '#ifdef HAS_SOCKET'}, + Perl_pp_getpeername => {getsockname => '#ifdef HAS_SOCKET'}, + Perl_pp_stat => ['lstat'], + Perl_pp_ftrowned => [qw(fteowned ftzero ftsock ftchr ftblk + ftfile ftdir ftpipe ftsuid ftsgid + ftsvtx)], + Perl_pp_fttext => ['ftbinary'], + Perl_pp_gmtime => ['localtime'], + Perl_pp_semget => [qw(shmget msgget)], + Perl_pp_semctl => [qw(shmctl msgctl)], + Perl_pp_ghostent => [qw(ghbyname ghbyaddr)], + Perl_pp_gnetent => [qw(gnbyname gnbyaddr)], + Perl_pp_gprotoent => [qw(gpbyname gpbynumber)], + Perl_pp_gservent => [qw(gsbyname gsbyport)], + Perl_pp_gpwent => [qw(gpwnam gpwuid)], + Perl_pp_ggrent => [qw(ggrnam ggrgid)], + Perl_pp_ftis => [qw(ftsize ftmtime ftatime ftctime)], + Perl_pp_chown => [qw(unlink chmod utime kill)], + Perl_pp_link => ['symlink'], + Perl_pp_ftrread => [qw(ftrwrite ftrexec fteread ftewrite + fteexec)], + Perl_pp_shmwrite => [qw(shmread msgsnd msgrcv semop)], + Perl_pp_syswrite => {send => '#ifdef HAS_SOCKET'}, + Perl_pp_defined => [qw(dor dorassign)], Perl_pp_and => ['andassign'], - Perl_pp_or => ['orassign'], - Perl_pp_ucfirst => ['lcfirst'], - Perl_pp_sle => [qw(slt sgt sge)], - Perl_pp_print => ['say'], - Perl_pp_index => ['rindex'], - Perl_pp_oct => ['hex'], - Perl_pp_shift => ['pop'], - Perl_pp_sin => [qw(cos exp log sqrt)], - Perl_pp_bit_or => ['bit_xor'], - Perl_pp_nbit_or => ['nbit_xor'], - Perl_pp_sbit_or => ['sbit_xor'], - Perl_pp_rv2av => ['rv2hv'], - Perl_pp_akeys => ['avalues'], - Perl_pp_trans => [qw(trans transr)], - Perl_pp_chop => [qw(chop chomp)], - Perl_pp_schop => [qw(schop schomp)], - Perl_pp_bind => {connect => '#ifdef HAS_SOCKET'}, - Perl_pp_preinc => ['i_preinc'], - Perl_pp_predec => ['i_predec'], - Perl_pp_postinc => ['i_postinc'], - Perl_pp_postdec => ['i_postdec'], - Perl_pp_ehostent => [qw(enetent eprotoent eservent - spwent epwent sgrent egrent)], - Perl_pp_shostent => [qw(snetent sprotoent sservent)], - Perl_pp_aelemfast => ['aelemfast_lex'], - Perl_pp_grepstart => ['mapstart'], - ); + Perl_pp_or => ['orassign'], + Perl_pp_ucfirst => ['lcfirst'], + Perl_pp_sle => [qw(slt sgt sge)], + Perl_pp_print => ['say'], + Perl_pp_index => ['rindex'], + Perl_pp_oct => ['hex'], + Perl_pp_shift => ['pop'], + Perl_pp_sin => [qw(cos exp log sqrt)], + Perl_pp_bit_or => ['bit_xor'], + Perl_pp_nbit_or => ['nbit_xor'], + Perl_pp_sbit_or => ['sbit_xor'], + Perl_pp_rv2av => ['rv2hv'], + Perl_pp_akeys => ['avalues'], + Perl_pp_trans => [qw(trans transr)], + Perl_pp_chop => [qw(chop chomp)], + Perl_pp_schop => [qw(schop schomp)], + Perl_pp_bind => {connect => '#ifdef HAS_SOCKET'}, + Perl_pp_preinc => ['i_preinc'], + Perl_pp_predec => ['i_predec'], + Perl_pp_postinc => ['i_postinc'], + Perl_pp_postdec => ['i_postdec'], + Perl_pp_ehostent => [qw(enetent eprotoent eservent + spwent epwent sgrent egrent)], + Perl_pp_shostent => [qw(snetent sprotoent sservent)], + Perl_pp_aelemfast => ['aelemfast_lex'], + Perl_pp_grepstart => ['mapstart'], + ); while (my ($func, $names) = splice @raw_alias, 0, 2) { if (ref $names eq 'ARRAY') { - foreach (@$names) { + foreach (@$names) { $alias{$_} = [$func, '']; - } + } } else { - while (my ($opname, $cond) = each %$names) { + while (my ($opname, $cond) = each %$names) { $alias{$opname} = [$func, $cond]; - } + } } } foreach my $sock_func (qw(socket bind listen accept shutdown - ssockopt getpeername)) { + ssockopt getpeername)) { $alias{$sock_func} = ["Perl_pp_$sock_func", '#ifdef HAS_SOCKET'], } @@ -927,31 +927,31 @@ print $oc "#$restrict_to_core\n\n"; my @unimplemented; sub unimplemented { - if (@unimplemented) { - print $oc "#else\n"; - foreach (@unimplemented) { - print $oc "#define $_ Perl_unimplemented_op\n"; - } - print $oc "#endif\n"; - @unimplemented = (); - } + if (@unimplemented) { + print $oc "#else\n"; + foreach (@unimplemented) { + print $oc "#define $_ Perl_unimplemented_op\n"; + } + print $oc "#endif\n"; + @unimplemented = (); + } } for (@ops) { - my ($impl, $cond) = @{$alias{$_} || ["Perl_pp_$_", '']}; - my $op_func = "Perl_pp_$_"; - - if ($cond ne $last_cond) { - # A change in condition. (including to or from no condition) - unimplemented(); - $last_cond = $cond; - if ($last_cond) { - print $oc "$last_cond\n"; - } - } - push @unimplemented, $op_func if $last_cond; - print $oc "#define $op_func $impl\n" if $impl ne $op_func; + my ($impl, $cond) = @{$alias{$_} || ["Perl_pp_$_", '']}; + my $op_func = "Perl_pp_$_"; + + if ($cond ne $last_cond) { + # A change in condition. (including to or from no condition) + unimplemented(); + $last_cond = $cond; + if ($last_cond) { + print $oc "$last_cond\n"; + } + } + push @unimplemented, $op_func if $last_cond; + print $oc "#define $op_func $impl\n" if $impl ne $op_func; } # If the last op was conditional, we need to close it out: unimplemented(); @@ -985,7 +985,7 @@ for (@ops) { } print $oc <<'END'; - "freed", + "freed", }; #endif @@ -1005,7 +1005,7 @@ for (@ops) { } print $oc <<'END'; - "freed op", + "freed op", }; #endif @@ -1027,10 +1027,10 @@ for (@ops) { my $op_func = "Perl_pp_$_"; my $name = $alias{$_}; if ($name && $name->[0] ne $op_func) { - print $oc "\t$op_func,\t/* implemented by $name->[0] */\n"; + print $oc "\t$op_func,\t/* implemented by $name->[0] */\n"; } else { - print $oc "\t$op_func,\n"; + print $oc "\t$op_func,\n"; } } @@ -1118,40 +1118,40 @@ for my $op (@ops) { my $argsum = 0; my $flags = $flags{$op}; for my $flag (keys %opflags) { - if ($flags =~ s/$flag//) { - die "Flag collision for '$op' ($flags{$op}, $flag)\n" - if $argsum & $opflags{$flag}; - $argsum |= $opflags{$flag}; - } + if ($flags =~ s/$flag//) { + die "Flag collision for '$op' ($flags{$op}, $flag)\n" + if $argsum & $opflags{$flag}; + $argsum |= $opflags{$flag}; + } } die qq[Opcode '$op' has no class indicator ($flags{$op} => $flags)\n] - unless exists $opclass{$flags}; + unless exists $opclass{$flags}; $argsum |= $opclass{$flags} << $OCSHIFT; my $argshift = $OASHIFT; for my $arg (split(' ',$args{$op})) { - if ($arg =~ s/^D//) { - # handle 1st, just to put D 1st. - $OP_IS_DIRHOP{$op} = $opnum{$op}; - } - if ($arg =~ /^F/) { - # record opnums of these opnames - $OP_IS_SOCKET{$op} = $opnum{$op} if $arg =~ s/s//; - $OP_IS_FILETEST{$op} = $opnum{$op} if $arg =~ s/-//; - $OP_IS_FT_ACCESS{$op} = $opnum{$op} if $arg =~ s/\+//; + if ($arg =~ s/^D//) { + # handle 1st, just to put D 1st. + $OP_IS_DIRHOP{$op} = $opnum{$op}; + } + if ($arg =~ /^F/) { + # record opnums of these opnames + $OP_IS_SOCKET{$op} = $opnum{$op} if $arg =~ s/s//; + $OP_IS_FILETEST{$op} = $opnum{$op} if $arg =~ s/-//; + $OP_IS_FT_ACCESS{$op} = $opnum{$op} if $arg =~ s/\+//; + } + elsif ($arg =~ /^S./) { + $OP_IS_NUMCOMPARE{$op} = $opnum{$op} if $arg =~ s/<//; + $OP_IS_INFIX_BIT {$op} = $opnum{$op} if $arg =~ s/\|//; } - elsif ($arg =~ /^S./) { - $OP_IS_NUMCOMPARE{$op} = $opnum{$op} if $arg =~ s/<//; - $OP_IS_INFIX_BIT {$op} = $opnum{$op} if $arg =~ s/\|//; - } - my $argnum = ($arg =~ s/\?//) ? 8 : 0; + my $argnum = ($arg =~ s/\?//) ? 8 : 0; die "op = $op, arg = $arg\n" - unless exists $argnum{$arg}; - $argnum += $argnum{$arg}; - die "Argument overflow for '$op'\n" - if $argshift >= $ARGBITS || - $argnum > ((1 << ($ARGBITS - $argshift)) - 1); - $argsum += $argnum << $argshift; - $argshift += 4; + unless exists $argnum{$arg}; + $argnum += $argnum{$arg}; + die "Argument overflow for '$op'\n" + if $argshift >= $ARGBITS || + $argnum > ((1 << ($ARGBITS - $argshift)) - 1); + $argsum += $argnum << $argshift; + $argshift += 4; } $argsum = sprintf("0x%08x", $argsum); print $oc "\t", tab(3, "$argsum,"), "/* $op */\n"; @@ -1184,41 +1184,41 @@ gen_op_is_macro( \%OP_IS_INFIX_BIT, 'OP_IS_INFIX_BIT'); sub gen_op_is_macro { my ($op_is, $macname) = @_; if (keys %$op_is) { - - # get opnames whose numbers are lowest and highest - my ($first, @rest) = sort { - $op_is->{$a} <=> $op_is->{$b} - } keys %$op_is; - - my $last = pop @rest; # @rest slurped, get its last - die "Invalid range of ops: $first .. $last\n" unless $last; - - print $on "\n#define $macname(op) \\\n\t("; - - # verify that op-ct matches 1st..last range (and fencepost) - # (we know there are no dups) - if ( $op_is->{$last} - $op_is->{$first} == scalar @rest + 1) { - - # contiguous ops -> optimized version - print $on "(op) >= OP_" . uc($first) - . " && (op) <= OP_" . uc($last); - } - else { - print $on join(" || \\\n\t ", - map { "(op) == OP_" . uc() } sort keys %$op_is); - } - print $on ")\n"; + + # get opnames whose numbers are lowest and highest + my ($first, @rest) = sort { + $op_is->{$a} <=> $op_is->{$b} + } keys %$op_is; + + my $last = pop @rest; # @rest slurped, get its last + die "Invalid range of ops: $first .. $last\n" unless $last; + + print $on "\n#define $macname(op) \\\n\t("; + + # verify that op-ct matches 1st..last range (and fencepost) + # (we know there are no dups) + if ( $op_is->{$last} - $op_is->{$first} == scalar @rest + 1) { + + # contiguous ops -> optimized version + print $on "(op) >= OP_" . uc($first) + . " && (op) <= OP_" . uc($last); + } + else { + print $on join(" || \\\n\t ", + map { "(op) == OP_" . uc() } sort keys %$op_is); + } + print $on ")\n"; } } my $pp = open_new('pp_proto.h', '>', - { by => 'opcode.pl', from => 'its data' }); + { by => 'opcode.pl', from => 'its data' }); { my %funcs; for (@ops) { - my $name = $alias{$_} ? $alias{$_}[0] : "Perl_pp_$_"; - ++$funcs{$name}; + my $name = $alias{$_} ? $alias{$_}[0] : "Perl_pp_$_"; + ++$funcs{$name}; } print $pp "PERL_CALLCONV OP *$_(pTHX);\n" foreach sort keys %funcs; } diff --git a/regen/overload.pl b/regen/overload.pl index 38dac323c0..cbd01b5d1b 100644 --- a/regen/overload.pl +++ b/regen/overload.pl @@ -32,14 +32,14 @@ while (<DATA>) { my ($c, $h) = map { open_new($_, '>', - { by => 'regen/overload.pl', file => $_, style => '*', - copyright => [1997, 1998, 2000, 2001, 2005 .. 2007, 2011] }); + { by => 'regen/overload.pl', file => $_, style => '*', + copyright => [1997, 1998, 2000, 2001, 2005 .. 2007, 2011] }); } 'overload.inc', 'overload.h'; mkdir("lib/overload", 0777) unless -d 'lib/overload'; my $p = open_new('lib/overload/numbers.pm', '>', - { by => 'regen/overload.pl', - file => 'lib/overload/numbers.pm', copyright => [2008] }); + { by => 'regen/overload.pl', + file => 'lib/overload/numbers.pm', copyright => [2008] }); { local $" = "\n "; @@ -70,7 +70,7 @@ for (0..$#enums) { my $l = 3 - int((length($enums[$_]) + 9) / 8); $l = 1 if $l < 1; printf $h " %s_amg,%s/* 0x%02x %-8s */\n", $enums[$_], - ("\t" x $l), $_, $op; + ("\t" x $l), $_, $op; } print $h <<'EOF'; diff --git a/regen/reentr.pl b/regen/reentr.pl index 9d93fdf1ff..5742278fe9 100644 --- a/regen/reentr.pl +++ b/regen/reentr.pl @@ -27,16 +27,16 @@ my %opts; getopts('Uv', \%opts); my %map = ( - V => "void", - A => "char*", # as an input argument - B => "char*", # as an output argument - C => "const char*", # as a read-only input argument - I => "int", - L => "long", - W => "size_t", - H => "FILE**", - E => "int*", - ); + V => "void", + A => "char*", # as an input argument + B => "char*", # as an output argument + C => "const char*", # as a read-only input argument + I => "int", + L => "long", + W => "size_t", + H => "FILE**", + E => "int*", + ); # (See the definitions after __DATA__.) # In func|inc|type|... a "S" means "type*", and a "R" means "type**". @@ -53,11 +53,11 @@ my %map = ( sub open_print_header { my ($file, $quote) = @_; return open_new($file, '>', - { by => 'regen/reentr.pl', - from => 'data in regen/reentr.pl', - file => $file, style => '*', - copyright => [2002, 2003, 2005 .. 2007], - quote => $quote }); + { by => 'regen/reentr.pl', + from => 'data in regen/reentr.pl', + file => $file, style => '*', + copyright => [2002, 2003, 2005 .. 2007], + quote => $quote }); } my $h = open_print_header('reentr.h'); @@ -204,17 +204,17 @@ while (<DATA>) { # Read in the prototypes. push @seenf, $func; my %m = %map; if ($type) { - $m{S} = "$type*"; - $m{R} = "$type**"; + $m{S} = "$type*"; + $m{R} = "$type**"; } # Set any special mapping variables (like X=x_t) if (@p) { - while ($p[-1] =~ /=/) { - my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/); - $m{$k} = $v; - pop @p; - } + while ($p[-1] =~ /=/) { + my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/); + $m{$k} = $v; + pop @p; + } } # If given the -U option open up the metaconfig unit for this function. @@ -223,24 +223,24 @@ while (<DATA>) { # Read in the prototypes. } if ($opts{U}) { - # The metaconfig units needs prerequisite dependencies. - my $prereqs = ''; - my $prereqh = ''; - my $prereqsh = ''; - if ($hdr ne 'stdio') { # There's no i_stdio. - $prereqs = "i_$hdr"; - $prereqh = "$hdr.h"; - $prereqsh = "\$$prereqs $prereqh"; - } - my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads); - push @prereq, $prereqs; + # The metaconfig units needs prerequisite dependencies. + my $prereqs = ''; + my $prereqh = ''; + my $prereqsh = ''; + if ($hdr ne 'stdio') { # There's no i_stdio. + $prereqs = "i_$hdr"; + $prereqh = "$hdr.h"; + $prereqsh = "\$$prereqs $prereqh"; + } + my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads); + push @prereq, $prereqs; my $hdrs = "\$i_systypes sys/types.h define stdio.h $prereqsh"; if ($hdr eq 'time') { - $hdrs .= " \$i_systime sys/time.h"; - push @prereq, 'i_systime'; - } - # Output the metaconfig unit header. - print U <<"EOF"; + $hdrs .= " \$i_systime sys/time.h"; + push @prereq, 'i_systime'; + } + # Output the metaconfig unit header. + print U <<"EOF"; ?RCS: \$Id: d_${func}_r.U,v $ ?RCS: ?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi @@ -285,27 +285,27 @@ eval \$inlibc case "\$d_${func}_r" in "\$define") EOF - print U <<"EOF"; - hdrs="$hdrs" - case "\$d_${func}_r_proto:\$usethreads" in - ":define") d_${func}_r_proto=define - set d_${func}_r_proto ${func}_r \$hdrs - eval \$hasproto ;; - *) ;; - esac - case "\$d_${func}_r_proto" in - define) + print U <<"EOF"; + hdrs="$hdrs" + case "\$d_${func}_r_proto:\$usethreads" in + ":define") d_${func}_r_proto=define + set d_${func}_r_proto ${func}_r \$hdrs + eval \$hasproto ;; + *) ;; + esac + case "\$d_${func}_r_proto" in + define) EOF } for my $p (@p) { my ($r, $a) = ($p =~ /^(.)_(.+)/); - my $v = join(", ", map { $m{$_} } split '', $a); - if ($opts{U}) { - print U <<"EOF"; - case "\$${func}_r_proto" in - ''|0) try='$m{$r} ${func}_r($v);' - ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;; - esac + my $v = join(", ", map { $m{$_} } split '', $a); + if ($opts{U}) { + print U <<"EOF"; + case "\$${func}_r_proto" in + ''|0) try='$m{$r} ${func}_r($v);' + ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;; + esac EOF } $seenh{$func}->{$p}++; @@ -314,35 +314,35 @@ EOF $seent{$func} = $type; $seens{$func} = $m{S}; $seend{$func} = $m{D}; - $seenm{$func} = \%m; + $seenm{$func} = \%m; } if ($opts{U}) { - print U <<"EOF"; - case "\$${func}_r_proto" in - ''|0) d_${func}_r=undef + print U <<"EOF"; + case "\$${func}_r_proto" in + ''|0) d_${func}_r=undef ${func}_r_proto=0 - echo "Disabling ${func}_r, cannot determine prototype." >&4 ;; - * ) case "\$${func}_r_proto" in - REENTRANT_PROTO*) ;; - *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;; - esac - echo "Prototype: \$try" ;; - esac - ;; - *) case "\$usethreads" in - define) echo "${func}_r has no prototype, not using it." >&4 ;; - esac - d_${func}_r=undef - ${func}_r_proto=0 - ;; - esac - ;; + echo "Disabling ${func}_r, cannot determine prototype." >&4 ;; + * ) case "\$${func}_r_proto" in + REENTRANT_PROTO*) ;; + *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;; + esac + echo "Prototype: \$try" ;; + esac + ;; + *) case "\$usethreads" in + define) echo "${func}_r has no prototype, not using it." >&4 ;; + esac + d_${func}_r=undef + ${func}_r_proto=0 + ;; + esac + ;; *) ${func}_r_proto=0 - ;; + ;; esac EOF - close(U); + close(U); } } @@ -352,8 +352,8 @@ close DATA; # Write out all the known prototype signatures. my $i = 1; for my $p (sort keys %seenp) { - print $h "# define REENTRANT_PROTO_${p} ${i}\n"; - $i++; + print $h "# define REENTRANT_PROTO_${p} ${i}\n"; + $i++; } } @@ -379,10 +379,10 @@ sub pushssif { sub pushinitfree { my $func = shift; push @init, <<EOF; - Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char); + Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char); EOF push @free, <<EOF; - Safefree(PL_reentrant_buffer->_${func}_buffer); + Safefree(PL_reentrant_buffer->_${func}_buffer); EOF } @@ -396,18 +396,18 @@ sub define { EOF my $GENFUNC; for my $func (@F) { - my $FUNC = uc $func; - my $HAS = "${FUNC}_R_HAS_$n"; - push @H, $HAS; - my @h = grep { /$p/ } @{$seena{$func}}; - unless (defined $GENFUNC) { - $GENFUNC = $FUNC; - $GENFUNC =~ s/^GET//; - } - if (@h) { - push @define, "# if defined(HAS_${FUNC}_R) && (" . join(" || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n"; - - push @define, <<EOF; + my $FUNC = uc $func; + my $HAS = "${FUNC}_R_HAS_$n"; + push @H, $HAS; + my @h = grep { /$p/ } @{$seena{$func}}; + unless (defined $GENFUNC) { + $GENFUNC = $FUNC; + $GENFUNC =~ s/^GET//; + } + if (@h) { + push @define, "# if defined(HAS_${FUNC}_R) && (" . join(" || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n"; + + push @define, <<EOF; # define $HAS # else # undef $HAS @@ -488,199 +488,199 @@ for my $func (@seenf) { my $ifdef = "# ifdef HAS_${FUNC}_R\n"; my $endif = "# endif /* HAS_${FUNC}_R */\n\n"; if (exists $seena{$func}) { - my @p = @{$seena{$func}}; - if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) { - pushssif $ifdef; - push @struct, <<EOF; - char* _${func}_buffer; - size_t _${func}_size; + my @p = @{$seena{$func}}; + if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) { + pushssif $ifdef; + push @struct, <<EOF; + char* _${func}_buffer; + size_t _${func}_size; EOF my $size = ($func =~ /^(asctime|ctime)$/) ? 26 : "REENTRANTSMALLSIZE"; - push @size, <<EOF; - PL_reentrant_buffer->_${func}_size = $size; + push @size, <<EOF; + PL_reentrant_buffer->_${func}_size = $size; EOF - pushinitfree $func; - pushssif $endif; - } - elsif ($func =~ /^(gm|local)time$/) { - pushssif $ifdef; - push @struct, <<EOF; # Fixed size - $seent{$func} _${func}_struct; + pushinitfree $func; + pushssif $endif; + } + elsif ($func =~ /^(gm|local)time$/) { + pushssif $ifdef; + push @struct, <<EOF; # Fixed size + $seent{$func} _${func}_struct; EOF - pushssif $endif; - } + pushssif $endif; + } elsif ($func =~ /^(crypt)$/) { - pushssif $ifdef; - push @struct, <<EOF; + pushssif $ifdef; + push @struct, <<EOF; # if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD - $seend{$func} _${func}_data; + $seend{$func} _${func}_data; # else - $seent{$func} *_${func}_struct_buffer; + $seent{$func} *_${func}_struct_buffer; # endif EOF push @init, <<EOF; # if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD - PL_reentrant_buffer->_${func}_struct_buffer = 0; + PL_reentrant_buffer->_${func}_struct_buffer = 0; # endif EOF push @free, <<EOF; # if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD - Safefree(PL_reentrant_buffer->_${func}_struct_buffer); + Safefree(PL_reentrant_buffer->_${func}_struct_buffer); # endif EOF - pushssif $endif; - } + pushssif $endif; + } elsif ($func =~ /^(getgrnam|getpwnam|getspnam)$/) { - pushssif $ifdef; - # 'genfunc' can be read either as 'generic' or 'genre', - # it represents a group of functions. - my $genfunc = $func; - $genfunc =~ s/nam/ent/g; - $genfunc =~ s/^get//; - my $GENFUNC = uc $genfunc; - push @struct, <<EOF; - $seent{$func} _${genfunc}_struct; - char* _${genfunc}_buffer; - size_t _${genfunc}_size; + pushssif $ifdef; + # 'genfunc' can be read either as 'generic' or 'genre', + # it represents a group of functions. + my $genfunc = $func; + $genfunc =~ s/nam/ent/g; + $genfunc =~ s/^get//; + my $GENFUNC = uc $genfunc; + push @struct, <<EOF; + $seent{$func} _${genfunc}_struct; + char* _${genfunc}_buffer; + size_t _${genfunc}_size; EOF push @struct, <<EOF; # ifdef USE_${GENFUNC}_PTR - $seent{$func}* _${genfunc}_ptr; + $seent{$func}* _${genfunc}_ptr; # endif EOF - push @struct, <<EOF; + push @struct, <<EOF; # ifdef USE_${GENFUNC}_FPTR - FILE* _${genfunc}_fptr; + FILE* _${genfunc}_fptr; # endif EOF - push @init, <<EOF; + push @init, <<EOF; # ifdef USE_${GENFUNC}_FPTR - PL_reentrant_buffer->_${genfunc}_fptr = NULL; + PL_reentrant_buffer->_${genfunc}_fptr = NULL; # endif EOF - my $sc = $genfunc eq 'grent' ? - '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX'; - my $sz = "_${genfunc}_size"; - push @size, <<EOF; + my $sc = $genfunc eq 'grent' ? + '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX'; + my $sz = "_${genfunc}_size"; + push @size, <<EOF; # if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__) - PL_reentrant_buffer->$sz = sysconf($sc); - if (PL_reentrant_buffer->$sz == (size_t) -1) - PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE; + PL_reentrant_buffer->$sz = sysconf($sc); + if (PL_reentrant_buffer->$sz == (size_t) -1) + PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE; # elif defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ) - PL_reentrant_buffer->$sz = SIABUFSIZ; + PL_reentrant_buffer->$sz = SIABUFSIZ; # elif defined(__sgi) - PL_reentrant_buffer->$sz = BUFSIZ; + PL_reentrant_buffer->$sz = BUFSIZ; # else - PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE; + PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE; # endif EOF - pushinitfree $genfunc; - pushssif $endif; - } + pushinitfree $genfunc; + pushssif $endif; + } elsif ($func =~ /^(gethostbyname|getnetbyname|getservbyname|getprotobyname)$/) { - pushssif $ifdef; - my $genfunc = $func; - $genfunc =~ s/byname/ent/; - $genfunc =~ s/^get//; - my $GENFUNC = uc $genfunc; - my $D = ifprotomatch($FUNC, grep {/D/} @p); - my $d = $seend{$func}; - $d =~ s/\*$//; # snip: we need the base type. - push @struct, <<EOF; - $seent{$func} _${genfunc}_struct; + pushssif $ifdef; + my $genfunc = $func; + $genfunc =~ s/byname/ent/; + $genfunc =~ s/^get//; + my $GENFUNC = uc $genfunc; + my $D = ifprotomatch($FUNC, grep {/D/} @p); + my $d = $seend{$func}; + $d =~ s/\*$//; # snip: we need the base type. + push @struct, <<EOF; + $seent{$func} _${genfunc}_struct; # if $D - $d _${genfunc}_data; + $d _${genfunc}_data; # else - char* _${genfunc}_buffer; - size_t _${genfunc}_size; + char* _${genfunc}_buffer; + size_t _${genfunc}_size; # endif # ifdef USE_${GENFUNC}_PTR - $seent{$func}* _${genfunc}_ptr; + $seent{$func}* _${genfunc}_ptr; # endif EOF push @struct, <<EOF; # ifdef USE_${GENFUNC}_ERRNO - int _${genfunc}_errno; + int _${genfunc}_errno; # endif EOF - push @size, <<EOF; + push @size, <<EOF; # if !($D) - PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE; + PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE; # endif EOF - push @init, <<EOF; + push @init, <<EOF; # if !($D) - Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char); + Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char); # endif EOF - push @free, <<EOF; + push @free, <<EOF; # if !($D) - Safefree(PL_reentrant_buffer->_${genfunc}_buffer); + Safefree(PL_reentrant_buffer->_${genfunc}_buffer); # endif EOF - pushssif $endif; - } + pushssif $endif; + } elsif ($func =~ /^(readdir|readdir64)$/) { - pushssif $ifdef; - my $R = ifprotomatch($FUNC, grep {/R/} @p); - push @struct, <<EOF; - $seent{$func}* _${func}_struct; - size_t _${func}_size; + pushssif $ifdef; + my $R = ifprotomatch($FUNC, grep {/R/} @p); + push @struct, <<EOF; + $seent{$func}* _${func}_struct; + size_t _${func}_size; # if $R - $seent{$func}* _${func}_ptr; + $seent{$func}* _${func}_ptr; # endif EOF - push @size, <<EOF; - /* This is the size Solaris recommends. - * (though we go static, should use pathconf() instead) */ - PL_reentrant_buffer->_${func}_size = sizeof($seent{$func}) + MAXPATHLEN + 1; + push @size, <<EOF; + /* This is the size Solaris recommends. + * (though we go static, should use pathconf() instead) */ + PL_reentrant_buffer->_${func}_size = sizeof($seent{$func}) + MAXPATHLEN + 1; EOF push @init, <<EOF; - PL_reentrant_buffer->_${func}_struct = ($seent{$func}*)safemalloc(PL_reentrant_buffer->_${func}_size); + PL_reentrant_buffer->_${func}_struct = ($seent{$func}*)safemalloc(PL_reentrant_buffer->_${func}_size); EOF - push @free, <<EOF; - Safefree(PL_reentrant_buffer->_${func}_struct); + push @free, <<EOF; + Safefree(PL_reentrant_buffer->_${func}_struct); EOF - pushssif $endif; - } + pushssif $endif; + } - push @wrap, $ifdef; + push @wrap, $ifdef; - push @wrap, <<EOF; + push @wrap, <<EOF; # if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1) # undef $func EOF # Write out what we have learned. - + my @v = 'a'..'z'; my $v = join(", ", @v[0..$seenu{$func}-1]); - for my $p (@p) { - my ($r, $a) = split '_', $p; - my $test = $r eq 'I' ? ' == 0' : ''; - my $true = 1; - my $genfunc = $func; - if ($genfunc =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) { - $genfunc = "${1}ent"; - } - my $b = $a; - my $w = ''; - substr($b, 0, $seenu{$func}) = ''; - if ($b =~ /R/) { - $true = "PL_reentrant_buffer->_${genfunc}_ptr"; - } elsif ($b =~ /S/) { - if ($func =~ /^readdir/) { - $true = "PL_reentrant_buffer->_${genfunc}_struct"; - } else { - $true = "&PL_reentrant_buffer->_${genfunc}_struct"; - } - } elsif ($b =~ /B/) { - $true = "PL_reentrant_buffer->_${genfunc}_buffer"; - } - if (length $b) { - $w = join ", ", + for my $p (@p) { + my ($r, $a) = split '_', $p; + my $test = $r eq 'I' ? ' == 0' : ''; + my $true = 1; + my $genfunc = $func; + if ($genfunc =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) { + $genfunc = "${1}ent"; + } + my $b = $a; + my $w = ''; + substr($b, 0, $seenu{$func}) = ''; + if ($b =~ /R/) { + $true = "PL_reentrant_buffer->_${genfunc}_ptr"; + } elsif ($b =~ /S/) { + if ($func =~ /^readdir/) { + $true = "PL_reentrant_buffer->_${genfunc}_struct"; + } else { + $true = "&PL_reentrant_buffer->_${genfunc}_struct"; + } + } elsif ($b =~ /B/) { + $true = "PL_reentrant_buffer->_${genfunc}_buffer"; + } + if (length $b) { + $w = join ", ", map { $_ eq 'R' ? "&PL_reentrant_buffer->_${genfunc}_ptr" : $_ eq 'E' @@ -701,13 +701,13 @@ EOF : "&PL_reentrant_buffer->_${genfunc}_struct") : $_ } split '', $b; - $w = ", $w" if length $v; - } + $w = ", $w" if length $v; + } # This needs a special case, see its definition in config.h my $setup = ($func eq 'localtime') ? "L_R_TZSET " : ""; - my $call = "$setup${func}_r($v$w)"; + my $call = "$setup${func}_r($v$w)"; # Must make OpenBSD happy my $memzero = ''; @@ -715,46 +715,46 @@ EOF ($genfunc eq 'protoent' || $genfunc eq 'servent')) { $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data)),'; } - push @wrap, <<EOF; + push @wrap, <<EOF; # if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p EOF - if ($r eq 'V' || $r eq 'B') { - push @wrap, <<EOF; + if ($r eq 'V' || $r eq 'B') { + push @wrap, <<EOF; # define $func($v) $call EOF - } else { - if ($func =~ /^get/) { - my $rv = $v ? ", $v" : ""; - if ($r eq 'I') { - push @wrap, <<EOF; + } else { + if ($func =~ /^get/) { + my $rv = $v ? ", $v" : ""; + if ($r eq 'I') { + push @wrap, <<EOF; # define $func($v) ($memzero(PL_reentrant_retint = $call)$test ? $true : ((PL_reentrant_retint == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0)) EOF - } else { - push @wrap, <<EOF; + } else { + push @wrap, <<EOF; # define $func($v) ($call$test ? $true : ((errno == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0)) EOF } - } else { - push @wrap, <<EOF; + } else { + push @wrap, <<EOF; # define $func($v) ($call$test ? $true : 0) EOF - } - } - push @wrap, <<EOF; # !defined(xxx) && XXX_R_PROTO == REENTRANT_PROTO_Y_TS + } + } + push @wrap, <<EOF; # !defined(xxx) && XXX_R_PROTO == REENTRANT_PROTO_Y_TS # endif EOF - } - push @wrap, <<EOF; + } + push @wrap, <<EOF; # if defined($func) # define PERL_REENTR_USING_${FUNC}_R # endif EOF - push @wrap, <<EOF; # defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1) + push @wrap, <<EOF; # defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1) # endif EOF - push @wrap, $endif, "\n"; + push @wrap, $endif, "\n"; } } @@ -818,14 +818,14 @@ print $c <<"EOF"; #define RenewDouble(data_pointer, size_pointer, type) \\ STMT_START { \\ - const size_t size = MAX(*(size_pointer), 1) * 2; \\ - Renew((data_pointer), (size), type); \\ - *(size_pointer) = size; \\ + const size_t size = MAX(*(size_pointer), 1) * 2; \\ + Renew((data_pointer), (size), type); \\ + *(size_pointer) = size; \\ } STMT_END void Perl_reentrant_size(pTHX) { - PERL_UNUSED_CONTEXT; + PERL_UNUSED_CONTEXT; /* Set the sizes of the reentrant buffers */ @@ -840,14 +840,14 @@ Perl_reentrant_size(pTHX) { void Perl_reentrant_init(pTHX) { - PERL_UNUSED_CONTEXT; + PERL_UNUSED_CONTEXT; /* Initialize the whole thing */ #ifdef USE_REENTRANT_API - Newx(PL_reentrant_buffer, 1, REENTR); - Perl_reentrant_size(aTHX); + Newx(PL_reentrant_buffer, 1, REENTR); + Perl_reentrant_size(aTHX); @init #endif /* USE_REENTRANT_API */ @@ -856,14 +856,14 @@ Perl_reentrant_init(pTHX) { void Perl_reentrant_free(pTHX) { - PERL_UNUSED_CONTEXT; + PERL_UNUSED_CONTEXT; /* Tear down */ #ifdef USE_REENTRANT_API @free - Safefree(PL_reentrant_buffer); + Safefree(PL_reentrant_buffer); #endif /* USE_REENTRANT_API */ } @@ -904,7 +904,7 @@ Perl_reentrant_retry(const char *f, ...) #ifdef HAS_GETSPNAM_R - /* This is a #define as has no corresponding keyword */ + /* This is a #define as has no corresponding keyword */ if (strEQ(f, "getspnam")) { key = KEY_getspnam; } @@ -927,36 +927,36 @@ Perl_reentrant_retry(const char *f, ...) case KEY_gethostbyaddr: case KEY_gethostbyname: case KEY_endhostent: - { + { char * host_addr; Size_t asize; char * host_name; int anint; # ifdef PERL_REENTRANT_MAXSIZE - if (PL_reentrant_buffer->_hostent_size <= - PERL_REENTRANT_MAXSIZE / 2) + if (PL_reentrant_buffer->_hostent_size <= + PERL_REENTRANT_MAXSIZE / 2) # endif RenewDouble(PL_reentrant_buffer->_hostent_buffer, &PL_reentrant_buffer->_hostent_size, char); switch (key) { - case KEY_gethostbyaddr: - host_addr = va_arg(ap, char *); - asize = va_arg(ap, Size_t); - anint = va_arg(ap, int); + case KEY_gethostbyaddr: + host_addr = va_arg(ap, char *); + asize = va_arg(ap, Size_t); + anint = va_arg(ap, int); /* socklen_t is what Posix 2001 says this should be */ - retptr = gethostbyaddr(host_addr, (socklen_t) asize, anint); break; - case KEY_gethostbyname: - host_name = va_arg(ap, char *); - retptr = gethostbyname(host_name); break; - case KEY_endhostent: - retptr = gethostent(); break; - default: - SETERRNO(ERANGE, LIB_INVARG); - break; - } - } - break; + retptr = gethostbyaddr(host_addr, (socklen_t) asize, anint); break; + case KEY_gethostbyname: + host_name = va_arg(ap, char *); + retptr = gethostbyname(host_name); break; + case KEY_endhostent: + retptr = gethostent(); break; + default: + SETERRNO(ERANGE, LIB_INVARG); + break; + } + } + break; # endif # ifdef USE_GRENT_BUFFER @@ -964,35 +964,35 @@ Perl_reentrant_retry(const char *f, ...) case KEY_getgrent: case KEY_getgrgid: case KEY_getgrnam: - { + { char * name; Gid_t gid; # ifdef PERL_REENTRANT_MAXSIZE - if (PL_reentrant_buffer->_grent_size <= - PERL_REENTRANT_MAXSIZE / 2) + if (PL_reentrant_buffer->_grent_size <= + PERL_REENTRANT_MAXSIZE / 2) # endif RenewDouble(PL_reentrant_buffer->_grent_buffer, &PL_reentrant_buffer->_grent_size, char); switch (key) { - case KEY_getgrnam: - name = va_arg(ap, char *); - retptr = getgrnam(name); break; - case KEY_getgrgid: + case KEY_getgrnam: + name = va_arg(ap, char *); + retptr = getgrnam(name); break; + case KEY_getgrgid: # if Gid_t_size < INTSIZE gid = (Gid_t)va_arg(ap, int); # else - gid = va_arg(ap, Gid_t); + gid = va_arg(ap, Gid_t); # endif - retptr = getgrgid(gid); break; - case KEY_getgrent: - retptr = getgrent(); break; - default: - SETERRNO(ERANGE, LIB_INVARG); - break; - } - } - break; + retptr = getgrgid(gid); break; + case KEY_getgrent: + retptr = getgrent(); break; + default: + SETERRNO(ERANGE, LIB_INVARG); + break; + } + } + break; # endif # ifdef USE_NETENT_BUFFER @@ -1000,14 +1000,14 @@ Perl_reentrant_retry(const char *f, ...) case KEY_getnetbyaddr: case KEY_getnetbyname: case KEY_getnetent: - { + { char * name; Netdb_net_t net; int anint; # ifdef PERL_REENTRANT_MAXSIZE - if (PL_reentrant_buffer->_netent_size <= - PERL_REENTRANT_MAXSIZE / 2) + if (PL_reentrant_buffer->_netent_size <= + PERL_REENTRANT_MAXSIZE / 2) # endif RenewDouble(PL_reentrant_buffer->_netent_buffer, &PL_reentrant_buffer->_netent_size, char); @@ -1024,9 +1024,9 @@ Perl_reentrant_retry(const char *f, ...) default: SETERRNO(ERANGE, LIB_INVARG); break; - } - } - break; + } + } + break; # endif # ifdef USE_PWENT_BUFFER @@ -1034,66 +1034,66 @@ Perl_reentrant_retry(const char *f, ...) case KEY_getpwnam: case KEY_getpwuid: case KEY_getpwent: - { + { Uid_t uid; char * name; # ifdef PERL_REENTRANT_MAXSIZE - if (PL_reentrant_buffer->_pwent_size <= - PERL_REENTRANT_MAXSIZE / 2) + if (PL_reentrant_buffer->_pwent_size <= + PERL_REENTRANT_MAXSIZE / 2) # endif RenewDouble(PL_reentrant_buffer->_pwent_buffer, &PL_reentrant_buffer->_pwent_size, char); switch (key) { - case KEY_getpwnam: - name = va_arg(ap, char *); - retptr = getpwnam(name); break; - case KEY_getpwuid: + case KEY_getpwnam: + name = va_arg(ap, char *); + retptr = getpwnam(name); break; + case KEY_getpwuid: # if Uid_t_size < INTSIZE - uid = (Uid_t)va_arg(ap, int); + uid = (Uid_t)va_arg(ap, int); # else - uid = va_arg(ap, Uid_t); + uid = va_arg(ap, Uid_t); # endif - retptr = getpwuid(uid); break; + retptr = getpwuid(uid); break; # if defined(HAS_GETPWENT) || defined(HAS_GETPWENT_R) - case KEY_getpwent: - retptr = getpwent(); break; + case KEY_getpwent: + retptr = getpwent(); break; # endif - default: - SETERRNO(ERANGE, LIB_INVARG); - break; + default: + SETERRNO(ERANGE, LIB_INVARG); + break; } - } - break; + } + break; # endif # ifdef USE_SPENT_BUFFER case KEY_getspnam: - { + { char * name; # ifdef PERL_REENTRANT_MAXSIZE - if (PL_reentrant_buffer->_spent_size <= - PERL_REENTRANT_MAXSIZE / 2) + if (PL_reentrant_buffer->_spent_size <= + PERL_REENTRANT_MAXSIZE / 2) # endif RenewDouble(PL_reentrant_buffer->_spent_buffer, &PL_reentrant_buffer->_spent_size, char); switch (key) { - case KEY_getspnam: - name = va_arg(ap, char *); - retptr = getspnam(name); break; - default: - SETERRNO(ERANGE, LIB_INVARG); - break; + case KEY_getspnam: + name = va_arg(ap, char *); + retptr = getspnam(name); break; + default: + SETERRNO(ERANGE, LIB_INVARG); + break; } - } - break; + } + break; # endif # ifdef USE_PROTOENT_BUFFER @@ -1101,31 +1101,31 @@ Perl_reentrant_retry(const char *f, ...) case KEY_getprotobyname: case KEY_getprotobynumber: case KEY_getprotoent: - { + { char * name; int anint; # ifdef PERL_REENTRANT_MAXSIZE - if (PL_reentrant_buffer->_protoent_size <= - PERL_REENTRANT_MAXSIZE / 2) + if (PL_reentrant_buffer->_protoent_size <= + PERL_REENTRANT_MAXSIZE / 2) # endif RenewDouble(PL_reentrant_buffer->_protoent_buffer, &PL_reentrant_buffer->_protoent_size, char); switch (key) { - case KEY_getprotobyname: - name = va_arg(ap, char *); - retptr = getprotobyname(name); break; - case KEY_getprotobynumber: - anint = va_arg(ap, int); - retptr = getprotobynumber(anint); break; - case KEY_getprotoent: - retptr = getprotoent(); break; - default: - SETERRNO(ERANGE, LIB_INVARG); - break; - } - } - break; + case KEY_getprotobyname: + name = va_arg(ap, char *); + retptr = getprotobyname(name); break; + case KEY_getprotobynumber: + anint = va_arg(ap, int); + retptr = getprotobynumber(anint); break; + case KEY_getprotoent: + retptr = getprotoent(); break; + default: + SETERRNO(ERANGE, LIB_INVARG); + break; + } + } + break; # endif # ifdef USE_SERVENT_BUFFER @@ -1133,40 +1133,40 @@ Perl_reentrant_retry(const char *f, ...) case KEY_getservbyname: case KEY_getservbyport: case KEY_getservent: - { + { char * name; char * proto; int anint; # ifdef PERL_REENTRANT_MAXSIZE - if (PL_reentrant_buffer->_servent_size <= - PERL_REENTRANT_MAXSIZE / 2) + if (PL_reentrant_buffer->_servent_size <= + PERL_REENTRANT_MAXSIZE / 2) # endif RenewDouble(PL_reentrant_buffer->_servent_buffer, &PL_reentrant_buffer->_servent_size, char); switch (key) { - case KEY_getservbyname: - name = va_arg(ap, char *); - proto = va_arg(ap, char *); - retptr = getservbyname(name, proto); break; - case KEY_getservbyport: - anint = va_arg(ap, int); - name = va_arg(ap, char *); - retptr = getservbyport(anint, name); break; - case KEY_getservent: - retptr = getservent(); break; - default: - SETERRNO(ERANGE, LIB_INVARG); - break; - } - } - break; + case KEY_getservbyname: + name = va_arg(ap, char *); + proto = va_arg(ap, char *); + retptr = getservbyname(name, proto); break; + case KEY_getservbyport: + anint = va_arg(ap, int); + name = va_arg(ap, char *); + retptr = getservbyport(anint, name); break; + case KEY_getservent: + retptr = getservent(); break; + default: + SETERRNO(ERANGE, LIB_INVARG); + break; + } + } + break; # endif default: - /* Not known how to retry, so just fail. */ - break; + /* Not known how to retry, so just fail. */ + break; } #else diff --git a/regen/regcharclass.pl b/regen/regcharclass.pl index 852ea0d3e8..76b1532047 100755 --- a/regen/regcharclass.pl +++ b/regen/regcharclass.pl @@ -1375,11 +1375,11 @@ if ( !caller ) { if ( $path eq '-' ) { $out_fh= \*STDOUT; } else { - $out_fh = open_new( $path ); + $out_fh = open_new( $path ); } print $out_fh read_only_top( lang => 'C', by => $0, - file => 'regcharclass.h', style => '*', - copyright => [2007, 2011], + file => 'regcharclass.h', style => '*', + copyright => [2007, 2011], final => <<EOF, WARNING: These macros are for internal Perl core use only, and may be changed or removed without notice. @@ -1478,7 +1478,7 @@ EOF print $out_fh "\n#endif /* PERL_REGCHARCLASS_H_ */\n"; if($path eq '-') { - print $out_fh "/* ex: set ro: */\n"; + print $out_fh "/* ex: set ro: */\n"; } else { # Some of the sources for these macros come from Unicode tables my $sources_list = "lib/unicore/mktables.lst"; diff --git a/regen/regen_lib.pl b/regen/regen_lib.pl index 9b20d00687..0eb5654e56 100644 --- a/regen/regen_lib.pl +++ b/regen/regen_lib.pl @@ -37,7 +37,7 @@ sub open_new { my ($final_name, $mode, $header, $force) = @_; my $name = $final_name . '-new'; my $lang = $final_name =~ /\.pod$/ ? 'Pod' : - $final_name =~ /\.(?:c|h|inc|tab|act)$/ ? 'C' : 'Perl'; + $final_name =~ /\.(?:c|h|inc|tab|act)$/ ? 'C' : 'Perl'; if ($force && -e $final_name) { chmod 0777, $name if $Needs_Write; CORE::unlink $final_name @@ -45,12 +45,12 @@ sub open_new { } my $fh = gensym; if (!defined $mode or $mode eq '>') { - if (-f $name) { - unlink $name or die "$name exists but can't unlink: $!"; - } - open $fh, '>', $name or die "Can't create $name: $!"; + if (-f $name) { + unlink $name or die "$name exists but can't unlink: $!"; + } + open $fh, '>', $name or die "Can't create $name: $!"; } elsif ($mode eq '>>') { - open $fh, '>>', $name or die "Can't append to $name: $!"; + open $fh, '>>', $name or die "Can't append to $name: $!"; } else { die "Unhandled open mode '$mode'"; } @@ -100,8 +100,8 @@ sub close_and_rename { } else { print STDOUT "ok - $0 $final_name\n"; } - safer_unlink($name); - return; + safer_unlink($name); + return; } unless ($force) { if (compare($name, $final_name) == 0) { @@ -132,10 +132,10 @@ sub read_only_top { my $raw = "-*- buffer-read-only: t -*-\n"; if ($args{file}) { - $raw .= "\n $args{file}\n"; + $raw .= "\n $args{file}\n"; } if ($args{copyright}) { - local $" = ', '; + local $" = ', '; $raw .= wrap(75, ' ', ' ', <<"EOM") . "\n"; Copyright (C) @{$args{copyright}} by\0Larry\0Wall\0and\0others @@ -148,17 +148,17 @@ EOM $raw .= "!!!!!!! DO NOT EDIT THIS FILE !!!!!!!\n"; if ($args{by}) { - $raw .= "This file is built by $args{by}"; - if ($args{from}) { - my @from = ref $args{from} eq 'ARRAY' ? @{$args{from}} : $args{from}; - my $last = pop @from; - if (@from) { - $raw .= ' from ' . join (', ', @from) . " and $last"; - } else { - $raw .= " from $last"; - } - } - $raw .= ".\n"; + $raw .= "This file is built by $args{by}"; + if ($args{from}) { + my @from = ref $args{from} eq 'ARRAY' ? @{$args{from}} : $args{from}; + my $last = pop @from; + if (@from) { + $raw .= ' from ' . join (', ', @from) . " and $last"; + } else { + $raw .= " from $last"; + } + } + $raw .= ".\n"; } $raw .= "Any changes made here will be lost!\n"; $raw .= $args{final} if $args{final}; @@ -180,8 +180,8 @@ sub read_only_bottom_close_and_rename { my $comment; if ($sources) { - $comment = "Generated from:\n"; - foreach my $file (sort @$sources) { + $comment = "Generated from:\n"; + foreach my $file (sort @$sources) { my $digest = (-e $file) ? digest($file) # Use a random number that won't match the real @@ -189,17 +189,17 @@ sub read_only_bottom_close_and_rename { # Porting tests likely will fail drawing attention # to the problem. : int(rand(1_000_000)); - $comment .= "$digest $file\n"; - } + $comment .= "$digest $file\n"; + } } $comment .= "ex: set ro:"; if (defined $lang && $lang eq 'Perl') { - $comment =~ s/^/# /mg; + $comment =~ s/^/# /mg; } elsif (!defined $lang or $lang ne 'Pod') { - $comment =~ s/^/ * /mg; - $comment =~ s! \* !/* !; - $comment .= " */"; + $comment =~ s/^/ * /mg; + $comment =~ s! \* !/* !; + $comment .= " */"; } print $fh "\n$comment\n"; diff --git a/regen/warnings.pl b/regen/warnings.pl index 498b93e285..0ca928b6f0 100644 --- a/regen/warnings.pl +++ b/regen/warnings.pl @@ -16,7 +16,7 @@ # # This script is normally invoked from regen.pl. -$VERSION = '1.49'; +$VERSION = '1.50'; BEGIN { require './regen/regen_lib.pl'; @@ -144,16 +144,16 @@ sub valueWalk my ($k, $v) ; foreach $k (sort keys %$tre) { - $v = $tre->{$k}; - die "duplicate key $k\n" if defined $list{$k} ; - die "Value associated with key '$k' is not an ARRAY reference" - if !ref $v || ref $v ne 'ARRAY' ; + $v = $tre->{$k}; + die "duplicate key $k\n" if defined $list{$k} ; + die "Value associated with key '$k' is not an ARRAY reference" + if !ref $v || ref $v ne 'ARRAY' ; - my ($ver, $rest) = @{ $v } ; - push @{ $v_list{$ver} }, $k; + my ($ver, $rest) = @{ $v } ; + push @{ $v_list{$ver} }, $k; - if (ref $rest) - { valueWalk ($rest) } + if (ref $rest) + { valueWalk ($rest) } } @@ -164,8 +164,8 @@ sub orderValues my $index = 0; foreach my $ver ( sort { $a <=> $b } keys %v_list ) { foreach my $name (@{ $v_list{$ver} } ) { - $ValueToName{ $index } = [ uc $name, $ver ] ; - $NameToValue{ uc $name } = $index ++ ; + $ValueToName{ $index } = [ uc $name, $ver ] ; + $NameToValue{ uc $name } = $index ++ ; } } @@ -181,21 +181,21 @@ sub walk my ($k, $v) ; foreach $k (sort keys %$tre) { - $v = $tre->{$k}; - die "duplicate key $k\n" if defined $list{$k} ; - die "Can't find key '$k'" - if ! defined $NameToValue{uc $k} ; + $v = $tre->{$k}; + die "duplicate key $k\n" if defined $list{$k} ; + die "Can't find key '$k'" + if ! defined $NameToValue{uc $k} ; push @{ $list{$k} }, $NameToValue{uc $k} ; - die "Value associated with key '$k' is not an ARRAY reference" - if !ref $v || ref $v ne 'ARRAY' ; + die "Value associated with key '$k' is not an ARRAY reference" + if !ref $v || ref $v ne 'ARRAY' ; - my ($ver, $rest) = @{ $v } ; - if (ref $rest) - { push (@{ $list{$k} }, walk ($rest)) } - elsif ($rest == DEFAULT_ON) - { push @def, $NameToValue{uc $k} } + my ($ver, $rest) = @{ $v } ; + if (ref $rest) + { push (@{ $list{$k} }, walk ($rest)) } + elsif ($rest == DEFAULT_ON) + { push @def, $NameToValue{uc $k} } - push @list, @{ $list{$k} } ; + push @list, @{ $list{$k} } ; } return @list ; @@ -209,7 +209,7 @@ sub mkRange my @out = @in ; for my $i (1 .. @in - 1) { - $out[$i] = ".." + $out[$i] = ".." if $in[$i] == $in[$i - 1] + 1 && ($i >= @in - 1 || $in[$i] + 1 == $in[$i + 1] ); } @@ -234,30 +234,30 @@ sub warningsTree my $rv = ''; while ($k = shift @keys) { - $v = $tre->{$k}; - die "Value associated with key '$k' is not an ARRAY reference" - if !ref $v || ref $v ne 'ARRAY' ; + $v = $tre->{$k}; + die "Value associated with key '$k' is not an ARRAY reference" + if !ref $v || ref $v ne 'ARRAY' ; my $offset ; - if ($tre ne $tree) { - $rv .= $prefix . "|\n" ; - $rv .= $prefix . "+- $k" ; - $offset = ' ' x ($max + 4) ; - } - else { - $rv .= $prefix . "$k" ; - $offset = ' ' x ($max + 1) ; - } - - my ($ver, $rest) = @{ $v } ; - if (ref $rest) - { - my $bar = @keys ? "|" : " "; - $rv .= " -" . "-" x ($max - length $k ) . "+\n" ; - $rv .= warningsTree ($rest, $prefix . $bar . $offset ) - } - else - { $rv .= "\n" } + if ($tre ne $tree) { + $rv .= $prefix . "|\n" ; + $rv .= $prefix . "+- $k" ; + $offset = ' ' x ($max + 4) ; + } + else { + $rv .= $prefix . "$k" ; + $offset = ' ' x ($max + 1) ; + } + + my ($ver, $rest) = @{ $v } ; + if (ref $rest) + { + my $bar = @keys ? "|" : " "; + $rv .= " -" . "-" x ($max - length $k ) . "+\n" ; + $rv .= warningsTree ($rest, $prefix . $bar . $offset ) + } + else + { $rv .= "\n" } } return $rv; @@ -272,7 +272,7 @@ sub mkHexOct my $string = "" ; foreach (@bits) { - vec($mask, $_, 1) = 1 ; + vec($mask, $_, 1) = 1 ; } foreach (unpack("C*", $mask)) { @@ -334,7 +334,7 @@ my ($index, $warn_size); #define pWARN_NONE (STRLEN *) &PL_WARN_NONE /* no warnings 'all' */ #define specialWARN(x) ((x) == pWARN_STD || (x) == pWARN_ALL || \ - (x) == pWARN_NONE) + (x) == pWARN_NONE) /* if PL_warnhook is set to this value, then warnings die */ #define PERL_WARNHOOK_FATAL (&PL_sv_placeholder) @@ -379,9 +379,9 @@ EOM print $warn <<'EOM'; #define isLEXWARN_on \ - cBOOL(PL_curcop && PL_curcop->cop_warnings != pWARN_STD) + cBOOL(PL_curcop && PL_curcop->cop_warnings != pWARN_STD) #define isLEXWARN_off \ - cBOOL(!PL_curcop || PL_curcop->cop_warnings == pWARN_STD) + cBOOL(!PL_curcop || PL_curcop->cop_warnings == pWARN_STD) #define isWARN_ONCE (PL_dowarn & (G_WARN_ON|G_WARN_ONCE)) #define isWARN_on(c,x) (PerlWarnIsSet_((U8 *)(c + 1), 2*(x))) #define isWARNf_on(c,x) (PerlWarnIsSet_((U8 *)(c + 1), 2*(x)+1)) @@ -474,11 +474,11 @@ category parameters passed. !specialWARN(PL_curcop->cop_warnings) && \ (isWARNf_on(PL_curcop->cop_warnings, unpackWARN1(x)) || \ (unpackWARN2(x) && \ - (isWARNf_on(PL_curcop->cop_warnings, unpackWARN2(x)) || \ - (unpackWARN3(x) && \ - (isWARNf_on(PL_curcop->cop_warnings, unpackWARN3(x)) || \ - (unpackWARN4(x) && \ - isWARNf_on(PL_curcop->cop_warnings, unpackWARN4(x))))))))) + (isWARNf_on(PL_curcop->cop_warnings, unpackWARN2(x)) || \ + (unpackWARN3(x) && \ + (isWARNf_on(PL_curcop->cop_warnings, unpackWARN3(x)) || \ + (unpackWARN4(x) && \ + isWARNf_on(PL_curcop->cop_warnings, unpackWARN4(x))))))))) EOM @@ -526,8 +526,8 @@ foreach my $k (sort keys %list) { my @list = sort { $a <=> $b } @$v ; print $pm tab(6, " '$k'"), '=> "', - mkHex($warn_size, map $_ * 2 , @list), - '", # [', mkRange(@list), "]\n" ; + mkHex($warn_size, map $_ * 2 , @list), + '", # [', mkRange(@list), "]\n" ; } print $pm ");\n\n" ; @@ -539,15 +539,15 @@ foreach my $k (sort keys %list) { my @list = sort { $a <=> $b } @$v ; print $pm tab(6, " '$k'"), '=> "', - mkHex($warn_size, map $_ * 2 + 1 , @list), - '", # [', mkRange(@list), "]\n" ; + mkHex($warn_size, map $_ * 2 + 1 , @list), + '", # [', mkRange(@list), "]\n" ; } print $pm ");\n\n" ; print $pm "# These are used by various things, including our own tests\n"; print $pm tab(6, 'our $NONE'), '= "', ('\0' x $warn_size) , "\";\n" ; print $pm tab(6, 'our $DEFAULT'), '= "', mkHex($warn_size, map $_ * 2, @def), - '"; # [', mkRange(sort { $a <=> $b } @def), "]\n" ; + '"; # [', mkRange(sort { $a <=> $b } @def), "]\n" ; print $pm tab(6, 'our $LAST_BIT'), '= ' . "$index ;\n" ; print $pm tab(6, 'our $BYTES'), '= ' . "$warn_size ;\n" ; while (<DATA>) { @@ -588,16 +588,16 @@ sub _expand_bits { my $want_len = ($LAST_BIT + 7) >> 3; my $len = length($bits); if ($len != $want_len) { - if ($bits eq "") { - $bits = "\x00" x $want_len; - } elsif ($len > $want_len) { - substr $bits, $want_len, $len-$want_len, ""; - } else { - my $x = vec($bits, $Offsets{all} >> 1, 2); - $x |= $x << 2; - $x |= $x << 4; - $bits .= chr($x) x ($want_len - $len); - } + if ($bits eq "") { + $bits = "\x00" x $want_len; + } elsif ($len > $want_len) { + substr $bits, $want_len, $len-$want_len, ""; + } else { + my $x = vec($bits, $Offsets{all} >> 1, 2); + $x |= $x << 2; + $x |= $x << 4; + $bits .= chr($x) x ($want_len - $len); + } } return $bits; } @@ -610,21 +610,21 @@ sub _bits { $mask = _expand_bits($mask); foreach my $word ( @_ ) { - if ($word eq 'FATAL') { - $fatal = 1; - $no_fatal = 0; - } - elsif ($word eq 'NONFATAL') { - $fatal = 0; - $no_fatal = 1; - } - elsif ($catmask = $Bits{$word}) { - $mask |= $catmask ; - $mask |= $DeadBits{$word} if $fatal ; - $mask = ~(~$mask | $DeadBits{$word}) if $no_fatal ; - } - else - { Croaker("Unknown warnings category '$word'")} + if ($word eq 'FATAL') { + $fatal = 1; + $no_fatal = 0; + } + elsif ($word eq 'NONFATAL') { + $fatal = 0; + $no_fatal = 1; + } + elsif ($catmask = $Bits{$word}) { + $mask |= $catmask ; + $mask |= $DeadBits{$word} if $fatal ; + $mask = ~(~$mask | $DeadBits{$word}) if $no_fatal ; + } + else + { Croaker("Unknown warnings category '$word'")} } return $mask ; @@ -671,14 +671,14 @@ sub unimport $mask = _expand_bits($mask); foreach my $word ( @_ ) { - if ($word eq 'FATAL') { - next; - } - elsif ($catmask = $Bits{$word}) { - $mask = ~(~$mask | $catmask | $DeadBits{$word}); - } - else - { Croaker("Unknown warnings category '$word'")} + if ($word eq 'FATAL') { + next; + } + elsif ($catmask = $Bits{$word}) { + $mask = ~(~$mask | $catmask | $DeadBits{$word}); + } + else + { Croaker("Unknown warnings category '$word'")} } ${^WARNING_BITS} = $mask ; @@ -701,71 +701,71 @@ sub __chk my $has_level = $wanted & LEVEL ; if ($has_level) { - if (@_ != ($has_message ? 3 : 2)) { - my $sub = (caller 1)[3]; - my $syntax = $has_message - ? "category, level, 'message'" - : 'category, level'; - Croaker("Usage: $sub($syntax)"); + if (@_ != ($has_message ? 3 : 2)) { + my $sub = (caller 1)[3]; + my $syntax = $has_message + ? "category, level, 'message'" + : 'category, level'; + Croaker("Usage: $sub($syntax)"); } } elsif (not @_ == 1 || @_ == ($has_message ? 2 : 0)) { - my $sub = (caller 1)[3]; - my $syntax = $has_message ? "[category,] 'message'" : '[category]'; - Croaker("Usage: $sub($syntax)"); + my $sub = (caller 1)[3]; + my $syntax = $has_message ? "[category,] 'message'" : '[category]'; + Croaker("Usage: $sub($syntax)"); } my $message = pop if $has_message; if (@_) { - # check the category supplied. - $category = shift ; - if (my $type = ref $category) { - Croaker("not an object") - if exists $builtin_type{$type}; - $category = $type; - $isobj = 1 ; - } - $offset = $Offsets{$category}; - Croaker("Unknown warnings category '$category'") - unless defined $offset; + # check the category supplied. + $category = shift ; + if (my $type = ref $category) { + Croaker("not an object") + if exists $builtin_type{$type}; + $category = $type; + $isobj = 1 ; + } + $offset = $Offsets{$category}; + Croaker("Unknown warnings category '$category'") + unless defined $offset; } else { - $category = (caller(1))[0] ; - $offset = $Offsets{$category}; - Croaker("package '$category' not registered for warnings") - unless defined $offset ; + $category = (caller(1))[0] ; + $offset = $Offsets{$category}; + Croaker("package '$category' not registered for warnings") + unless defined $offset ; } my $i; if ($isobj) { - my $pkg; - $i = 2; - while (do { { package DB; $pkg = (caller($i++))[0] } } ) { - last unless @DB::args && $DB::args[0] =~ /^$category=/ ; - } - $i -= 2 ; + my $pkg; + $i = 2; + while (do { { package DB; $pkg = (caller($i++))[0] } } ) { + last unless @DB::args && $DB::args[0] =~ /^$category=/ ; + } + $i -= 2 ; } elsif ($has_level) { - $i = 2 + shift; + $i = 2 + shift; } else { - $i = _error_loc(); # see where Carp will allocate the error + $i = _error_loc(); # see where Carp will allocate the error } # Default to 0 if caller returns nothing. Default to $DEFAULT if it # explicitly returns undef. my(@callers_bitmask) = (caller($i))[9] ; my $callers_bitmask = - @callers_bitmask ? $callers_bitmask[0] // $DEFAULT : 0 ; + @callers_bitmask ? $callers_bitmask[0] // $DEFAULT : 0 ; length($callers_bitmask) > ($offset >> 3) or $offset = $Offsets{all}; my @results; foreach my $type (FATAL, NORMAL) { - next unless $wanted & $type; + next unless $wanted & $type; - push @results, vec($callers_bitmask, $offset + $type - 1, 1); + push @results, vec($callers_bitmask, $offset + $type - 1, 1); } # &enabled and &fatal_enabled @@ -773,19 +773,19 @@ sub __chk # &warnif, and the category is neither enabled as warning nor as fatal return if ($wanted & (NORMAL | FATAL | MESSAGE)) - == (NORMAL | FATAL | MESSAGE) - && !($results[0] || $results[1]); + == (NORMAL | FATAL | MESSAGE) + && !($results[0] || $results[1]); # If we have an explicit level, bypass Carp. if ($has_level and @callers_bitmask) { - # logic copied from util.c:mess_sv - my $stuff = " at " . join " line ", (caller $i)[1,2]; - $stuff .= sprintf ", <%s> %s %d", - *${^LAST_FH}{NAME}, - ($/ eq "\n" ? "line" : "chunk"), $. - if $. && ${^LAST_FH}; - die "$message$stuff.\n" if $results[0]; - return warn "$message$stuff.\n"; + # logic copied from util.c:mess_sv + my $stuff = " at " . join " line ", (caller $i)[1,2]; + $stuff .= sprintf ", <%s> %s %d", + *${^LAST_FH}{NAME}, + ($/ eq "\n" ? "line" : "chunk"), $. + if $. && ${^LAST_FH}; + die "$message$stuff.\n" if $results[0]; + return warn "$message$stuff.\n"; } require Carp; @@ -809,15 +809,15 @@ sub register_categories my @names = @_; for my $name (@names) { - if (! defined $Bits{$name}) { - $Offsets{$name} = $LAST_BIT; - $Bits{$name} = _mkMask($LAST_BIT++); - $DeadBits{$name} = _mkMask($LAST_BIT++); - if (length($Bits{$name}) > length($Bits{all})) { - $Bits{all} .= "\x55"; - $DeadBits{all} .= "\xaa"; - } - } + if (! defined $Bits{$name}) { + $Offsets{$name} = $LAST_BIT; + $Bits{$name} = _mkMask($LAST_BIT++); + $DeadBits{$name} = _mkMask($LAST_BIT++); + if (length($Bits{$name}) > length($Bits{all})) { + $Bits{all} .= "\x55"; + $DeadBits{all} .= "\xaa"; + } + } } } @@ -938,7 +938,7 @@ For example, consider the code below: my @x; { no warnings; - my $y = @x[0]; + my $y = @x[0]; } my $z = @x[0]; @@ -1023,8 +1023,8 @@ a block of code. You might expect this to be enough to do the trick: { local ($^W) = 0; - my $x =+ 2; - my $y; chop $y; + my $x =+ 2; + my $y; chop $y; } When this code is run with the B<-w> flag, a warning will be produced @@ -1035,8 +1035,8 @@ disable compile-time warnings you need to rewrite the code like this: { BEGIN { $^W = 0 } - my $x =+ 2; - my $y; chop $y; + my $x =+ 2; + my $y; chop $y; } And note that unlike the first example, this will permanently set C<$^W> |