From: Gurusamy Sarathy Date: Thu, 14 May 1998 23:11:05 +0000 (+0000) Subject: [win32] merge change#897 from maintbranch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7b8d334a971230040a212bc5038097b3f600a094;p=p5sagit%2Fp5-mst-13.2.git [win32] merge change#897 from maintbranch p4raw-link: @897 on //depot/maint-5.004/perl: f06f9b6fc5a686f0169ee2a91b32d5e7125a44ae p4raw-id: //depot/win32/perl@974 --- diff --git a/Todo b/Todo index 4752030..e9263cc 100644 --- a/Todo +++ b/Todo @@ -21,6 +21,7 @@ Would be nice to have reference to compiled regexp lexically scoped functions: my sub foo { ... } lvalue functions + regression/sanity tests for suidperl Full 64 bit support (i.e. "long long") Possible pragmas @@ -55,5 +56,4 @@ Vague possibilities structured types autocroak? Modifiable $1 et al - substr EXPR,OFFSET,LENGTH,STRING diff --git a/doio.c b/doio.c index d293282..94d78c4 100644 --- a/doio.c +++ b/doio.c @@ -171,8 +171,11 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe if (strNE(name,"-")) TAINT_ENV(); TAINT_PROPER("piped open"); - if (dowarn && name[strlen(name)-1] == '|') - warn("Can't do bidirectional pipe"); + if (name[strlen(name)-1] == '|') { + name[strlen(name)-1] = '\0' ; + if (dowarn) + warn("Can't do bidirectional pipe"); + } fp = PerlProc_popen(name,"w"); writing = 1; } diff --git a/ext/IO/IO.pm b/ext/IO/IO.pm index 1ba05ca..4d4c81c 100644 --- a/ext/IO/IO.pm +++ b/ext/IO/IO.pm @@ -12,7 +12,7 @@ IO - load various IO modules =head1 DESCRIPTION -C provides a simple mechanism to load all of the IO modules at one go. +C provides a simple mechanism to load some of the IO modules at one go. Currently this includes: IO::Handle diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm index b71e8b4..717b97f 100644 --- a/ext/Opcode/Opcode.pm +++ b/ext/Opcode/Opcode.pm @@ -152,7 +152,7 @@ like gv2cv, i_ncmp and ftsvtx. =item an operator tag name (optag) Operator tags can be used to refer to groups (or sets) of operators. -Tag names always being with a colon. The Opcode module defines several +Tag names always begin with a colon. The Opcode module defines several optags and the user can define others using the define_optag function. =item a negated opname or optag @@ -569,7 +569,7 @@ Originally designed and implemented by Malcolm Beattie, mbeattie@sable.ox.ac.uk as part of Safe version 1. Split out from Safe module version 1, named opcode tags and other -changes added by Tim Bunce EFE. +changes added by Tim Bunce. =cut diff --git a/lib/Carp.pm b/lib/Carp.pm index 685a793..6397d1b 100644 --- a/lib/Carp.pm +++ b/lib/Carp.pm @@ -47,6 +47,15 @@ environment variable. # This package is heavily used. Be small. Be fast. Be good. +# Comments added by Andy Wardley 09-Apr-98, based on an +# _almost_ complete understanding of the package. Corrections and +# comments are welcome. + +# The $CarpLevel variable can be set to "strip off" extra caller levels for +# those times when Carp calls are buried inside other functions. The +# $Max(EvalLen|(Arg(Len|Nums)) variables are used to specify how the eval +# text and function arguments should be formatted when printed. + $CarpLevel = 0; # How many extra package levels to skip on carp. $MaxEvalLen = 0; # How much eval '...text...' to show. 0 = all. $MaxArgLen = 64; # How much of each argument to print. 0 = all. @@ -58,30 +67,62 @@ require Exporter; @EXPORT_OK = qw(cluck verbose); @EXPORT_FAIL = qw(verbose); # hook to enable verbose mode + +# if the caller specifies verbose usage ("perl -MCarp=verbose script.pl") +# then the following method will be called by the Exporter which knows +# to do this thanks to @EXPORT_FAIL, above. $_[1] will contain the word +# 'verbose'. + sub export_fail { shift; if ($_[0] eq 'verbose') { - local $^W = 0; - *shortmess = \&longmess; - shift; + local $^W = 0; # avoid "sub-routine redefined..." warning + *shortmess = \&longmess; # set shortmess() as an alias to longmess() + shift; # remove 'verbose' from the args to keep Exporter happy } return @_; } +# longmess() crawls all the way up the stack reporting on all the function +# calls made. The error string, $error, is originally constructed from the +# arguments passed into longmess() via confess(), cluck() or shortmess(). +# This gets appended with the stack trace messages which are generated for +# each function call on the stack. + sub longmess { my $error = join '', @_; my $mess = ""; my $i = 1 + $CarpLevel; my ($pack,$file,$line,$sub,$hargs,$eval,$require); my (@a); + # + # crawl up the stack.... + # while (do { { package DB; @a = caller($i++) } } ) { - ($pack,$file,$line,$sub,$hargs,undef,$eval,$require) = @a; + # get copies of the variables returned from caller() + ($pack,$file,$line,$sub,$hargs,undef,$eval,$require) = @a; + # + # if the $error error string is newline terminated then it + # is copied into $mess. Otherwise, $mess gets set (at the end of + # the 'else {' section below) to one of two things. The first time + # through, it is set to the "$error at $file line $line" message. + # $error is then set to 'called' which triggers subsequent loop + # iterations to append $sub to $mess before appending the "$error + # at $file line $line" which now actually reads "called at $file line + # $line". Thus, the stack trace message is constructed: + # + # first time: $mess = $error at $file line $line + # subsequent times: $mess .= $sub $error at $file line $line + # ^^^^^^ + # "called" if ($error =~ m/\n$/) { $mess .= $error; } else { + # Build a string, $sub, which names the sub-routine called. + # This may also be "require ...", "eval '...' or "eval {...}" if (defined $eval) { - if ($require) { + if ($require) { $sub = "require $eval"; } else { $eval =~ s/([\\\'])/\\$1/g; @@ -93,32 +134,48 @@ sub longmess { } elsif ($sub eq '(eval)') { $sub = 'eval {...}'; } + # if there are any arguments in the sub-routine call, format + # them according to the format variables defined earlier in + # this file and join them onto the $sub sub-routine string if ($hargs) { - @a = @DB::args; # must get local copy of args - if ($MaxArgNums and @a > $MaxArgNums) { - $#a = $MaxArgNums; - $a[$#a] = "..."; - } - for (@a) { - $_ = "undef", next unless defined $_; - if (ref $_) { - $_ .= ''; - s/'/\\'/g; + # we may trash some of the args so we take a copy + @a = @DB::args; # must get local copy of args + # don't print any more than $MaxArgNums + if ($MaxArgNums and @a > $MaxArgNums) { + # cap the length of $#a and set the last element to '...' + $#a = $MaxArgNums; + $a[$#a] = "..."; } - else { - s/'/\\'/g; - substr($_,$MaxArgLen) = '...' - if $MaxArgLen and $MaxArgLen < length; + for (@a) { + # set args to the string "undef" if undefined + $_ = "undef", next unless defined $_; + if (ref $_) { + # dunno what this is for... + $_ .= ''; + s/'/\\'/g; + } + else { + s/'/\\'/g; + # terminate the string early with '...' if too long + substr($_,$MaxArgLen) = '...' + if $MaxArgLen and $MaxArgLen < length; + } + # 'quote' arg unless it looks like a number + $_ = "'$_'" unless /^-?[\d.]+$/; + # print high-end chars as 'M-' or '^' + s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg; + s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg; } - $_ = "'$_'" unless /^-?[\d.]+$/; - s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg; - s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg; - } - $sub .= '(' . join(', ', @a) . ')'; + # append ('all', 'the', 'arguments') to the $sub string + $sub .= '(' . join(', ', @a) . ')'; } + # here's where the error message, $mess, gets constructed $mess .= "\t$sub " if $error eq "called"; $mess .= "$error at $file line $line\n"; } + # we don't need to print the actual error message again so we can + # change this to "called" so that the string "$error at $file line + # $line" makes sense as "called at $file line $line". $error = "called"; } # this kludge circumvents die's incorrect handling of NUL @@ -127,36 +184,70 @@ sub longmess { $$msg; } + +# shortmess() is called by carp() and croak() to skip all the way up to +# the top-level caller's package and report the error from there. confess() +# and cluck() generate a full stack trace so they call longmess() to +# generate that. In verbose mode shortmess() is aliased to longmess() so +# you always get a stack trace + sub shortmess { # Short-circuit &longmess if called via multiple packages my $error = join '', @_; my ($prevpack) = caller(1); my $extra = $CarpLevel; my $i = 2; my ($pack,$file,$line); + # when reporting an error, we want to report it from the context of the + # calling package. So what is the calling package? Within a module, + # there may be many calls between methods and perhaps between sub-classes + # and super-classes, but the user isn't interested in what happens + # inside the package. We start by building a hash array which keeps + # track of all the packages to which the calling package belongs. We + # do this by examining its @ISA variable. Any call from a base class + # method (one of our caller's @ISA packages) can be ignored my %isa = ($prevpack,1); + # merge all the caller's @ISA packages into %isa. @isa{@{"${prevpack}::ISA"}} = () if(defined @{"${prevpack}::ISA"}); + # now we crawl up the calling stack and look at all the packages in + # there. For each package, we look to see if it has an @ISA and then + # we see if our caller features in that list. That would imply that + # our caller is a derived class of that package and its calls can also + # be ignored while (($pack,$file,$line) = caller($i++)) { if(defined @{$pack . "::ISA"}) { my @i = @{$pack . "::ISA"}; my %i; @i{@i} = (); + # merge any relevant packages into %isa @isa{@i,$pack} = () if(exists $i{$prevpack} || exists $isa{$pack}); } + # and here's where we do the ignoring... if the package in + # question is one of our caller's base or derived packages then + # we can ignore it (skip it) and go onto the next (but note that + # the continue { } block below gets called every time) next if(exists $isa{$pack}); + # Hey! We've found a package that isn't one of our caller's + # clan....but wait, $extra refers to the number of 'extra' levels + # we should skip up. If $extra > 0 then this is a false alarm. + # We must merge the package into the %isa hash (so we can ignore it + # if it pops up again), decrement $extra, and continue. if ($extra-- > 0) { %isa = ($pack,1); @isa{@{$pack . "::ISA"}} = () if(defined @{$pack . "::ISA"}); } else { - # this kludge circumvents die's incorrect handling of NUL + # OK! We've got a candidate package. Time to construct the + # relevant error message and return it. die() doesn't like + # to be given NUL characters (which $msg may contain) so we + # remove them first. (my $msg = "$error at $file line $line\n") =~ tr/\0//d; return $msg; } @@ -165,12 +256,23 @@ sub shortmess { # Short-circuit &longmess if called via multiple packages $prevpack = $pack; } + # uh-oh! It looks like we crawled all the way up the stack and + # never found a candidate package. Oh well, let's call longmess + # to generate a full stack trace. We use the magical form of 'goto' + # so that this shortmess() function doesn't appear on the stack + # to further confuse longmess() about it's calling package. goto &longmess; } -sub confess { die longmess @_; } -sub croak { die shortmess @_; } -sub carp { warn shortmess @_; } -sub cluck { warn longmess @_; } + +# the following four functions call longmess() or shortmess() depending on +# whether they should generate a full stack trace (confess() and cluck()) +# or simply report the caller's package (croak() and carp()), respectively. +# confess() and croak() die, carp() and cluck() warn. + +sub croak { die shortmess @_ } +sub confess { die longmess @_ } +sub carp { warn shortmess @_ } +sub cluck { warn longmess @_ } 1; diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index 4f861df..99ca0bd 100644 --- a/lib/ExtUtils/MM_Unix.pm +++ b/lib/ExtUtils/MM_Unix.pm @@ -1953,7 +1953,7 @@ pure_site_install :: }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{ doc_perl_install :: - }.$self->{NOECHO}.q{$(DOC_INSTALL) \ + -}.$self->{NOECHO}.q{$(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLPRIVLIB)" \ LINKTYPE "$(LINKTYPE)" \ @@ -1962,7 +1962,7 @@ doc_perl_install :: >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{ doc_site_install :: - }.$self->{NOECHO}.q{$(DOC_INSTALL) \ + -}.$self->{NOECHO}.q{$(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ @@ -2327,7 +2327,7 @@ $tmp/perlmain.c: $makefilename}, q{ push @m, q{ doc_inst_perl: }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod - }.$self->{NOECHO}.q{$(DOC_INSTALL) \ + -}.$self->{NOECHO}.q{$(DOC_INSTALL) \ "Perl binary" "$(MAP_TARGET)" \ MAP_STATIC "$(MAP_STATIC)" \ MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \ diff --git a/lib/Pod/Html.pm b/lib/Pod/Html.pm index 8ff3e89..dafa27d 100644 --- a/lib/Pod/Html.pm +++ b/lib/Pod/Html.pm @@ -3,6 +3,8 @@ package Pod::Html; use Pod::Functions; use Getopt::Long; # package for handling command-line parameters require Exporter; +use vars qw($VERSION); +$VERSION = 1.01; @ISA = Exporter; @EXPORT = qw(pod2html htmlify); use Cwd; @@ -11,13 +13,15 @@ use Carp; use strict; +use Config; + =head1 NAME -Pod::HTML - module to convert pod files to HTML +Pod::Html - module to convert pod files to HTML =head1 SYNOPSIS - use Pod::HTML; + use Pod::Html; pod2html([options]); =head1 DESCRIPTION @@ -302,7 +306,7 @@ sub pod2html { for (my $i = 0; $i < @poddata; $i++) { if ($poddata[$i] =~ /^=head1\s*NAME\b/m) { for my $para ( @poddata[$i, $i+1] ) { - last TITLE_SEARCH if ($title) = $para =~ /(\S+\s+-+\s*.*)/s; + last TITLE_SEARCH if ($title) = $para =~ /(\S+\s+-+.*\S)/s; } } @@ -316,19 +320,22 @@ sub pod2html { warn "adopted '$title' as title for $podfile\n" if $verbose and $title; } - unless ($title) { + if ($title) { + $title =~ s/\s*\(.*\)//; + } else { warn "$0: no title for $podfile"; $podfile =~ /^(.*)(\.[^.\/]+)?$/; $title = ($podfile eq "-" ? 'No Title' : $1); warn "using $title" if $verbose; } print HTML < - - $title - + + +$title + + - + END_OF_HEAD @@ -368,9 +375,9 @@ END_OF_HEAD } else { next if @begin_stack && $begin_stack[-1] ne 'html'; - if (/^=(head[1-6])\s+(.*)/s) { # =head[1-6] heading + if (/^=(head[1-6])\s+(.*\S)/s) { # =head[1-6] heading process_head($1, $2); - } elsif (/^=item\s*(.*)/sm) { # =item text + } elsif (/^=item\s*(.*\S)/sm) { # =item text process_item($1); } elsif (/^=over\s*(.*)/) { # =over N process_over(); @@ -391,16 +398,16 @@ END_OF_HEAD next if @begin_stack && $begin_stack[-1] ne 'html'; my $text = $_; process_text(\$text, 1); - print HTML "$text\n

\n\n"; + print HTML "

\n$text"; } } # finish off any pending directives finish_list(); print HTML < + - + END_OF_TAIL # close the html file @@ -782,7 +789,7 @@ sub scan_headings { $index .= "\n" . ("\t" x $listdepth) . "

  • " . "" . - process_text(\$title, 0) . ""; + html_escape(process_text(\$title, 0)) . ""; } } @@ -823,8 +830,8 @@ sub scan_items { if ($1 eq "*") { # bullet list /\A=item\s+\*\s*(.*?)\s*\Z/s; $item = $1; - } elsif ($1 =~ /^[0-9]+/) { # numbered list - /\A=item\s+[0-9]+\.?(.*?)\s*\Z/s; + } elsif ($1 =~ /^\d+/) { # numbered list + /\A=item\s+\d+\.?(.*?)\s*\Z/s; $item = $1; } else { # /\A=item\s+(.*?)\s*\Z/s; @@ -856,6 +863,7 @@ sub process_head { print HTML ""; # unless $listlevel; #print HTML "" unless $listlevel; my $convert = $heading; process_text(\$convert, 0); + $convert = html_escape($convert); print HTML '$convert"; print HTML ""; # unless $listlevel; print HTML "\n"; @@ -898,30 +906,36 @@ sub process_item { print HTML "
      \n"; } - print HTML "
    • "; - $text =~ /\A\*\s*(.*)\Z/s; - print HTML "" if $1 && !$items_named{$1}++; - $quote = 1; - #print HTML process_puretext($1, \$quote); - print HTML $1; - print HTML "" if $1; - print HTML ""; + print HTML '
    • '; + if ($text =~ /\A\*\s*(.+)\Z/s) { + print HTML ''; + if ($items_named{$1}++) { + print HTML html_escape($1); + } else { + my $name = 'item_' . htmlify(1,$1); + print HTML qq(), html_escape($1), ''; + } + print HTML ''; + } - } elsif ($text =~ /\A[0-9#]+/) { # numbered list + } elsif ($text =~ /\A[\d#]+/) { # numbered list if ($need_preamble) { push(@listend, ""); print HTML "
        \n"; } - print HTML "
      1. "; - $text =~ /\A[0-9]+\.?(.*)\Z/s; - print HTML "" if $1; - $quote = 1; - #print HTML process_puretext($1, \$quote); - print HTML $1 if $1; - print HTML "" if $1; - print HTML ""; + print HTML '
      2. '; + if ($text =~ /\A\d+\.?\s*(.+)\Z/s) { + print HTML ''; + if ($items_named{$1}++) { + print HTML html_escape($1); + } else { + my $name = 'item_' . htmlify(0,$1); + print HTML qq(), html_escape($1), ''; + } + print HTML ''; + } } else { # all others @@ -930,18 +944,17 @@ sub process_item { print HTML "
        \n"; } - print HTML "
        "; - print HTML "" - if $text && !$items_named{($text =~ /(\S+)/)[0]}++; - # preceding craziness so that the duplicate leading bits in - # perlfunc work to find just the first one. otherwise - # open etc would have many names - $quote = 1; - #print HTML process_puretext($text, \$quote); - print HTML $text; - print HTML "" if $text; - print HTML ""; - + print HTML '
        '; + if ($text =~ /(\S+)/) { + print HTML ''; + if ($items_named{$1}++) { + print HTML html_escape($text); + } else { + my $name = 'item_' . htmlify(1,$text); + print HTML qq(), html_escape($text), ''; + } + print HTML ''; + } print HTML '
        '; } @@ -1276,12 +1289,15 @@ sub process_puretext { $word = qq($word); } elsif ($word =~ /[\w.-]+\@\w+\.\w/) { # looks like an e-mail address - $word = qq($word); + my ($w1, $w2, $w3) = ("", $word, ""); + ($w1, $w2, $w3) = ("(", $1, ")$2") if $word =~ /^\((.*?)\)(,?)/; + ($w1, $w2, $w3) = ("<", $1, ">$2") if $word =~ /^<(.*?)>(,?)/; + $word = qq($w1$w2$w3); } elsif ($word !~ /[a-z]/ && $word =~ /[A-Z]/) { # all uppercase? - $word = html_escape($word) if $word =~ /[&<>]/; + $word = html_escape($word) if $word =~ /["&<>]/; $word = "\n$word" if $netscape; } else { - $word = html_escape($word) if $word =~ /[&<>]/; + $word = html_escape($word) if $word =~ /["&<>]/; } } @@ -1443,6 +1459,7 @@ sub process_C { $s1 =~ s/\([^()]*\)//g; # delete parentheses $s2 = $s1; $s1 =~ s/\W//g; # delete bogus characters + $str = html_escape($str); # if there was a pod file that we found earlier with an appropriate # =item directive, then create a link to that page. @@ -1512,7 +1529,7 @@ sub process_X { # after the entire pod file has been read and converted. # sub finish_list { - while ($listlevel >= 0) { + while ($listlevel > 0) { print HTML "
        \n"; $listlevel--; } @@ -1546,4 +1563,3 @@ BEGIN { } 1; - diff --git a/lib/Term/ReadLine.pm b/lib/Term/ReadLine.pm index 2183c8d..83ba375 100644 --- a/lib/Term/ReadLine.pm +++ b/lib/Term/ReadLine.pm @@ -310,7 +310,7 @@ sub ornaments { return $rl_term_set unless @_; $rl_term_set = shift; $rl_term_set ||= ',,,'; - $rl_term_set = 'us,ue,md,me' if $rl_term_set == 1; + $rl_term_set = 'us,ue,md,me' if $rl_term_set eq '1'; my @ts = split /,/, $rl_term_set, 4; eval { LoadTermCap }; unless (defined $terminal) { diff --git a/opcode.pl b/opcode.pl index 118fef9..af030df 100755 --- a/opcode.pl +++ b/opcode.pl @@ -362,7 +362,7 @@ abs abs ck_fun fstu% S? # String stuff. length length ck_lengthconst istu% S? -substr substr ck_fun st@ S S S? +substr substr ck_fun st@ S S S? S? vec vec ck_fun ist@ S S S index index ck_index ist@ S S S? diff --git a/perl.c b/perl.c index 464a49b..97b0c38 100644 --- a/perl.c +++ b/perl.c @@ -668,6 +668,7 @@ setuid perl scripts securely.\n"); s = argv[0]+1; reswitch: switch (*s) { + case ' ': case '0': case 'F': case 'a': @@ -1562,8 +1563,11 @@ moreswitches(char *s) inplace = savepv(s+1); /*SUPPRESS 530*/ for (s = inplace; *s && !isSPACE(*s); s++) ; - if (*s) + if (*s) { *s++ = '\0'; + if (*s == '-') /* Additional switches on #! line. */ + s++; + } return s; case 'I': /* -I handled both here and in parse_perl() */ forbid_setid("-I"); diff --git a/pod/perlapio.pod b/pod/perlapio.pod index c963d23..f69e795 100644 --- a/pod/perlapio.pod +++ b/pod/perlapio.pod @@ -67,7 +67,7 @@ has been "tidied up a little". =item B -This takes the place of FILE *. Unlike FILE * it should be treated as +This takes the place of FILE *. Like FILE * it should be treated as opaque (it is probably safe to assume it is a pointer to something). =item B, B, B @@ -84,7 +84,7 @@ These correspond to fopen()/fdopen() arguments are the same. =item B, B -These are is fprintf()/vfprintf equivalents. +These are fprintf()/vfprintf() equivalents. =item B @@ -201,8 +201,8 @@ behaviour. =item B This corresponds to setlinebuf(). Use is deprecated pending -further discussion. (Perl core uses it I when "dumping" -is has nothing to do with $| auto-flush.) +further discussion. (Perl core uses it I when "dumping"; +it has nothing to do with $| auto-flush.) =back diff --git a/pod/perlcall.pod b/pod/perlcall.pod index 865d3bf..37916ae 100644 --- a/pod/perlcall.pod +++ b/pod/perlcall.pod @@ -1918,7 +1918,7 @@ refers to the last. =head2 Creating and calling an anonymous subroutine in C -As we've already shown, L can be used to invoke an +As we've already shown, C can be used to invoke an anonymous subroutine. However, our example showed how Perl script invoking an XSUB to preform this operation. Let's see how it can be done inside our C code: @@ -1931,8 +1931,9 @@ done inside our C code: perl_call_sv(cvrv, G_VOID|G_NOARGS); -L is used to compile the anonymous subroutine, which -will be the return value as well. Once this code reference is in hand, it +C is used to compile the anonymous subroutine, which +will be the return value as well (read more about C in +L). Once this code reference is in hand, it can be mixed in with all the previous examples we've shown. =head1 SEE ALSO diff --git a/pod/perldebug.pod b/pod/perldebug.pod index 8937c7e..8f49541 100644 --- a/pod/perldebug.pod +++ b/pod/perldebug.pod @@ -63,7 +63,7 @@ it prints out the description for just that command. The special argument of C produces a more compact help listing, designed to fit together on one screen. -If the output the C command (or any command, for that matter) scrolls +If the output of the C command (or any command, for that matter) scrolls past your screen, either precede the command with a leading pipe symbol so it's run through your pager, as in @@ -281,7 +281,7 @@ The sequence of steps taken by the debugger is 4. prompt user if at a breakpoint or in single-step 5. evaluate line -For example, this will print out C<$foo> every time line +For example, this will print out $foo every time line 53 is passed: a 53 print "DB FOUND $foo\n" @@ -667,8 +667,8 @@ C was called in a scalar context, also from I, but from line 4. Note that if you execute C command from inside an active C -statement, the backtrace will contain both C> -frame and an C>) frame. +statement, the backtrace will contain both C +frame and an C) frame. =item Listing @@ -868,7 +868,7 @@ compile subname> for the same purpose. =head2 Debugger Customization -Most probably you not want to modify the debugger, it contains enough +Most probably you do not want to modify the debugger, it contains enough hooks to satisfy most needs. You may change the behaviour of debugger from the debugger itself, using Cptions, from the command line via C environment variable, and from I. @@ -966,14 +966,14 @@ application. =item * -The array C<@{"_<$filename"}> is the line-by-line contents of +The array C<@{"_E$filename"}> is the line-by-line contents of $filename for all the compiled files. Same for Ced strings which contain subroutines, or which are currently executed. The C<$filename> for Ced strings looks like C<(eval 34)>. =item * -The hash C<%{"_<$filename"}> contains breakpoints and action (it is +The hash C<%{"_E$filename"}> contains breakpoints and action (it is keyed by line number), and individual entries are settable (as opposed to the whole hash). Only true/false is important to Perl, though the values used by F have the form @@ -981,22 +981,22 @@ C<"$break_condition\0$action">. Values are magical in numeric context: they are zeros if the line is not breakable. Same for evaluated strings which contain subroutines, or which are -currently executed. The C<$filename> for Ced strings looks like +currently executed. The $filename for Ced strings looks like C<(eval 34)>. =item * -The scalar C<${"_<$filename"}> contains C<"_<$filename">. Same for +The scalar C<${"_E$filename"}> contains C<"_E$filename">. Same for evaluated strings which contain subroutines, or which are currently -executed. The C<$filename> for Ced strings looks like C<(eval +executed. The $filename for Ced strings looks like C<(eval 34)>. =item * After each Cd file is compiled, but before it is executed, -C is called (if subroutine +C$filename"})> is called (if subroutine C exists). Here the $filename is the expanded name of -the Cd file (as found in values of C<%INC>). +the Cd file (as found in values of %INC). =item * diff --git a/pod/perldelta4.pod b/pod/perldelta4.pod index 9443f38..f1b6c8f 100644 --- a/pod/perldelta4.pod +++ b/pod/perldelta4.pod @@ -753,26 +753,27 @@ in Windows NT). This port includes support for perl extension building tools like L and L, so that many extensions available on the Comprehensive Perl Archive Network (CPAN) can now be readily built under Windows NT. See http://www.perl.com/ for more -information on CPAN, and L for more details on how to -get started with building this port. +information on CPAN and F in the perl distribution for more +details on how to get started with building this port. There is also support for building perl under the Cygwin32 environment. Cygwin32 is a set of GNU tools that make it possible to compile and run many UNIX programs under Windows NT by providing a mostly UNIX-like -interface for compilation and execution. See L for -more details on this port, and how to obtain the Cygwin32 toolkit. +interface for compilation and execution. See F in the +perl distribution for more details on this port and how to obtain the +Cygwin32 toolkit. =head2 Plan 9 -See L. +See F in the perl distribution. =head2 QNX -See L. +See F in the perl distribution. =head2 AmigaOS -See L. +See F in the perl distribution. =head1 Pragmata @@ -1379,8 +1380,7 @@ a possibility to shut down by trapping this error is granted. (W) qw() lists contain items separated by whitespace; as with literal strings, comment characters are not ignored, but are instead treated as literal data. (You may have used different delimiters than the -exclamation marks parentheses shown here; braces are also frequently -used.) +parentheses shown here; braces are also frequently used.) You probably wrote something like this: diff --git a/pod/perldiag.pod b/pod/perldiag.pod index dedde64..4808563 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1094,6 +1094,13 @@ a goto, or a loop control statement. (W) You are exiting a substitution by unconventional means, such as a return, a goto, or a loop control statement. +=item Explicit blessing to '' (assuming package main) + +(W) You are blessing a reference to a zero length string. This has +the effect of blessing the reference into the package main. This is +usually not what you want. Consider providing a default target +package, e.g. bless($ref, $p or 'MyPackage'); + =item Fatal VMS error at %s, line %d (P) An error peculiar to VMS. Something untoward happened in a VMS system @@ -1919,7 +1926,7 @@ was string. (P) The lexer got into a bad state while processing a case modifier. -=item Pareneses missing around "%s" list +=item Parentheses missing around "%s" list (W) You said something like @@ -1957,8 +1964,7 @@ the BSD version, which takes a pid. (W) qw() lists contain items separated by whitespace; as with literal strings, comment characters are not ignored, but are instead treated as literal data. (You may have used different delimiters than the -exclamation marks parentheses shown here; braces are also frequently -used.) +parentheses shown here; braces are also frequently used.) You probably wrote something like this: @@ -2075,6 +2081,18 @@ to use parens. In any case, a hash requires key/value B. %hash = ( one => 1, two => 2, ); # right %hash = qw( one 1 two 2 ); # also fine +=item Reference found where even-sized list expected + +(W) You gave a single reference where Perl was expecting a list with +an even number of elements (for assignment to a hash). This +usually means that you used the anon hash constructor when you meant +to use parens. In any case, a hash requires key/value B. + + %hash = { one => 1, two => 2, }; # WRONG + %hash = [ qw/ an anon array / ]; # WRONG + %hash = ( one => 1, two => 2, ); # right + %hash = qw( one 1 two 2 ); # also fine + =item Reference miscount in sv_replace() (W) The internal sv_replace() function was handed a new SV with a @@ -2183,6 +2201,7 @@ or possibly some other missing operator, such as a comma. Check your logic flow. =item Sequence (? incomplete + (F) A regular expression ended with an incomplete extension (?. See L. @@ -2641,7 +2660,7 @@ the name you call Perl by to C, C, and so on. =item Unsupported function %s -(F) This machines doesn't implement the indicated function, apparently. +(F) This machine doesn't implement the indicated function, apparently. At least, Configure doesn't think so. =item Unsupported socket function "%s" called @@ -2701,7 +2720,7 @@ a split() explicitly to an array (or list). (D) As an (ahem) accidental feature, C subroutines are looked up as methods (using the C<@ISA> hierarchy) even when the subroutines to be autoloaded were called as plain functions (e.g. C), not -as methods (e.g. Cbar()> or C<$obj->bar()>). +as methods (e.g. Cbar()> or C<$obj-Ebar()>). This bug will be rectified in Perl 5.005, which will use method lookup only for methods' Cs. However, there is a significant base @@ -2716,7 +2735,7 @@ C, execute C<*AUTOLOAD = \&BaseClass::AUTOLOAD> during startup. In code that currently says C you should remove AutoLoader from @ISA and change C to -C. +C. =item Use of %s is deprecated diff --git a/pod/perlembed.pod b/pod/perlembed.pod index 3209678..7876da5 100644 --- a/pod/perlembed.pod +++ b/pod/perlembed.pod @@ -20,8 +20,7 @@ Read about back-quotes and about C and C in L. =item B -Read about L and L and L -and L. +Read about do(), eval(), require(), and use() in L. =item B @@ -35,27 +34,49 @@ Read on... =head2 ROADMAP -L +Compiling your C program There's one example in each of the nine sections: -L +=over 4 -L +=item * -L +Adding a Perl interpreter to your C program -L +=item * -L +Calling a Perl subroutine from your C program -L +=item * -L +Evaluating a Perl statement from your C program -L +=item * -L +Performing Perl pattern matches and substitutions from your C program + +=item * + +Fiddling with the Perl stack from your C program + +=item * + +Maintaining a persistent interpreter + +=item * + +Maintaining multiple interpreter instances + +=item * + +Using Perl modules, which themselves use C libraries, from your C program + +=item * + +Embedding Perl under Win32 + +=back =head2 Compiling your C program @@ -96,7 +117,7 @@ Execute this statement for a hint about where to find CORE: perl -MConfig -e 'print $Config{archlib}' Here's how you'd compile the example in the next section, -L, on my Linux box: +Adding a Perl interpreter to your C program, on my Linux box: % gcc -O2 -Dbool=char -DHAS_BOOL -I/usr/local/include -I/usr/local/lib/perl5/i586-linux/5.003/CORE @@ -199,8 +220,8 @@ calling I. =head2 Calling a Perl subroutine from your C program To call individual Perl subroutines, you can use any of the B -functions documented in the L manpage. -In this example we'll use I. +functions documented in L. +In this example we'll use perl_call_argv(). That's shown below, in a program I'll call I. @@ -257,21 +278,20 @@ If you want to pass arguments to the Perl subroutine, you can add strings to the C-terminated C list passed to I. For other data types, or to examine return values, you'll need to manipulate the Perl stack. That's demonstrated in the -last section of this document: L. +last section of this document: Fiddling with the Perl stack from +your C program. =head2 Evaluating a Perl statement from your C program Perl provides two API functions to evaluate pieces of Perl code. -These are L and L. +These are perl_eval_sv() and perl_eval_pv(). Arguably, these are the only routines you'll ever need to execute snippets of Perl code from within your C program. Your code can be as long as you wish; it can contain multiple statements; it can employ -L, L and L to include -external Perl files. +use(), require(), and do() to include external Perl files. -I lets us evaluate individual Perl strings, and then +perl_eval_pv() lets us evaluate individual Perl strings, and then extract variables for coercion into C types. The following program, I, executes three Perl strings, extracting an C from the first, a C from the second, and a C from the third. @@ -320,7 +340,7 @@ I to create a string: In the example above, we've created a global variable to temporarily store the computed value of our eval'd expression. It is also possible and in most cases a better strategy to fetch the return value -from L instead. Example: +from perl_eval_pv() instead. Example: ... SV *val = perl_eval_pv("reverse 'rekcaH lreP rehtonA tsuJ'", TRUE); @@ -626,10 +646,10 @@ troubles. One way to avoid namespace collisions in this scenario is to translate the filename into a guaranteed-unique package name, and then compile -the code into that package using L. In the example +the code into that package using eval(). In the example below, each file will only be compiled once. Or, the application might choose to clean out the symbol table associated with the file -after it's no longer needed. Using L, We'll +after it's no longer needed. Using perl_call_argv(), We'll call the subroutine C which lives in the file C and pass the filename and boolean cleanup/cache flag as arguments. @@ -640,7 +660,7 @@ conditions that cause Perl's symbol table to grow. You might want to add some logic that keeps track of the process size, or restarts itself after a certain number of requests, to ensure that memory consumption is minimized. You'll also want to scope your variables -with L whenever possible. +with my() whenever possible. package Embed::Persistent; diff --git a/pod/perlfaq2.pod b/pod/perlfaq2.pod index bbc361a..0f73eea 100644 --- a/pod/perlfaq2.pod +++ b/pod/perlfaq2.pod @@ -169,7 +169,7 @@ include alt.sources; see their FAQ for details. =head2 Perl Books -A number books on Perl and/or CGI programming are available. A few of +A number of books on Perl and/or CGI programming are available. A few of these are good, some are ok, but many aren't worth your money. Tom Christiansen maintains a list of these books, some with extensive reviews, at http://www.perl.com/perl/critiques/index.html. @@ -314,7 +314,7 @@ to join or leave this list. =item Perl-Packrats Discussion related to archiving of perl materials, particularly the -Comprehensive PerlArchive Network (CPAN). Subscribe by emailing +Comprehensive Perl Archive Network (CPAN). Subscribe by emailing majordomo@cis.ufl.edu: subscribe perl-packrats diff --git a/pod/perlfaq3.pod b/pod/perlfaq3.pod index 65ebafd..7a30759 100644 --- a/pod/perlfaq3.pod +++ b/pod/perlfaq3.pod @@ -85,7 +85,7 @@ perl-mode for emacs can provide a remarkable amount of help with most (but not all) code, and even less programmable editors can provide significant assistance. -If you are using to using vgrind program for printing out nice code to +If you are used to using vgrind program for printing out nice code to a laser printer, you can take a stab at this using http://www.perl.com/CPAN/doc/misc/tips/working.vgrind.entry, but the results are not particularly satisfying for sophisticated code. @@ -260,7 +260,7 @@ module written in C can. With the FCGI module (from CPAN), a Perl executable compiled with sfio (see the F file in the distribution) and the mod_fastcgi module (available from http://www.fastcgi.com/) each of your perl scripts becomes a permanent -CGI daemon processes. +CGI daemon process. Both of these solutions can have far-reaching effects on your system and on the way you write your CGI scripts, so investigate them with diff --git a/pod/perlfaq4.pod b/pod/perlfaq4.pod index a5b505c..4c38d90 100644 --- a/pod/perlfaq4.pod +++ b/pod/perlfaq4.pod @@ -559,7 +559,7 @@ quite a lot of space by using bit strings instead: @articles = ( 1..10, 150..2000, 2017 ); undef $read; - grep (vec($read,$_,1) = 1, @articles); + for (@articles) { vec($read,$_,1) = 1 } Now check whether C is true for some C<$n>. diff --git a/pod/perlfaq5.pod b/pod/perlfaq5.pod index 03d5e6a..5d71f64 100644 --- a/pod/perlfaq5.pod +++ b/pod/perlfaq5.pod @@ -802,7 +802,7 @@ files. =head2 Why does Perl let me delete read-only files? Why does C<-i> clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the "Far More Than -You Every Wanted To Know" in +You Ever Wanted To Know" in http://www.perl.com/CPAN/doc/FMTEYEWTK/file-dir-perms . The executive summary: learn how your filesystem works. The diff --git a/pod/perlfaq7.pod b/pod/perlfaq7.pod index 283aa2b..d62ee36 100644 --- a/pod/perlfaq7.pod +++ b/pod/perlfaq7.pod @@ -669,7 +669,7 @@ before Perl has seen that such a package exists. It's wisest to make sure your packages are all defined before you start using them, which will be taken care of if you use the C statement instead of C. If not, make sure to use arrow notation (eg, -Cfind("Samy")>) instead. Object notation is explained in +Cfind("Samy")>) instead. Object notation is explained in L. =head2 How can I find out my current package? diff --git a/pod/perlfaq8.pod b/pod/perlfaq8.pod index f4d3c12..dbc1bcd 100644 --- a/pod/perlfaq8.pod +++ b/pod/perlfaq8.pod @@ -269,7 +269,7 @@ http://www.perl.com/CPAN/doc/misc/ancient/tutorial/eg/itimers.pl . In general, you may not be able to. The Time::HiRes module (available from CPAN) provides this functionality for some systems. -In general, you may not be able to. But if you system supports both the +In general, you may not be able to. But if your system supports both the syscall() function in Perl as well as a system call like gettimeofday(2), then you may be able to do something like this: @@ -758,8 +758,9 @@ If your version of perl is compiled without dynamic loading, then you just need to replace step 3 (B) with B and you will get a new F binary with your extension linked in. -See L for more details on building extensions, -the question "How do I keep my own module/library directory?" +See L for more details on building extensions +and an answer to the question "How do I keep my own module/library +directory?" =head2 How do I keep my own module/library directory? @@ -778,7 +779,7 @@ See Perl's L for more information. =head2 How do I add the directory my program lives in to the module/library search path? use FindBin; - use lib "$FindBin:Bin"; + use lib "$FindBin::Bin"; use your_own_modules; =head2 How do I add a directory to my include path at runtime? diff --git a/pod/perlform.pod b/pod/perlform.pod index 7e540b8..0b2a68c 100644 --- a/pod/perlform.pod +++ b/pod/perlform.pod @@ -20,8 +20,8 @@ apart from all the other "types" in Perl. This means that if you have a function named "Foo", it is not the same thing as having a format named "Foo". However, the default name for the format associated with a given filehandle is the same as the name of the filehandle. Thus, the default -format for STDOUT is name "STDOUT", and the default format for filehandle -TEMP is name "TEMP". They just look the same. They aren't. +format for STDOUT is named "STDOUT", and the default format for filehandle +TEMP is named "TEMP". They just look the same. They aren't. Output record formats are declared as follows: diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 1a5e0e6..6a0f9c2 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -657,7 +657,7 @@ Breaks the binding between a DBM file and a hash. [This function has been superseded by the tie() function.] -This binds a dbm(3), ndbm(3), sdbm(3), gdbm(), or Berkeley DB file to a +This binds a dbm(3), ndbm(3), sdbm(3), gdbm(3), or Berkeley DB file to a hash. HASH is the name of the hash. (Unlike normal open, the first argument is I a filehandle, even though it looks like one). DBNAME is the name of the database (without the F<.dir> or F<.pag> extension if @@ -1279,7 +1279,7 @@ you're done. You should reopen those to /dev/null if it's any issue. =item format -Declare a picture format with use by the write() function. For +Declare a picture format for use by the write() function. For example: format Something = @@ -1600,7 +1600,7 @@ Note that, because $_ is a reference into the list value, it can be used to modify the elements of the array. While this is useful and supported, it can cause bizarre results if the LIST is not a named array. Similarly, grep returns aliases into the original list, -much like the way that L's index variable aliases the list +much like the way that a for loops's index variable aliases the list elements. That is, modifying an element of a list returned by grep (for example, in a C, C or another C) actually modifies the element in the original list. @@ -1812,8 +1812,8 @@ subroutine, C, or C. If more than one value is listed, the list must be placed in parentheses. See L for details, including issues with tied arrays and hashes. -But you really probably want to be using my() instead, because local() isn't -what most people think of as "local"). See L for details. =item localtime EXPR @@ -2981,7 +2981,7 @@ always sleep the full amount. For delays of finer granularity than one second, you may use Perl's syscall() interface to access setitimer(2) if your system supports it, -or else see L below. +or else see L above. See also the POSIX module's sigpause() function. @@ -3175,9 +3175,9 @@ splits on whitespace (after skipping any leading whitespace). Anything matching PATTERN is taken to be a delimiter separating the fields. (Note that the delimiter may be longer than one character.) -If LIMIT is specified and is not negative, splits into no more than -that many fields (though it may split into fewer). If LIMIT is -unspecified, trailing null fields are stripped (which potential users +If LIMIT is specified and is positive, splits into no more than that +many fields (though it may split into fewer). If LIMIT is unspecified +or zero, trailing null fields are stripped (which potential users of pop() would do well to remember). If LIMIT is negative, it is treated as if an arbitrarily large LIMIT had been specified. @@ -3326,7 +3326,7 @@ omitted, uses a semi-random value based on the current time and process ID, among other things. In versions of Perl prior to 5.004 the default seed was just the current time(). This isn't a particularly good seed, so many old programs supply their own seed value (often C