diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 1999-07-18 21:33:57 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1999-07-18 21:33:57 +0000 |
commit | 0faf3e6502ba533234322c904a3fa6b70b610627 (patch) | |
tree | b6ab13f80d82a8fc50bdbffec28f1b78204dc125 | |
parent | 9f62e1ec6945a49a52880c6619a9badbeb4bb8ea (diff) | |
parent | da0838f1870c5338e6bf9ab745ef01fde1406476 (diff) | |
download | perl-0faf3e6502ba533234322c904a3fa6b70b610627.tar.gz |
Integrate with Sarathy.
p4raw-id: //depot/cfgperl@3698
-rw-r--r-- | Changes | 285 | ||||
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | cc_runtime.h | 1 | ||||
-rw-r--r-- | doio.c | 13 | ||||
-rw-r--r-- | doop.c | 1 | ||||
-rw-r--r-- | ebcdic.c | 8 | ||||
-rw-r--r-- | embed.h | 12 | ||||
-rwxr-xr-x | embed.pl | 3 | ||||
-rw-r--r-- | ext/B/B/CC.pm | 2 | ||||
-rw-r--r-- | ext/SDBM_File/sdbm/Makefile.PL | 8 | ||||
-rw-r--r-- | global.sym | 2 | ||||
-rw-r--r-- | hints/bsdos.sh | 1 | ||||
-rw-r--r-- | lib/Carp.pm | 12 | ||||
-rw-r--r-- | lib/ExtUtils/MM_Unix.pm | 50 | ||||
-rw-r--r-- | lib/ExtUtils/Manifest.pm | 37 | ||||
-rw-r--r-- | lib/Pod/Html.pm | 67 | ||||
-rw-r--r-- | lib/integer.pm | 11 | ||||
-rw-r--r-- | lib/vars.pm | 2 | ||||
-rw-r--r-- | mg.c | 2 | ||||
-rw-r--r-- | objXSUB.h | 8 | ||||
-rw-r--r-- | op.c | 2 | ||||
-rw-r--r-- | perl.c | 9 | ||||
-rwxr-xr-x | perlapi.c | 14 | ||||
-rw-r--r-- | perly.c | 3 | ||||
-rw-r--r-- | perly.y | 3 | ||||
-rw-r--r-- | pod/Win32.pod | 6 | ||||
-rw-r--r-- | pod/perldelta.pod | 6 | ||||
-rw-r--r-- | pod/perldiag.pod | 6 | ||||
-rw-r--r-- | pod/perlfaq.pod | 2 | ||||
-rw-r--r-- | pod/perlfaq1.pod | 26 | ||||
-rw-r--r-- | pod/perlfaq2.pod | 56 | ||||
-rw-r--r-- | pod/perlfaq3.pod | 64 | ||||
-rw-r--r-- | pod/perlfaq4.pod | 59 | ||||
-rw-r--r-- | pod/perlfaq5.pod | 17 | ||||
-rw-r--r-- | pod/perlfunc.pod | 37 | ||||
-rw-r--r-- | pod/perlguts.pod | 4 | ||||
-rw-r--r-- | pod/perlhist.pod | 2 | ||||
-rw-r--r-- | pod/perlop.pod | 21 | ||||
-rw-r--r-- | pod/perlport.pod | 2 | ||||
-rw-r--r-- | pod/perltodo.pod | 2 | ||||
-rw-r--r-- | pod/perltoot.pod | 2 | ||||
-rw-r--r-- | pod/perltootc.pod | 26 | ||||
-rw-r--r-- | pod/perlvar.pod | 8 | ||||
-rw-r--r-- | pp_ctl.c | 28 | ||||
-rw-r--r-- | pp_sys.c | 42 | ||||
-rw-r--r-- | proto.h | 3 | ||||
-rw-r--r-- | sv.c | 95 | ||||
-rwxr-xr-x | t/comp/proto.t | 20 | ||||
-rwxr-xr-x | t/op/chars.t | 74 | ||||
-rwxr-xr-x | t/op/exec.t | 4 | ||||
-rwxr-xr-x | t/op/goto.t | 23 | ||||
-rwxr-xr-x | t/op/ord.t | 2 | ||||
-rwxr-xr-x | t/op/tie.t | 12 | ||||
-rw-r--r-- | thrdvar.h | 2 | ||||
-rw-r--r-- | util.c | 6 | ||||
-rw-r--r-- | win32/bin/pl2bat.pl | 2 | ||||
-rw-r--r-- | x2p/find2perl.PL | 1174 |
57 files changed, 1613 insertions, 777 deletions
@@ -79,6 +79,291 @@ Version 5.005_58 Development release working toward 5.006 ---------------- ____________________________________________________________________________ +[ 3690] By: gsar on 1999/07/18 01:16:59 + Log: mention the -Minteger effect on modulus (from Nathan Torkington) + Branch: perl + ! lib/integer.pm +____________________________________________________________________________ +[ 3689] By: gsar on 1999/07/18 00:47:17 + Log: ensure __END__ appears on a line by itself in wrapped + scripts (thanks to Steve Tolkin <tolkin@mediaone.net>); + mention caveat about successfull kill() + Branch: perl + ! pod/perlfunc.pod win32/bin/pl2bat.pl +____________________________________________________________________________ +[ 3688] By: gsar on 1999/07/17 20:47:44 + Log: noecho noops (from Nicholas Clark <nick@flirble.org>) + Branch: perl + ! ext/SDBM_File/sdbm/Makefile.PL +____________________________________________________________________________ +[ 3687] By: gsar on 1999/07/17 20:43:27 + Log: make CC.pm use a distinct CCPP() macro rather than PP() + (suggested by Vishal Bhatia <vishalb@my-deja.com>) + Branch: perl + ! cc_runtime.h ext/B/B/CC.pm +____________________________________________________________________________ +[ 3686] By: gsar on 1999/07/17 20:39:08 + Log: tiny bug in vars.pm (from John Dlugosz) + Branch: perl + ! lib/vars.pm +____________________________________________________________________________ +[ 3685] By: gsar on 1999/07/17 20:37:27 + Log: applied suggested patch, along with later tweak + From: jan.dubois@ibm.net (Jan Dubois) + Date: Wed, 14 Jul 1999 23:53:43 +0200 + Message-ID: <37a902e7.15977234@smtp1.ibm.net> + Subject: Merge ActivePerl Stylesheet support etc into Pod::Html.pm + Branch: perl + ! lib/Pod/Html.pm +____________________________________________________________________________ +[ 3684] By: gsar on 1999/07/17 20:24:32 + Log: avoid #ifdef DEBUGGING in thrdvar.h (from Dominic Dunlop <domo@vo.lu>) + Branch: perl + ! thrdvar.h +____________________________________________________________________________ +[ 3683] By: gsar on 1999/07/17 20:21:01 + Log: From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Tue, 13 Jul 1999 05:44:28 -0400 (EDT) + Message-Id: <199907130944.FAA04473@monk.mps.ohio-state.edu> + Subject: [PATCH 5.005_57] Segfaults if $^P + Branch: perl + ! embed.h embed.pl global.sym mg.c objXSUB.h perl.c perlapi.c + ! proto.h +____________________________________________________________________________ +[ 3682] By: gsar on 1999/07/17 20:04:17 + Log: use a better prefixify() heuristic than m/perl/ (prefix/lib/perl5 + and prefix/lib/perl5/man are ass_u_med only if those directories + actually exist; else prefix/{lib,man} are used) + Branch: perl + ! lib/ExtUtils/MM_Unix.pm +____________________________________________________________________________ +[ 3681] By: gsar on 1999/07/17 19:12:33 + Log: allow $foo{$x} and $bar[$i] for (\$) prototype + Branch: perl + ! op.c t/comp/proto.t +____________________________________________________________________________ +[ 3680] By: gsar on 1999/07/17 18:23:55 + Log: fix vec() on magic values + From: Ian Phillipps <ian@dial.pipex.com> + Date: Mon, 12 Jul 1999 12:30:05 +0100 + Message-ID: <19990712123005.A11355@homer.diplex.co.uk> + Subject: [PATCH 5.005_57] Re: do_vecset is broken. Re: [ID 19990703.003]. + Branch: perl + ! doop.c t/op/tie.t +____________________________________________________________________________ +[ 3679] By: gsar on 1999/07/17 18:10:44 + Log: make system() return -1 and set $! if exec of child failed + From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Fri, 9 Jul 1999 05:21:13 -0400 + Message-ID: <19990709052113.A6201@monk.mps.ohio-state.edu> + Subject: [PATCH 5.005_57] system()==-1 and $! from failing fork/exec + Branch: perl + ! doio.c embed.h embed.pl global.sym objXSUB.h perlapi.c + ! pod/perlfunc.pod pp_sys.c proto.h t/op/exec.t +____________________________________________________________________________ +[ 3678] By: gsar on 1999/07/17 17:54:01 + Log: From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Fri, 9 Jul 1999 04:27:51 -0400 (EDT) + Message-Id: <199907090827.EAA03321@monk.mps.ohio-state.edu> + Subject: [PATCH 5.005_57] File descriptor leak in do_exec3 + Branch: perl + ! util.c +____________________________________________________________________________ +[ 3677] By: gsar on 1999/07/17 17:34:38 + Log: a modernized version of find2perl from Ken Pizzini <ken@halcyon.com>; + converted Ken's documentation outline into pod + Branch: perl + ! x2p/find2perl.PL +____________________________________________________________________________ +[ 3676] By: gsar on 1999/07/17 16:34:09 + Log: pod fixes (with minor edits) from Abigail, Ronald Kimball, Jon + Waddington, Tuomas Lukka, Steven Tolkin, Ian Phillipps, and + Steve Lidie + Branch: perl + ! pod/Win32.pod pod/perldelta.pod pod/perlfaq.pod + ! pod/perlfaq1.pod pod/perlfaq2.pod pod/perlfaq3.pod + ! pod/perlfaq4.pod pod/perlfaq5.pod pod/perlfunc.pod + ! pod/perlguts.pod pod/perlhist.pod pod/perlop.pod + ! pod/perlport.pod pod/perltoc.pod pod/perltodo.pod + ! pod/perltoot.pod pod/perltootc.pod pod/perlvar.pod +____________________________________________________________________________ +[ 3675] By: gsar on 1999/07/17 00:16:53 + Log: backout redundant change#3628 + Branch: perl + ! Changes hints/bsdos.sh +____________________________________________________________________________ +[ 3674] By: jhi on 1999/07/15 14:26:03 + Log: Fix the bin/oct/hex constant overflow tests for + long long platforms. + Branch: cfgperl + ! t/pragma/warn/util +____________________________________________________________________________ +[ 3673] By: jhi on 1999/07/14 21:59:11 + Log: Fixed AIX dynamic loading and AIX shared Perl library. + Tested in: AIX 4.1.5 cc+useshrplib+usethreads, 4.1.5 cc, + 4.1.5 gcc+useshrplib+usethreads, 4.3.1 cc+useshrplib. + Hijacked win32/makedef.pl for more general purpose export + list building, now it is used (as toplevel makedef.pl) + for win32 and AIX (perl_exp.SH made unnecessary). + Because the export lists are now correct in AIX, no more linker + warnings about "Exported symbol not defined" should appear. + Branch: cfgperl + + makedef.pl + - perl_exp.SH win32/makedef.pl + ! MANIFEST Makefile.SH ext/DynaLoader/DynaLoader_pm.PL + ! ext/DynaLoader/dl_aix.xs hints/aix.sh win32/Makefile + ! win32/makefile.mk +____________________________________________________________________________ +[ 3672] By: gsar on 1999/07/14 17:12:13 + Log: minor efficiency tweak + Branch: perl + ! pp_ctl.c +____________________________________________________________________________ +[ 3671] By: jhi on 1999/07/14 16:22:39 + Log: The regexec.c change of #3606 caused a core dump in fbm_instr() + if its caller re_intuit_start() was entered with strend == strpos + because end_shift ended up as -1. The patch ain't necessarily + correct but least the core dump is avoided. + Branch: cfgperl + ! regexec.c +____________________________________________________________________________ +[ 3670] By: jhi on 1999/07/13 07:59:09 + Log: Integrate with Sarathy. + Branch: cfgperl + - XSlock.h win32/GenCAPI.pl win32/TEST win32/autosplit.pl + - win32/genxsdef.pl win32/makemain.pl win32/makeperldef.pl + !> (integrate 67 files) +____________________________________________________________________________ +[ 3669] By: gsar on 1999/07/12 06:14:54 + Log: fixups for sundry warnings about function pointers + Branch: perl + ! ext/re/re.xs intrpvar.h op.c perl.c perl.h pp_ctl.c scope.h + ! sv.c thrdvar.h util.c win32/Makefile win32/makefile.mk + ! win32/win32.c win32/win32.h +____________________________________________________________________________ +[ 3668] By: gsar on 1999/07/12 04:11:58 + Log: tweaks for win32/borland + Branch: perl + ! t/pragma/locale.t win32/makedef.pl win32/makefile.mk +____________________________________________________________________________ +[ 3667] By: gsar on 1999/07/12 01:55:15 + Log: yet more cleanups of the PERL_OBJECT, MULTIPLICITY and USE_THREADS + builds; passing the implicit context is unified among the three + flavors; PERL_IMPLICIT_CONTEXT is auto-enabled under all three + flavors (see the top of perl.h) for testing; all varargs functions + foo() have a va_list-taking variant vfoo() for generating the + context-free versions; the PERL_OBJECT build should now be + hyper-compatible with CPAN extensions (C++ is totally out of + the picture) + + result has only been tested on Windows + + TODO: write docs on the THX rationale and idiomatic usage of + the Perl API + Branch: perl + - XSlock.h win32/GenCAPI.pl win32/TEST win32/autosplit.pl + - win32/genxsdef.pl win32/makemain.pl win32/makeperldef.pl + ! MANIFEST XSUB.h bytecode.pl deb.c dump.c embed.h embed.pl + ! embedvar.h ext/B/B.xs ext/ByteLoader/ByteLoader.xs + ! ext/ByteLoader/byterun.c ext/Data/Dumper/Dumper.xs + ! ext/Devel/Peek/Peek.xs ext/Fcntl/Fcntl.xs ext/IO/IO.xs + ! ext/Opcode/Opcode.xs ext/POSIX/POSIX.xs + ! ext/SDBM_File/SDBM_File.xs ext/Socket/Socket.xs + ! ext/Thread/Thread.xs ext/attrs/attrs.xs ext/re/re.xs + ! global.sym globals.c intrpvar.h iperlsys.h + ! lib/ExtUtils/MM_Unix.pm lib/ExtUtils/MM_Win32.pm + ! lib/ExtUtils/MakeMaker.pm lib/ExtUtils/xsubpp lib/base.pm + ! lib/warning.pm malloc.c objXSUB.h perl.c perl.h perlapi.c + ! perlapi.h perlio.c pp_sys.c proto.h regcomp.c regexec.c + ! scope.c sv.c thrdvar.h util.c win32/Makefile win32/config_H.bc + ! win32/config_H.gc win32/config_H.vc win32/config_h.PL + ! win32/dl_win32.xs win32/include/dirent.h + ! win32/include/sys/socket.h win32/makedef.pl win32/makefile.mk + ! win32/perllib.c win32/runperl.c win32/win32.c win32/win32.h + ! win32/win32iop.h win32/win32sck.c +____________________________________________________________________________ +[ 3666] By: jhi on 1999/07/11 22:00:13 + Log: Integrate with Sarathy. + Branch: cfgperl + !> op.c t/op/lex_assign.t +____________________________________________________________________________ +[ 3665] By: jhi on 1999/07/11 21:59:01 + Log: More manual sync. + Branch: cfgperl + ! pod/perldelta.pod +____________________________________________________________________________ +[ 3664] By: gsar on 1999/07/11 19:11:07 + Log: change#3612 was buggy and failed to build Tk; applied Ilya's + remedy and related tests via private mail + Branch: perl + ! op.c t/op/lex_assign.t +____________________________________________________________________________ +[ 3663] By: jhi on 1999/07/11 15:04:37 + Log: Manual synchronization with Sarathy (some files + had drifted apart for no apparent reason), plus + I had a typo in dl_vms.xs Sarathy had fixed. + Branch: cfgperl + ! ext/DynaLoader/dl_vms.xs pod/perldelta.pod pp.c pp_sys.c +____________________________________________________________________________ +[ 3662] By: jhi on 1999/07/10 12:23:21 + Log: Change t/pragma/warn oct()/hex() overflow tests to use %Config + to adapt to the underlying platform (the binary, 0b1..., test + was broken in 64-bit platforms). Also change "hex" in the + warning messages to "hexadecimal" to match "binary" and "octal". + Branch: cfgperl + ! pod/perldiag.pod t/pragma/warn/util util.c +____________________________________________________________________________ +[ 3661] By: jhi on 1999/07/08 21:54:55 + Log: Integrate with Sarathy. + Branch: cfgperl + +> perlapi.c perlapi.h + !> (integrate 43 files) +____________________________________________________________________________ +[ 3660] By: gsar on 1999/07/08 18:47:35 + Log: more PERL_OBJECT cleanups (changes still untested on Unix!) + Branch: perl + + perlapi.c perlapi.h + ! MANIFEST XSUB.h emacs/ptags embed.h embed.pl embedvar.h + ! ext/Opcode/Opcode.xs global.sym globals.c intrpvar.h + ! iperlsys.h mg.c miniperlmain.c objXSUB.h perl.c perl.h perly.c + ! pp.c pp_ctl.c pp_hot.c proto.h regcomp.c regcomp.h regexec.c + ! scope.c scope.h sv.c thrdvar.h toke.c util.c win32/GenCAPI.pl + ! win32/Makefile win32/makedef.pl win32/perllib.c win32/win32.c + ! win32/win32.h +____________________________________________________________________________ +[ 3659] By: gsar on 1999/07/08 18:41:45 + Log: sundry cleanups for clean build on windows + Branch: perl + ! doio.c regcomp.c regcomp.h t/io/openpid.t utf8.c +____________________________________________________________________________ +[ 3658] By: gsar on 1999/07/08 01:24:25 + Log: fixes for logical bugs in the lexwarn patch; other tweaks to avoid + type mismatch problems + Branch: perl + ! doio.c gv.c op.c pp.c regcomp.c regexec.c run.c sv.c + ! t/pragma/warn/op toke.c utf8.c util.c +____________________________________________________________________________ +[ 3657] By: jhi on 1999/07/07 23:01:16 + Log: Integrate with Sarathy. perldiag.pod required manual editing. + Branch: cfgperl + ! pod/perldiag.pod + !> Changes configure.com ext/B/B/Deparse.pm + !> ext/ByteLoader/Makefile.PL ext/Fcntl/Fcntl.xs + !> ext/IO/lib/IO/File.pm gv.c iperlsys.h lib/ExtUtils/MM_VMS.pm + !> lib/File/Basename.pm lib/File/Spec/VMS.pm perlsfio.h + !> t/base/rs.t t/lib/io_multihomed.t t/lib/textfill.t + !> t/lib/textwrap.t t/op/filetest.t t/op/mkdir.t + !> t/pragma/overload.t thread.h vms/vms.c +____________________________________________________________________________ +[ 3656] By: gsar on 1999/07/07 21:04:38 + Log: integrate cfgperl contents + Branch: perl + +> lib/unicode/Is/ASCII.pl lib/unicode/Is/Cntrl.pl + +> lib/unicode/Is/Graph.pl lib/unicode/Is/Punct.pl + +> lib/unicode/Is/Word.pl lib/unicode/Is/XDigit.pl + ! Changes + !> (integrate 45 files) +____________________________________________________________________________ [ 3655] By: gsar on 1999/07/07 18:55:45 Log: filetest.t and ByteLoader build tweaks from Peter Prymmer <pvhp@forte.com> @@ -1184,6 +1184,7 @@ t/op/assignwarn.t See if OP= operators warn correctly for undef targets t/op/auto.t See if autoincrement et all work t/op/avhv.t See if pseudo-hashes work t/op/bop.t See if bitops work +t/op/chars.t See if character escapes work t/op/chop.t See if chop works t/op/closure.t See if closures work t/op/cmp.t See if the various string and numeric compare work diff --git a/cc_runtime.h b/cc_runtime.h index 110b106d7d..dbc7475774 100644 --- a/cc_runtime.h +++ b/cc_runtime.h @@ -1,4 +1,5 @@ #define DOOP(ppname) PUTBACK; PL_op = ppname(aTHX); SPAGAIN +#define CCPP(s) OP * s(pTHX) #define PP_LIST(g) do { \ dMARK; \ @@ -1049,6 +1049,13 @@ Perl_my_lstat(pTHX) bool Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp) { + return do_aexec5(really, mark, sp, 0, 0); +} + +bool +Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp, + int fd, int do_report) +{ register char **a; char *tmps; STRLEN n_a; @@ -1073,6 +1080,12 @@ Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp) if (ckWARN(WARN_EXEC)) Perl_warner(aTHX_ WARN_EXEC, "Can't exec \"%s\": %s", PL_Argv[0], Strerror(errno)); + if (do_report) { + int e = errno; + + PerlLIO_write(fd, (void*)&e, sizeof(int)); + PerlLIO_close(fd); + } } do_execfree(); return FALSE; @@ -746,6 +746,7 @@ Perl_do_vecset(pTHX_ SV *sv) s[offset+3] = lval & 255; } } + SvSETMAGIC(targ); } void @@ -25,6 +25,14 @@ ebcdic_control(int ch) } else { /* Want uncontrol */ if (ch == '\177' || ch == -1) return('?'); + else if (ch == '\157') + return('\177'); + else if (ch == '\174') + return('\000'); + else if (ch == '^') /* '\137' in 1047, '\260' in 819 */ + return('\036'); + else if (ch == '\155') + return('\037'); else if (0 < ch && ch < (sizeof(controllablechars) - 1)) return(controllablechars[ch+1]); else @@ -102,6 +102,7 @@ #define die_where Perl_die_where #define dounwind Perl_dounwind #define do_aexec Perl_do_aexec +#define do_aexec5 Perl_do_aexec5 #define do_binmode Perl_do_binmode #define do_chop Perl_do_chop #define do_close Perl_do_close @@ -204,6 +205,7 @@ #define ibcmp Perl_ibcmp #define ibcmp_locale Perl_ibcmp_locale #define ingroup Perl_ingroup +#define init_debugger Perl_init_debugger #define init_stacks Perl_init_stacks #define intro_my Perl_intro_my #define instr Perl_instr @@ -781,7 +783,6 @@ #define incpush S_incpush #define init_interp S_init_interp #define init_ids S_init_ids -#define init_debugger S_init_debugger #define init_lexer S_init_lexer #define init_main_stash S_init_main_stash #define init_perllib S_init_perllib @@ -1422,6 +1423,7 @@ #define die_where(a,b) Perl_die_where(aTHX_ a,b) #define dounwind(a) Perl_dounwind(aTHX_ a) #define do_aexec(a,b,c) Perl_do_aexec(aTHX_ a,b,c) +#define do_aexec5(a,b,c,d,e) Perl_do_aexec5(aTHX_ a,b,c,d,e) #define do_binmode(a,b,c) Perl_do_binmode(aTHX_ a,b,c) #define do_chop(a,b) Perl_do_chop(aTHX_ a,b) #define do_close(a,b) Perl_do_close(aTHX_ a,b) @@ -1523,6 +1525,7 @@ #define ibcmp(a,b,c) Perl_ibcmp(aTHX_ a,b,c) #define ibcmp_locale(a,b,c) Perl_ibcmp_locale(aTHX_ a,b,c) #define ingroup(a,b) Perl_ingroup(aTHX_ a,b) +#define init_debugger() Perl_init_debugger(aTHX) #define init_stacks() Perl_init_stacks(aTHX) #define intro_my() Perl_intro_my(aTHX) #define instr(a,b) Perl_instr(aTHX_ a,b) @@ -2091,7 +2094,6 @@ #define incpush(a,b) S_incpush(aTHX_ a,b) #define init_interp() S_init_interp(aTHX) #define init_ids() S_init_ids(aTHX) -#define init_debugger() S_init_debugger(aTHX) #define init_lexer() S_init_lexer(aTHX) #define init_main_stash() S_init_main_stash(aTHX) #define init_perllib() S_init_perllib(aTHX) @@ -2829,6 +2831,8 @@ #define dounwind Perl_dounwind #define Perl_do_aexec CPerlObj::Perl_do_aexec #define do_aexec Perl_do_aexec +#define Perl_do_aexec5 CPerlObj::Perl_do_aexec5 +#define do_aexec5 Perl_do_aexec5 #define Perl_do_binmode CPerlObj::Perl_do_binmode #define do_binmode Perl_do_binmode #define Perl_do_chop CPerlObj::Perl_do_chop @@ -3023,6 +3027,8 @@ #define ibcmp_locale Perl_ibcmp_locale #define Perl_ingroup CPerlObj::Perl_ingroup #define ingroup Perl_ingroup +#define Perl_init_debugger CPerlObj::Perl_init_debugger +#define init_debugger Perl_init_debugger #define Perl_init_stacks CPerlObj::Perl_init_stacks #define init_stacks Perl_init_stacks #define Perl_intro_my CPerlObj::Perl_intro_my @@ -4135,8 +4141,6 @@ #define init_interp S_init_interp #define S_init_ids CPerlObj::S_init_ids #define init_ids S_init_ids -#define S_init_debugger CPerlObj::S_init_debugger -#define init_debugger S_init_debugger #define S_init_lexer CPerlObj::S_init_lexer #define init_lexer S_init_lexer #define S_init_main_stash CPerlObj::S_init_main_stash @@ -1081,6 +1081,7 @@ p |OP* |vdie |const char* pat|va_list* args p |OP* |die_where |char* message|STRLEN msglen p |void |dounwind |I32 cxix p |bool |do_aexec |SV* really|SV** mark|SV** sp +p |bool |do_aexec5 |SV* really|SV** mark|SV** sp|int fd|int flag p |int |do_binmode |PerlIO *fp|int iotype|int flag p |void |do_chop |SV* asv|SV* sv p |bool |do_close |GV* gv|bool not_implicit @@ -1191,6 +1192,7 @@ p |void |hv_undef |HV* tb p |I32 |ibcmp |const char* a|const char* b|I32 len p |I32 |ibcmp_locale |const char* a|const char* b|I32 len p |I32 |ingroup |I32 testgid|I32 effective +p |void |init_debugger p |void |init_stacks p |U32 |intro_my p |char* |instr |const char* big|const char* little @@ -1819,7 +1821,6 @@ s |void |forbid_setid |char * s |void |incpush |char *|int s |void |init_interp s |void |init_ids -s |void |init_debugger s |void |init_lexer s |void |init_main_stash s |void |init_perllib diff --git a/ext/B/B/CC.pm b/ext/B/B/CC.pm index 98c9318055..f912c413f2 100644 --- a/ext/B/B/CC.pm +++ b/ext/B/B/CC.pm @@ -124,7 +124,7 @@ sub output_runtime { print qq(#include "cc_runtime.h"\n); foreach $ppdata (@pp_list) { my ($name, $runtime, $declare) = @$ppdata; - print "\nstatic\nPP($name)\n{\n"; + print "\nstatic\nCCPP($name)\n{\n"; my ($type, $varlist, $line); while (($type, $varlist) = each %$declare) { print "\t$type ", join(", ", @$varlist), ";\n"; diff --git a/ext/SDBM_File/sdbm/Makefile.PL b/ext/SDBM_File/sdbm/Makefile.PL index e6fdcf9306..4453dea1fd 100644 --- a/ext/SDBM_File/sdbm/Makefile.PL +++ b/ext/SDBM_File/sdbm/Makefile.PL @@ -42,12 +42,14 @@ INST_STATIC = libsdbm$(LIB_EXT) } sub MY::top_targets { + my $noecho = shift->{NOECHO}; + my $r = ' all :: static - $(NOECHO) $(NOOP) + ' . $noecho . '$(NOOP) config :: - $(NOECHO) $(NOOP) + ' . $noecho . '$(NOOP) lint: lint -abchx $(LIBSRCS) @@ -58,7 +60,7 @@ lint: # variables into the environment so $(MYEXTLIB) is set in here to this # value which can not be built. sdbm/libsdbm.a: - $(NOECHO) $(NOOP) + ' . $noecho . '$(NOOP) ' unless $^O eq 'VMS'; return $r; diff --git a/global.sym b/global.sym index 06c71da103..fba03069d8 100644 --- a/global.sym +++ b/global.sym @@ -86,6 +86,7 @@ Perl_vdie Perl_die_where Perl_dounwind Perl_do_aexec +Perl_do_aexec5 Perl_do_binmode Perl_do_chop Perl_do_close @@ -178,6 +179,7 @@ Perl_hv_undef Perl_ibcmp Perl_ibcmp_locale Perl_ingroup +Perl_init_debugger Perl_init_stacks Perl_intro_my Perl_instr diff --git a/hints/bsdos.sh b/hints/bsdos.sh index e8cfb4a972..c54a0c1606 100644 --- a/hints/bsdos.sh +++ b/hints/bsdos.sh @@ -86,7 +86,6 @@ case "$osvers" in libswanted="rpc curses termcap $libswanted" ;; 4.0*) - POSIX_cflags='ccflags="$ccflags -DSTRUCT_TM_HASZONE"' # ELF dynamic link libraries starting in 4.0 (???) useshrplib='true' so='so' diff --git a/lib/Carp.pm b/lib/Carp.pm index 5fb8809900..8301f37da7 100644 --- a/lib/Carp.pm +++ b/lib/Carp.pm @@ -175,7 +175,10 @@ sub longmess { } # here's where the error message, $mess, gets constructed $mess .= "\t$sub " if $error eq "called"; - $mess .= "$error at $file line $line\n"; + $mess .= "$error at $file line $line"; + $mess .= " thread " . Thread->self->tid + if exists $main::{'Thread::'}; + $mess .= "\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 @@ -254,7 +257,12 @@ sub shortmess { # Short-circuit &longmess if called via multiple packages # 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; + my $msg; + $msg = "$error at $file line $line"; + $msg .= " thread " . Thread->self->tid + if exists $main::{'Thread::'}; + $msg .= "\n"; + $msg =~ tr/\0//d; return $msg; } } diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index 0e4712c4f1..282d47166a 100644 --- a/lib/ExtUtils/MM_Unix.pm +++ b/lib/ExtUtils/MM_Unix.pm @@ -11,8 +11,7 @@ use vars qw($VERSION $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Is_PERL_OBJECT $VERSION = substr q$Revision: 1.12602 $, 10; # $Id: MM_Unix.pm,v 1.126 1998/06/28 21:32:49 k Exp k $ -Exporter::import('ExtUtils::MakeMaker', - qw( $Verbose &neatvalue)); +Exporter::import('ExtUtils::MakeMaker', qw($Verbose &neatvalue)); $Is_OS2 = $^O eq 'os2'; $Is_Mac = $^O eq 'MacOS'; @@ -1760,8 +1759,7 @@ usually solves this kind of problem. my($install_variable,$search_prefix,$replace_prefix); - # The rule, taken from Configure, is that if prefix contains perl, - # we shape the tree + # If the prefix contains perl, Configure shapes the tree as follows: # perlprefix/lib/ INSTALLPRIVLIB # perlprefix/lib/pod/ # perlprefix/lib/site_perl/ INSTALLSITELIB @@ -1773,6 +1771,11 @@ usually solves this kind of problem. # prefix/lib/perl5/site_perl/ INSTALLSITELIB # prefix/bin/ INSTALLBIN # prefix/lib/perl5/man/ INSTALLMAN1DIR + # + # The above results in various kinds of breakage on various + # platforms, so we cope with it as follows: if prefix/lib/perl5 + # or prefix/lib/perl5/man exist, we'll replace those instead + # of /prefix/{lib,man} $replace_prefix = qq[\$\(PREFIX\)]; for $install_variable (qw/ @@ -1781,36 +1784,45 @@ usually solves this kind of problem. /) { $self->prefixify($install_variable,$configure_prefix,$replace_prefix); } - $search_prefix = $configure_prefix =~ /perl/ ? - $self->catdir($configure_prefix,"lib") : - $self->catdir($configure_prefix,"lib","perl5"); + my $funkylibdir = $self->catdir($configure_prefix,"lib","perl5"); + $funkylibdir = '' unless -d $funklibdir; + $search_prefix = $funkylibdir || $self->catdir($configure_prefix,"lib"); if ($self->{LIB}) { $self->{INSTALLPRIVLIB} = $self->{INSTALLSITELIB} = $self->{LIB}; $self->{INSTALLARCHLIB} = $self->{INSTALLSITEARCH} = $self->catdir($self->{LIB},$Config{'archname'}); - } else { - $replace_prefix = $self->{PREFIX} =~ /perl/ ? - $self->catdir(qq[\$\(PREFIX\)],"lib") : - $self->catdir(qq[\$\(PREFIX\)],"lib","perl5"); + } + else { + if (-d $self->catdir($self->{PREFIX},"lib","perl5")) { + $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib", "perl5"); + } + else { + $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib"); + } for $install_variable (qw/ INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB INSTALLSITEARCH - /) { + /) + { $self->prefixify($install_variable,$search_prefix,$replace_prefix); } } - $search_prefix = $configure_prefix =~ /perl/ ? - $self->catdir($configure_prefix,"man") : - $self->catdir($configure_prefix,"lib","perl5","man"); - $replace_prefix = $self->{PREFIX} =~ /perl/ ? - $self->catdir(qq[\$\(PREFIX\)],"man") : - $self->catdir(qq[\$\(PREFIX\)],"lib","perl5","man"); + my $funkymandir = $self->catdir($configure_prefix,"lib","perl5","man"); + $funkymandir = '' unless -d $funkmandir; + $search_prefix = $funkymandir || $self->catdir($configure_prefix,"man"); + if (-d $self->catdir($self->{PREFIX},"lib","perl5", "man")) { + $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib", "perl5", "man"); + } + else { + $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"man"); + } for $install_variable (qw/ INSTALLMAN1DIR INSTALLMAN3DIR - /) { + /) + { $self->prefixify($install_variable,$search_prefix,$replace_prefix); } diff --git a/lib/ExtUtils/Manifest.pm b/lib/ExtUtils/Manifest.pm index 1a6dde7a02..52cfc2a80a 100644 --- a/lib/ExtUtils/Manifest.pm +++ b/lib/ExtUtils/Manifest.pm @@ -25,6 +25,7 @@ $MANIFEST = 'MANIFEST'; # Really cool fix from Ilya :) unless (defined $Config{d_link}) { + local $^W; *ln = \&cp; } @@ -268,27 +269,27 @@ ExtUtils::Manifest - utilities to write and check a MANIFEST file =head1 SYNOPSIS -C<require ExtUtils::Manifest;> + require ExtUtils::Manifest; -C<ExtUtils::Manifest::mkmanifest;> + ExtUtils::Manifest::mkmanifest; -C<ExtUtils::Manifest::manicheck;> + ExtUtils::Manifest::manicheck; -C<ExtUtils::Manifest::filecheck;> + ExtUtils::Manifest::filecheck; -C<ExtUtils::Manifest::fullcheck;> + ExtUtils::Manifest::fullcheck; -C<ExtUtils::Manifest::skipcheck;> + ExtUtils::Manifest::skipcheck; -C<ExtUtild::Manifest::manifind();> + ExtUtils::Manifest::manifind(); -C<ExtUtils::Manifest::maniread($file);> + ExtUtils::Manifest::maniread($file); -C<ExtUtils::Manifest::manicopy($read,$target,$how);> + ExtUtils::Manifest::manicopy($read,$target,$how); =head1 DESCRIPTION -Mkmanifest() writes all files in and below the current directory to a +mkmanifest() writes all files in and below the current directory to a file named in the global variable $ExtUtils::Manifest::MANIFEST (which defaults to C<MANIFEST>) in the current directory. It works similar to @@ -302,33 +303,33 @@ comments are separated by one or more TAB characters in the output. All files that match any regular expression in a file C<MANIFEST.SKIP> (if such a file exists) are ignored. -Manicheck() checks if all the files within a C<MANIFEST> in the +manicheck() checks if all the files within a C<MANIFEST> in the current directory really do exist. It only reports discrepancies and exits silently if MANIFEST and the tree below the current directory are in sync. -Filecheck() finds files below the current directory that are not +filecheck() finds files below the current directory that are not mentioned in the C<MANIFEST> file. An optional file C<MANIFEST.SKIP> will be consulted. Any file matching a regular expression in such a file will not be reported as missing in the C<MANIFEST> file. -Fullcheck() does both a manicheck() and a filecheck(). +fullcheck() does both a manicheck() and a filecheck(). -Skipcheck() lists all the files that are skipped due to your +skipcheck() lists all the files that are skipped due to your C<MANIFEST.SKIP> file. -Manifind() returns a hash reference. The keys of the hash are the +manifind() returns a hash reference. The keys of the hash are the files found below the current directory. -Maniread($file) reads a named C<MANIFEST> file (defaults to +maniread($file) reads a named C<MANIFEST> file (defaults to C<MANIFEST> in the current directory) and returns a HASH reference with files being the keys and comments being the values of the HASH. Blank lines and lines which start with C<#> in the C<MANIFEST> file are discarded. -I<Manicopy($read,$target,$how)> copies the files that are the keys in +C<manicopy($read,$target,$how)> copies the files that are the keys in the HASH I<%$read> to the named target directory. The HASH reference -I<$read> is typically returned by the maniread() function. This +$read is typically returned by the maniread() function. This function is useful for producing a directory tree identical to the intended distribution tree. The third parameter $how can be used to specify a different methods of "copying". Valid values are C<cp>, diff --git a/lib/Pod/Html.pm b/lib/Pod/Html.pm index ee303d353f..6077291225 100644 --- a/lib/Pod/Html.pm +++ b/lib/Pod/Html.pm @@ -137,12 +137,24 @@ Do not recurse into subdirectories specified in podpath. Specify the title of the resulting HTML file. +=item css + + --css=stylesheet + +Specify the URL of a cascading style sheet. + =item verbose --verbose Display progress messages. +=item quiet + + --quiet + +Don't display I<mostly harmless> warning messages. + =back =head1 EXAMPLE @@ -156,6 +168,10 @@ Display progress messages. "--infile=foo.pod", "--outfile=/perl/nmanual/foo.html"); +=head1 ENVIRONMENT + +Uses $Config{pod2html} to setup default options. + =head1 AUTHOR Tom Christiansen, E<lt>tchrist@perl.comE<gt>. @@ -174,8 +190,8 @@ This program is distributed under the Artistic License. =cut -my $dircache = "pod2html-dircache"; -my $itemcache = "pod2html-itemcache"; +my $dircache = "pod2html.d~~"; +my $itemcache = "pod2html.i~~"; my @begin_stack = (); # begin/end stack @@ -193,7 +209,9 @@ my $podfile = ""; # read from stdin by default my @podpath = (); # list of directories containing library pods. my $podroot = "."; # filesystem base directory from which all # relative paths in $podpath stem. +my $css = ''; # Cascading style sheet my $recurse = 1; # recurse on subdirectories in $podpath. +my $quiet = 0; # not quiet by default my $verbose = 0; # not verbose by default my $doindex = 1; # non-zero if we should generate an index my $listlevel = 0; # current list depth @@ -212,6 +230,7 @@ my %items_named = (); # for the multiples of the same item in perlfunc my @items_seen = (); my $netscape = 0; # whether or not to use netscape directives. my $title; # title to give the pod(s) +my $header = 0; # produce block header/footer my $top = 1; # true if we are at the top of the doc. used # to prevent the first <HR> directive. my $paragraph; # which paragraph we're processing (used @@ -224,8 +243,8 @@ my %items = (); # associative array used to find the location my $Is83; # is dos with short filenames (8.3) sub init_globals { -$dircache = "pod2html-dircache"; -$itemcache = "pod2html-itemcache"; +$dircache = "pod2html.d~~"; +$itemcache = "pod2html.i~~"; @begin_stack = (); # begin/end stack @@ -237,7 +256,9 @@ $podfile = ""; # read from stdin by default @podpath = (); # list of directories containing library pods. $podroot = "."; # filesystem base directory from which all # relative paths in $podpath stem. +$css = ''; # Cascading style sheet $recurse = 1; # recurse on subdirectories in $podpath. +$quiet = 0; # not quiet by default $verbose = 0; # not verbose by default $doindex = 1; # non-zero if we should generate an index $listlevel = 0; # current list depth @@ -255,6 +276,7 @@ $ignore = 1; # whether or not to format text. we don't @items_seen = (); %items_named = (); $netscape = 0; # whether or not to use netscape directives. +$header = 0; # produce block header/footer $title = ''; # title to give the pod(s) $top = 1; # true if we are at the top of the doc. used # to prevent the first <HR> directive. @@ -356,20 +378,32 @@ sub pod2html { if ($title) { $title =~ s/\s*\(.*\)//; } else { - warn "$0: no title for $podfile"; + warn "$0: no title for $podfile" unless $quiet; $podfile =~ /^(.*)(\.[^.\/]+)?$/; $title = ($podfile eq "-" ? 'No Title' : $1); warn "using $title" if $verbose; } + my $csslink = $css ? qq(\n<LINK REL="stylesheet" HREF="$css" TYPE="text/css">) : ''; + $csslink =~ s,\\,/,g; + $csslink =~ s,(/.):,$1|,; + + my $block = $header ? <<END_OF_BLOCK : ''; +<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%> +<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc"> +<FONT SIZE=+1><STRONG><P CLASS=block> $title</P></STRONG></FONT> +</TD></TR> +</TABLE> +END_OF_BLOCK + print HTML <<END_OF_HEAD; <HTML> <HEAD> -<TITLE>$title</TITLE> +<TITLE>$title</TITLE>$csslink <LINK REV="made" HREF="mailto:$Config{perladmin}"> </HEAD> <BODY> - +$block END_OF_HEAD # load/reload/validate/cache %pages and %items @@ -431,13 +465,14 @@ END_OF_HEAD next if @begin_stack && $begin_stack[-1] ne 'html'; my $text = $_; process_text(\$text, 1); - print HTML "<P>\n$text"; + print HTML "<P>\n$text</P>\n"; } } # finish off any pending directives finish_list(); print HTML <<END_OF_TAIL; +$block </BODY> </HTML> @@ -489,12 +524,16 @@ Usage: $0 --help --htmlroot=<name> --infile=<name> --outfile=<name> --recurse - recurse on those subdirectories listed in podpath (default behavior). --title - title that will appear in resulting html file. + --header - produce block header/footer + --css - stylesheet URL --verbose - self-explanatory + --quiet - supress some benign warning messages END_OF_USAGE sub parse_command_line { - my ($opt_flush,$opt_help,$opt_htmldir,$opt_htmlroot,$opt_index,$opt_infile,$opt_libpods,$opt_netscape,$opt_outfile,$opt_podpath,$opt_podroot,$opt_norecurse,$opt_recurse,$opt_title,$opt_verbose); + my ($opt_flush,$opt_help,$opt_htmldir,$opt_htmlroot,$opt_index,$opt_infile,$opt_libpods,$opt_netscape,$opt_outfile,$opt_podpath,$opt_podroot,$opt_norecurse,$opt_recurse,$opt_title,$opt_verbose,$opt_css,$opt_header,$opt_quiet); + unshift @ARGV, split ' ', $Config{pod2html} if $Config{pod2html}; my $result = GetOptions( 'flush' => \$opt_flush, 'help' => \$opt_help, @@ -510,7 +549,10 @@ sub parse_command_line { 'norecurse' => \$opt_norecurse, 'recurse!' => \$opt_recurse, 'title=s' => \$opt_title, + 'header' => \$opt_header, + 'css=s' => \$opt_css, 'verbose' => \$opt_verbose, + 'quiet' => \$opt_quiet, ); usage("-", "invalid parameters") if not $result; @@ -534,7 +576,10 @@ sub parse_command_line { $doindex = $opt_index if defined $opt_index; $recurse = $opt_recurse if defined $opt_recurse; $title = $opt_title if defined $opt_title; + $header = defined $opt_header ? 1 : 0; + $css = $opt_css if defined $opt_css; $verbose = defined $opt_verbose ? 1 : 0; + $quiet = defined $opt_quiet ? 1 : 0; $netscape = $opt_netscape if defined $opt_netscape; } @@ -826,7 +871,7 @@ sub scan_headings { $index .= "\n" . ("\t" x $listdepth) . "<LI>" . "<A HREF=\"#" . htmlify(0,$title) . "\">" . - html_escape(process_text(\$title, 0)) . "</A>"; + html_escape(process_text(\$title, 0)) . "</A></LI>"; } } @@ -1489,7 +1534,7 @@ sub process_L { $link = "$htmlroot/$page.html"; $link .= "#" . htmlify(0,$section) if ($section); } elsif (!defined $pages{$page}) { - warn "$0: $podfile: cannot resolve L<$str> in paragraph $paragraph: no such page '$page'\n"; + warn "$0: $podfile: cannot resolve L<$str> in paragraph $paragraph: no such page '$page'\n" unless $quiet; $link = ""; $linktext = $page unless defined($linktext); } else { diff --git a/lib/integer.pm b/lib/integer.pm index 894931896f..f6be58a0eb 100644 --- a/lib/integer.pm +++ b/lib/integer.pm @@ -28,6 +28,17 @@ code you'll be left with C<$x == 1.5>, C<$y == 2> and C<$z == -1>. The $z case happens because unary C<-> counts as an operation. +Native integer arithmetic (as provided by your C compiler) is used. +This means that Perl's own semantics for arithmetic operations may +not be preserved. One common source of trouble is the modulus of +negative numbers, which Perl does one way, but your hardware may do +another. + + % perl -le 'print (4 % -3)' + -2 + % perl -Minteger -le 'print (4 % -3)' + 1 + See L<perlmod/Pragmatic Modules>. =cut diff --git a/lib/vars.pm b/lib/vars.pm index 334af9630a..ca2a08dcf6 100644 --- a/lib/vars.pm +++ b/lib/vars.pm @@ -14,7 +14,7 @@ sub import { my ($pack, @imports, $sym, $ch) = @_; foreach $sym (@imports) { ($ch, $sym) = unpack('a1a*', $sym); - if ($sym =~ tr/A-Za-Z_0-9//c) { + if ($sym =~ tr/A-Za-z_0-9//c) { # time for a more-detailed check-up if ($sym =~ /::/) { require Carp; @@ -1676,6 +1676,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) break; case '\020': /* ^P */ PL_perldb = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv); + if (PL_perldb && !PL_DBsingle) + init_debugger(); break; case '\024': /* ^T */ #ifdef BIG_TIME @@ -1147,6 +1147,10 @@ #define Perl_do_aexec pPerl->Perl_do_aexec #undef do_aexec #define do_aexec Perl_do_aexec +#undef Perl_do_aexec5 +#define Perl_do_aexec5 pPerl->Perl_do_aexec5 +#undef do_aexec5 +#define do_aexec5 Perl_do_aexec5 #undef Perl_do_binmode #define Perl_do_binmode pPerl->Perl_do_binmode #undef do_binmode @@ -1525,6 +1529,10 @@ #define Perl_ingroup pPerl->Perl_ingroup #undef ingroup #define ingroup Perl_ingroup +#undef Perl_init_debugger +#define Perl_init_debugger pPerl->Perl_init_debugger +#undef init_debugger +#define init_debugger Perl_init_debugger #undef Perl_init_stacks #define Perl_init_stacks pPerl->Perl_init_stacks #undef init_stacks @@ -5548,6 +5548,8 @@ Perl_ck_subr(pTHX_ OP *o) case '$': if (o2->op_type != OP_RV2SV && o2->op_type != OP_PADSV + && o2->op_type != OP_HELEM + && o2->op_type != OP_AELEM && o2->op_type != OP_THREADSV) { bad_type(arg, "scalar", gv_ename(namegv), o2); @@ -2478,23 +2478,26 @@ S_forbid_setid(pTHX_ char *s) Perl_croak(aTHX_ "No %s allowed while running setgid", s); } -STATIC void -S_init_debugger(pTHX) +void +Perl_init_debugger(pTHX) { dTHR; + HV *ostash = PL_curstash; + PL_curstash = PL_debstash; PL_dbargs = GvAV(gv_AVadd((gv_fetchpv("args", GV_ADDMULTI, SVt_PVAV)))); AvREAL_off(PL_dbargs); PL_DBgv = gv_fetchpv("DB", GV_ADDMULTI, SVt_PVGV); PL_DBline = gv_fetchpv("dbline", GV_ADDMULTI, SVt_PVAV); PL_DBsub = gv_HVadd(gv_fetchpv("sub", GV_ADDMULTI, SVt_PVHV)); + sv_upgrade(GvSV(PL_DBsub), SVt_IV); /* IVX accessed if PERLDB_SUB_NN */ PL_DBsingle = GvSV((gv_fetchpv("single", GV_ADDMULTI, SVt_PV))); sv_setiv(PL_DBsingle, 0); PL_DBtrace = GvSV((gv_fetchpv("trace", GV_ADDMULTI, SVt_PV))); sv_setiv(PL_DBtrace, 0); PL_DBsignal = GvSV((gv_fetchpv("signal", GV_ADDMULTI, SVt_PV))); sv_setiv(PL_DBsignal, 0); - PL_curstash = PL_defstash; + PL_curstash = ostash; } #ifndef STRESS_REALLOC @@ -682,6 +682,13 @@ Perl_do_aexec(pTHXo_ SV* really, SV** mark, SV** sp) return ((CPerlObj*)pPerl)->Perl_do_aexec(really, mark, sp); } +#undef Perl_do_aexec5 +bool +Perl_do_aexec5(pTHXo_ SV* really, SV** mark, SV** sp, int fd, int flag) +{ + return ((CPerlObj*)pPerl)->Perl_do_aexec5(really, mark, sp, fd, flag); +} + #undef Perl_do_binmode int Perl_do_binmode(pTHXo_ PerlIO *fp, int iotype, int flag) @@ -1342,6 +1349,13 @@ Perl_ingroup(pTHXo_ I32 testgid, I32 effective) return ((CPerlObj*)pPerl)->Perl_ingroup(testgid, effective); } +#undef Perl_init_debugger +void +Perl_init_debugger(pTHXo) +{ + ((CPerlObj*)pPerl)->Perl_init_debugger(); +} + #undef Perl_init_stacks void Perl_init_stacks(pTHXo) @@ -1623,8 +1623,7 @@ break; case 23: #line 179 "perly.y" { PL_copline = yyvsp[-5].ival; - yyval.opval = newSTATEOP(0, Nullch, - newCONDOP(0, yyvsp[-3].opval, scope(yyvsp[-1].opval), yyvsp[0].opval)); + yyval.opval = newCONDOP(0, yyvsp[-3].opval, scope(yyvsp[-1].opval), yyvsp[0].opval); PL_hints |= HINT_BLOCK_SCOPE; } break; case 24: @@ -174,8 +174,7 @@ else : /* NULL */ { $$ = scope($2); } | ELSIF '(' mexpr ')' mblock else { PL_copline = $1; - $$ = newSTATEOP(0, Nullch, - newCONDOP(0, $3, scope($5), $6)); + $$ = newCONDOP(0, $3, scope($5), $6); PL_hints |= HINT_BLOCK_SCOPE; } ; diff --git a/pod/Win32.pod b/pod/Win32.pod index a0bf040b74..dfc78bda5a 100644 --- a/pod/Win32.pod +++ b/pod/Win32.pod @@ -121,7 +121,7 @@ convert 8.3 components in the supplied FILENAME to longnames or vice-versa. Compare with Win32::GetShortPathName and Win32::GetLongPathName. -This function has been added for Perl 5.006. +This function has been added for Perl 5.6. =item Win32::GetLastError() @@ -137,7 +137,7 @@ than PATHNAME. No attempt is made to convert PATHNAME to the absolute path. Compare with Win32::GetShortPathName and Win32::GetFullPathName. -This function has been added for Perl 5.006. +This function has been added for Perl 5.6. =item Win32::GetNextAvailDrive() @@ -259,7 +259,7 @@ such a feature is not available under Windows 95. [CORE] Sets the value of the last error encountered to ERROR. This is that value that will be returned by the Win32::GetLastError() -function. This functions has been added for Perl 5.006. +function. This functions has been added for Perl 5.6. =item Win32::Sleep(TIME) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 0a33e3d5b5..dc697e6929 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -1,6 +1,6 @@ =head1 NAME -perldelta - what's new for perl5.006 (as of 5.005_56) +perldelta - what's new for perl v5.6 (as of v5.5.58) =head1 DESCRIPTION @@ -19,7 +19,7 @@ None known at this time. =item C<PERL_POLLUTE> Release 5.005 grandfathered old global symbol names by providing preprocessor -macros for extension source compatibility. As of release 5.006, these +macros for extension source compatibility. As of release 5.6, these preprocessor definitions are not available by default. You need to explicitly compile perl with C<-DPERL_POLLUTE> to get these definitions. For extensions still using the old symbols, this option can be @@ -40,7 +40,7 @@ be called in programs that used Perl's malloc. Previous versions of Perl have allowed this behaviour to be suppressed with the HIDEMYMALLOC and EMBEDMYMALLOC preprocessor definitions. -As of release 5.006, Perl's malloc family of functions have default names +As of release 5.6, Perl's malloc family of functions have default names distinct from the system versions. You need to explicitly compile perl with C<-DPERL_POLLUTE_MALLOC> to get the older behaviour. HIDEMYMALLOC and EMBEDMYMALLOC have no effect, since the behaviour they enabled is now diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 9b3ebb198f..96031a54e6 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -317,6 +317,12 @@ could indicate that SvREFCNT_dec() was called too many times, or that SvREFCNT_inc() was called too few times, or that the SV was mortalized when it shouldn't have been, or that memory has been corrupted. +=item Attempt to join self + +(F) You tried to join a thread from within itself, which is an +impossible task. You may be joining the wrong thread, or you may +need to move the join() to some other thread. + =item Attempt to pack pointer to temporary value (W) You tried to pass a temporary value (like the result of a diff --git a/pod/perlfaq.pod b/pod/perlfaq.pod index 56cf3d71be..0d5dae8f5a 100644 --- a/pod/perlfaq.pod +++ b/pod/perlfaq.pod @@ -766,7 +766,7 @@ in respect of this information or its use. =item 23/May/99 -Extensive updates from the net in preparation for 5.006 release. +Extensive updates from the net in preparation for 5.6 release. =item 13/April/99 diff --git a/pod/perlfaq1.pod b/pod/perlfaq1.pod index 7566bf5cd0..a55d38dea7 100644 --- a/pod/perlfaq1.pod +++ b/pod/perlfaq1.pod @@ -36,8 +36,8 @@ In particular, the core development team (known as the Perl Porters) are a rag-tag band of highly altruistic individuals committed to producing better software for free than you could hope to purchase for money. You may snoop on pending developments via -nntp://news.perl.com/perl.porters-gw/ and the Deja News archive at -http://www.dejanews.com/ using the perl.porters-gw newsgroup, or you can +nntp://news.perl.com/perl.porters-gw/ and the Deja archive at +http://www.deja.com/ using the perl.porters-gw newsgroup, or you can subscribe to the mailing list by sending perl5-porters-request@perl.org a subscription request. @@ -125,8 +125,8 @@ and the rare new keyword). No, Perl is easy to start learning -- and easy to keep learning. It looks like most programming languages you're likely to have experience -with, so if you've ever written an C program, an awk script, a shell -script, or even BASIC program, you're already part way there. +with, so if you've ever written a C program, an awk script, a shell +script, or even a BASIC program, you're already part way there. Most tasks only require a small subset of the Perl language. One of the guiding mottos for Perl development is "there's more than one way @@ -213,8 +213,8 @@ signify the language proper and "perl" the implementation of it, i.e. the current interpreter. Hence Tom's quip that "Nothing but perl can parse Perl." You may or may not choose to follow this usage. For example, parallelism means "awk and perl" and "Python and Perl" look -ok, while "awk and Perl" and "Python and perl" do not. But never -write "PERL", because perl isn't really an acronym, aprocryphal +OK, while "awk and Perl" and "Python and perl" do not. But never +write "PERL", because perl isn't really an acronym, apocryphal folklore and post-facto expansions notwithstanding. =head2 Is it a Perl program or a Perl script? @@ -223,7 +223,7 @@ Larry doesn't really care. He says (half in jest) that "a script is what you give the actors. A program is what you give the audience." Originally, a script was a canned sequence of normally interactive -commands, that is, a chat script. Something like a uucp or ppp chat +commands, that is, a chat script. Something like a UUCP or PPP chat script or an expect script fits the bill nicely, as do configuration scripts run by a program at its start up, such F<.cshrc> or F<.ircrc>, for example. Chat scripts were just drivers for existing programs, @@ -247,7 +247,7 @@ a definitive answer here. Now that "script" and "scripting" are terms that have been seized by unscrupulous or unknowing marketeers for their own nefarious purposes, they have begun to take on strange and often pejorative meanings, -like "non serious" or "not real programming". Consequently, some perl +like "non serious" or "not real programming". Consequently, some Perl programmers prefer to avoid them altogether. =head2 What is a JAPH? @@ -269,7 +269,7 @@ Newer examples can be found by perusing Larry's postings: =head2 How can I convince my sysadmin/supervisor/employees to use version (5/5.005/Perl instead of some other language)? If your manager or employees are wary of unsupported software, or -software which doesn't officially ship with your Operating System, you +software which doesn't officially ship with your operating system, you might try to appeal to their self-interest. If programmers can be more productive using and utilizing Perl constructs, functionality, simplicity, and power, then the typical manager/supervisor/employee @@ -295,21 +295,21 @@ by the Perl Development Team. Another big sell for Perl5 is the large number of modules and extensions which greatly reduce development time for any given task. Also mention that the difference between version 4 and version 5 of Perl is like the difference between awk and C++. -(Well, ok, maybe not quite that distinct, but you get the idea.) If you +(Well, OK, maybe not quite that distinct, but you get the idea.) If you want support and a reasonable guarantee that what you're developing will continue to work in the future, then you have to run the supported version. That probably means running the 5.005 release, although 5.004 isn't that bad. Several important bugs were fixed from the 5.000 through 5.003 versions, though, so try upgrading past them if possible. -Of particular note is the massive bughunt for buffer overflow +Of particular note is the massive bug hunt for buffer overflow problems that went into the 5.004 release. All releases prior to that, including perl4, are considered insecure and should be upgraded as soon as possible. =head1 AUTHOR AND COPYRIGHT -Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington. +Copyright (c) 1997, 1998, 1999 Tom Christiansen and Nathan Torkington. All rights reserved. When included as an integrated part of the Standard Distribution @@ -317,7 +317,7 @@ of Perl or of its documentation (printed or otherwise), this works is covered under Perl's Artistic Licence. For separate distributions of all or part of this FAQ outside of that, see L<perlfaq>. -Irrespective of its distribution, all code examples here are public +Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would diff --git a/pod/perlfaq2.pod b/pod/perlfaq2.pod index 26865c7a83..d5bbb56fd3 100644 --- a/pod/perlfaq2.pod +++ b/pod/perlfaq2.pod @@ -17,7 +17,7 @@ in standard Internet format (a gzipped archive in POSIX tar format). Perl builds and runs on a bewildering number of platforms. Virtually all known and current Unix derivatives are supported (Perl's native -platform), as are proprietary systems like VMS, DOS, OS/2, Windows, +platform), as are other systems like VMS, DOS, OS/2, Windows, QNX, BeOS, and the Amiga. There are also the beginnings of support for MPE/iX. @@ -45,11 +45,12 @@ Some URLs that might help you are: http://www.perl.com/latest/ http://www.perl.com/CPAN/ports/ -Someone looking for a Perl for Win16 might look to LMOLNAR's djgpp +Someone looking for a Perl for Win16 might look to Laszlo Molnar's djgpp port in http://www.perl.com/CPAN/ports/msdos/ , which comes with clear installation instructions. A simple installation guide for MS-DOS using -IlyaZ's OS/2 port is available at http://www.cs.ruu.nl/~piet/perl5dos.html -and similarly for Windows 3.1 at http://www.cs.ruu.nl/~piet/perlwin3.html . +Ilya Zakharevich's OS/2 port is available at +http://www.cs.ruu.nl/%7Epiet/perl5dos.html +and similarly for Windows 3.1 at http://www.cs.ruu.nl/%7Epiet/perlwin3.html . =head2 I don't have a C compiler on my system. How can I compile perl? @@ -74,7 +75,7 @@ the hard-coded @INC which perl is looking for. If this command lists any paths which don't exist on your system, then you may need to move the appropriate libraries to these locations, or create -symlinks, aliases, or shortcuts appropriately. @INC is also printed as +symbolic links, aliases, or shortcuts appropriately. @INC is also printed as part of the output of % perl -V @@ -111,7 +112,7 @@ ftp://ftp.funet.fi/pub/languages/perl/CPAN/misc/japh . Considering that there are hundreds of existing modules in the archive, one probably exists to do nearly anything you can think of. -Current categories under CPAN/modules/by-category/ include perl core +Current categories under CPAN/modules/by-category/ include Perl core modules; development support; operating system interfaces; networking, devices, and interprocess communication; data type utilities; database interfaces; user interfaces; interfaces to other languages; filenames, @@ -127,13 +128,13 @@ Certainly not. Larry expects that he'll be certified before Perl is. =head2 Where can I get information on Perl? -The complete Perl documentation is available with the perl distribution. -If you have perl installed locally, you probably have the documentation +The complete Perl documentation is available with the Perl distribution. +If you have Perl installed locally, you probably have the documentation installed as well: type C<man perl> if you're on a system resembling Unix. This will lead you to other important man pages, including how to set your $MANPATH. If you're not on a Unix system, access to the documentation will be different; for example, it might be only in HTML format. But all -proper perl installations have fully-accessible documentation. +proper Perl installations have fully-accessible documentation. You might also try C<perldoc perl> in case your system doesn't have a proper man command, or it's been misinstalled. If that doesn't @@ -157,7 +158,7 @@ assistance: http://language.perl.com/info/documentation.html http://reference.perl.com/query.cgi?tutorials -=head2 What are the Perl newsgroups on USENET? Where do I post questions? +=head2 What are the Perl newsgroups on Usenet? Where do I post questions? The now defunct comp.lang.perl newsgroup has been superseded by the following groups: @@ -170,7 +171,7 @@ following groups: comp.infosystems.www.authoring.cgi Writing CGI scripts for the Web. -There is also USENET gateway to the mailing list used by the crack +There is also Usenet gateway to the mailing list used by the crack Perl development team (perl5-porters) at news://news.perl.com/perl.porters-gw/ . @@ -182,14 +183,15 @@ to alt.sources, please make sure it follows their posting standards, including setting the Followup-To header line to NOT include alt.sources; see their FAQ (http://www.faqs.org/faqs/alt-sources-intro/) for details. -If you're just looking for software, first use Alta Vista, Deja News, and +If you're just looking for software, first use AltaVista +(http://www.altavista.com), Deja (http://www.deja.com), and search CPAN. This is faster and more productive than just posting a request. =head2 Perl Books 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 +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. @@ -254,7 +256,10 @@ a star may be ordered from O'Reilly. by Larry Wall, Tom Christiansen, and Randal L. Schwartz *Perl 5 Desktop Reference - By Johan Vromans + by Johan Vromans + + *Perl in a Nutshell + by Ellen Siever, Stephan Spainhour, and Nathan Patwardhan =item Tutorials @@ -298,6 +303,9 @@ a star may be ordered from O'Reilly. How to Set up and Maintain a World Wide Web Site [2nd edition] by Lincoln Stein + *Learning Perl/Tk + by Nancy Walsh + =back =head2 Perl in Magazines @@ -322,7 +330,7 @@ http://www.stonehenge.com/merlyn/WebTechniques/. To get the best (and possibly cheapest) performance, pick a site from the list below and use it to grab the complete list of mirror sites. ->From there you can find the quickest site for you. Remember, the +From there you can find the quickest site for you. Remember, the following list is I<not> the complete list of CPAN mirrors. http://www.perl.com/CPAN-local @@ -332,9 +340,9 @@ following list is I<not> the complete list of CPAN mirrors. http://www.cs.ruu.nl/pub/PERL/CPAN/ ftp://ftp.cs.colorado.edu/pub/perl/CPAN/ -=head2 What mailing lists are there for perl? +=head2 What mailing lists are there for Perl? -Most of the major modules (tk, CGI, libwww-perl) have their own +Most of the major modules (Tk, CGI, libwww-perl) have their own mailing lists. Consult the documentation that came with the module for subscription information. The Perl Institute attempts to maintain a list of mailing lists at: @@ -343,10 +351,10 @@ list of mailing lists at: =head2 Archives of comp.lang.perl.misc -Have you tried Deja News or Alta Vista? Those are the +Have you tried Deja or AltaVista? Those are the best archives. Just look up "*perl*" as a newsgroup. - http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=terse&showsort=date&maxhits=25&subjects=&groups=*perl*&authors=&fromdate=&todate= + http://www.deja.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=terse&showsort=date&maxhits=25&subjects=&groups=*perl*&authors=&fromdate=&todate= You'll probably want to trim that down a bit, though. @@ -379,8 +387,8 @@ better for everyone. However, these answers may not suffice for managers who require a purchase order from a company whom they can sue should anything go awry. Or maybe they need very serious hand-holding and contractual obligations. -Shrink-wrapped CDs with perl on them are available from several sources if -that will help. For example, many perl books carry a perl distribution +Shrink-wrapped CDs with Perl on them are available from several sources if +that will help. For example, many Perl books carry a Perl distribution on them, as do the O'Reilly Perl Resource Kits (in both the Unix flavor and in the proprietary Microsoft flavor); the free Unix distributions also all come with Perl. @@ -417,7 +425,7 @@ See also www.perl.com for updates on tutorials, training, and support. =head2 Where do I send bug reports? If you are reporting a bug in the perl interpreter or the modules -shipped with perl, use the I<perlbug> program in the perl distribution or +shipped with Perl, use the I<perlbug> program in the Perl distribution or mail your report to perlbug@perl.com . If you are posting a bug with a non-standard port (see the answer to @@ -434,7 +442,7 @@ The perl.com domain is owned by Tom Christiansen, who created it as a public service long before perl.org came about. Despite the name, it's a pretty non-commercial site meant to be a clearinghouse for information about all things Perlian, accepting no paid advertisements, bouncy -happy gifs, or silly java applets on its pages. The Perl Home Page at +happy GIFs, or silly Java applets on its pages. The Perl Home Page at http://www.perl.com/ is currently hosted on a T3 line courtesy of Songline Systems, a software-oriented subsidiary of O'Reilly and Associates. Other starting points include @@ -453,7 +461,7 @@ of Perl or of its documentation (printed or otherwise), this works is covered under Perl's Artistic License. For separate distributions of all or part of this FAQ outside of that, see L<perlfaq>. -Irrespective of its distribution, all code examples here are public +Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would diff --git a/pod/perlfaq3.pod b/pod/perlfaq3.pod index 4e56a54a5d..d2e83be460 100644 --- a/pod/perlfaq3.pod +++ b/pod/perlfaq3.pod @@ -25,7 +25,7 @@ Have you read the appropriate man pages? Here's a brief index: Various http://www.perl.com/CPAN/doc/FMTEYEWTK/index.html (not a man-page but still useful) -L<perltoc> provides a crude table of contents for the perl man page set. +A crude table of contents for the Perl man page set is found in L<perltoc>. =head2 How can I use Perl interactively? @@ -41,8 +41,8 @@ operations typically found in symbolic debuggers. =head2 Is there a Perl shell? -In general, no. The Shell.pm module (distributed with perl) makes -perl try commands which aren't part of the Perl language as shell +In general, no. The Shell.pm module (distributed with Perl) makes +Perl try commands which aren't part of the Perl language as shell commands. perlsh from the source distribution is simplistic and uninteresting, but may still be what you want. @@ -144,7 +144,7 @@ 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. -The a2ps at http://www.infres.enst.fr/~demaille/a2ps/ does lots of things +The a2ps at http://www.infres.enst.fr/%7Edemaille/a2ps/ does lots of things related to generating nicely printed output of documents. =head2 Is there a ctags for Perl? @@ -180,7 +180,7 @@ your hard-earned cash on. PerlBuilder (XXX URL to follow) is an integrated development environment for Windows that supports Perl development. Perl programs are just plain text, though, so you could download emacs for Windows (???) or a vi clone -(vim) which runs on for win32 (http://www.cs.vu.nl/~tmgil/vi.html). +(vim) which runs on for win32 (http://www.cs.vu.nl/%7Etmgil/vi.html). If you're transferring Windows files to Unix, be sure to transfer in ASCII mode so the ends of lines are appropriately mangled. @@ -195,10 +195,10 @@ with an embedded Perl interpreter -- see http://www.perl.com/CPAN/src/misc. =head2 Where can I get perl-mode for emacs? Since Emacs version 19 patchlevel 22 or so, there have been both a -perl-mode.el and support for the perl debugger built in. These should +perl-mode.el and support for the Perl debugger built in. These should come with the standard Emacs 19 distribution. -In the perl source directory, you'll find a directory called "emacs", +In the Perl source directory, you'll find a directory called "emacs", which contains a cperl-mode that color-codes keywords, provides context-sensitive help, and other nifty things. @@ -223,11 +223,11 @@ to the Athena Widget set. Both are available from CPAN. See the directory http://www.perl.com/CPAN/modules/by-category/08_User_Interfaces/ Invaluable for Perl/Tk programming are: the Perl/Tk FAQ at -http://w4.lns.cornell.edu/~pvhp/ptk/ptkTOC.html , the Perl/Tk Reference +http://w4.lns.cornell.edu/%7Epvhp/ptk/ptkTOC.html , the Perl/Tk Reference Guide available at http://www.perl.com/CPAN-local/authors/Stephen_O_Lidie/ , and the online manpages at -http://www-users.cs.umn.edu/~amundson/perl/perltk/toc.html . +http://www-users.cs.umn.edu/%7Eamundson/perl/perltk/toc.html . =head2 How can I generate simple menus without using CGI or Tk? @@ -272,9 +272,9 @@ it. See the F<INSTALL> file in the source distribution for more information. Unsubstantiated reports allege that Perl interpreters that use sfio -outperform those that don't (for IO intensive applications). To try +outperform those that don't (for I/O intensive applications). To try this, see the F<INSTALL> file in the source distribution, especially -the ``Selecting File IO mechanisms'' section. +the ``Selecting File I/O mechanisms'' section. The undump program was an old attempt to speed up your Perl program by storing the already-compiled form to disk. This is no longer @@ -369,11 +369,11 @@ anything a module written in C can. For more on mod_perl, see http://perl.apache.org/ With the FCGI module (from CPAN) and the mod_fastcgi -module (available from http://www.fastcgi.com/) each of your perl -scripts becomes a permanent CGI daemon process. +module (available from http://www.fastcgi.com/) each of your Perl +programs becomes a permanent 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 +and on the way you write your CGI programs, so investigate them with care. See http://www.perl.com/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/ . @@ -381,9 +381,9 @@ See http://www.perl.com/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI A non-free, commercial product, ``The Velocity Engine for Perl'', (http://www.binevolve.com/ or http://www.binevolve.com/bine/vep) might also be worth looking at. It will allow you to increase the performance -of your perl scripts, upto 25 times faster than normal CGI perl by -running in persistent perl mode, or 4 to 5 times faster without any -modification to your existing CGI scripts. Fully functional evaluation +of your Perl programs, up to 25 times faster than normal CGI Perl by +running in persistent Perl mode, or 4 to 5 times faster without any +modification to your existing CGI programs. Fully functional evaluation copies are available from the web site. =head2 How can I hide the source for my Perl program? @@ -445,7 +445,7 @@ just as big as the original perl executable, and then some. That's because as currently written, all programs are prepared for a full eval() statement. You can tremendously reduce this cost by building a shared I<libperl.so> library and linking against that. See the -F<INSTALL> podfile in the perl source distribution for details. If +F<INSTALL> podfile in the Perl source distribution for details. If you link your main perl binary with this, it will make it minuscule. For example, on one author's system, F</usr/bin/perl> is only 11k in size! @@ -465,7 +465,7 @@ Perl install anyway. You can't. Not yet, anyway. You can integrate Java and Perl with the Perl Resource Kit from O'Reilly and Associates. See http://www.oreilly.com/catalog/prkunix/ for more information. -The Java interface will be supported in the core 5.006 release +The Java interface will be supported in the core 5.6 release of Perl. =head2 How can I get C<#!perl> to work on [MS-DOS,NT,...]? @@ -488,15 +488,15 @@ the Registry yourself. In addition to associating C<.pl> with the interpreter, NT people can use: C<SET PATHEXT=%PATHEXT%;.PL> to let them run the program C<install-linux.pl> merely by typing C<install-linux>. -Macintosh perl scripts will have the appropriate Creator and -Type, so that double-clicking them will invoke the perl application. +Macintosh Perl programs will have the appropriate Creator and +Type, so that double-clicking them will invoke the Perl application. I<IMPORTANT!>: Whatever you do, PLEASE don't get frustrated, and just throw the perl interpreter into your cgi-bin directory, in order to -get your scripts working for a web server. This is an EXTREMELY big +get your programs working for a web server. This is an EXTREMELY big security risk. Take the time to figure out how to do it correctly. -=head2 Can I write useful perl programs on the command line? +=head2 Can I write useful Perl programs on the command line? Yes. Read L<perlrun> for more information. Some examples follow. (These assume standard Unix shell quoting rules.) @@ -520,9 +520,9 @@ Yes. Read L<perlrun> for more information. Some examples follow. echo $PATH | perl -nl -072 -e ' s![^/+]*$!man!&&-d&&!$s{$_}++&&push@m,$_;END{print"@m"}' -Ok, the last one was actually an obfuscated perl entry. :-) +OK, the last one was actually an Obfuscated Perl Contest entry. :-) -=head2 Why don't perl one-liners work on my DOS/Mac/VMS system? +=head2 Why don't Perl one-liners work on my DOS/Mac/VMS system? The problem is usually that the command interpreters on those systems have rather different ideas about quoting than the Unix shells under @@ -598,7 +598,7 @@ when it runs fine on the command line'', see these sources: =head2 Where can I learn about object-oriented Perl programming? -L<perltoot> is a good place to start, and you can use L<perlobj> and +A good place to start is L<perltoot>, and you can use L<perlobj> and L<perlbot> for reference. Perltoot didn't come out until the 5.004 release, but you can get a copy (in pod, html, or postscript) from http://www.perl.com/CPAN/doc/FMTEYEWTK/ . @@ -617,15 +617,15 @@ my C program, what am I doing wrong? Download the ExtUtils::Embed kit from CPAN and run `make test'. If the tests pass, read the pods again and again and again. If they -fail, see L<perlbug> and send a bugreport with the output of +fail, see L<perlbug> and send a bug report with the output of C<make test TEST_VERBOSE=1> along with C<perl -V>. =head2 When I tried to run my script, I got this message. What does it mean? -L<perldiag> has a complete list of perl's error messages and warnings, -with explanatory text. You can also use the splain program (distributed -with perl) to explain the error messages: +A complete list of Perl's error messages and warnings with explanatory +text can be found in L<perldiag>. You can also use the splain program +(distributed with Perl) to explain the error messages: perl program 2>diag.out splain [-v] [-p] diag.out @@ -640,7 +640,7 @@ or =head2 What's MakeMaker? -This module (part of the standard perl distribution) is designed to +This module (part of the standard Perl distribution) is designed to write a Makefile for an extension module from a Makefile.PL. For more information, see L<ExtUtils::MakeMaker>. @@ -654,7 +654,7 @@ of Perl or of its documentation (printed or otherwise), this works is covered under Perl's Artistic License. For separate distributions of all or part of this FAQ outside of that, see L<perlfaq>. -Irrespective of its distribution, all code examples here are public +Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would diff --git a/pod/perlfaq4.pod b/pod/perlfaq4.pod index 700c42abf8..63e093fe0e 100644 --- a/pod/perlfaq4.pod +++ b/pod/perlfaq4.pod @@ -31,7 +31,7 @@ representation is converted back to decimal. These decimal numbers are displayed in either the format you specify with printf(), or the current output format for numbers (see L<perlvar/"$#"> if you use print. C<$#> has a different default value in Perl5 than it did in -Perl4. Changing C<$#> yourself is deprecated. +Perl4. Changing C<$#> yourself is deprecated.) This affects B<all> computer languages that represent decimal floating-point numbers in binary, not just Perl. Perl provides @@ -67,7 +67,7 @@ route. printf("%.3f", 3.1415926535); # prints 3.142 -The POSIX module (part of the standard perl distribution) implements +The POSIX module (part of the standard Perl distribution) implements ceil(), floor(), and a number of other mathematical and trigonometric functions. @@ -76,7 +76,7 @@ functions. $floor = floor(3.5); # 3 In 5.000 to 5.003 Perls, trigonometry was done in the Math::Complex -module. With 5.004, the Math::Trig module (part of the standard perl +module. With 5.004, the Math::Trig module (part of the standard Perl distribution) implements the trigonometric functions. Internally it uses the Math::Complex module and some functions can break out from the real axis into the complex plane, for example the inverse sine of @@ -105,12 +105,12 @@ are not guaranteed. To turn a string of 1s and 0s like C<10110110> into a scalar containing its binary value, use the pack() and unpack() functions (documented in -L<perlfunc/"pack" L<perlfunc/"unpack">): +L<perlfunc/"pack"> and L<perlfunc/"unpack">): $decimal = unpack('c', pack('B8', '10110110')); This packs the string C<10110110> into an eight bit binary structure. -This is then unpack as a character, which returns its ordinal value. +This is then unpacked as a character, which returns its ordinal value. This does the same thing: @@ -183,6 +183,15 @@ ranges. Instead use: push(@results, some_func($i)); } +This situation has been fixed in Perl5.005. Use of C<..> in a C<for> +loop will iterate over the range, without creating the entire range. + + for my $i (5 .. 500_005) { + push(@results, some_func($i)); + } + +will not create a list of 500,000 integers. + =head2 How can I output Roman numerals? Get the http://www.perl.com/CPAN/modules/by-module/Roman module. @@ -333,7 +342,7 @@ A solution to this issue is offered by Russ Allbery. # # The explicit settings of $ndst and $tdst are necessary because localtime # only says it returns the system tm struct, and the system tm struct at - # least on Solaris doesn't guarantee any particuliar positive value (like, + # least on Solaris doesn't guarantee any particular positive value (like, # say, 1) for isdst, just a positive value. And that value can # potentially be negative, if DST information isn't available (this sub # just treats those cases like no DST). @@ -350,7 +359,7 @@ A solution to this issue is offered by Russ Allbery. # Copyright relinquished 1999 by Russ Allbery <rra@stanford.edu> # This code is in the public domain -=head2 Does Perl have a year 2000 problem? Is Perl Y2K compliant? +=head2 Does Perl have a Year 2000 problem? Is Perl Y2K compliant? Short answer: No, Perl does not have a Year 2000 problem. Yes, Perl is Y2K compliant (whatever that means). The programmers you've hired to @@ -361,7 +370,7 @@ Perl is just as Y2K compliant as your pencil--no more, and no less. Can you use your pencil to write a non-Y2K-compliant memo? Of course you can. Is that the pencil's fault? Of course it isn't. -The date and time functions supplied with perl (gmtime and localtime) +The date and time functions supplied with Perl (gmtime and localtime) supply adequate information to determine the year well beyond 2000 (2038 is when trouble strikes for 32-bit machines). The year returned by these functions when used in an array context is the year minus 1900. @@ -441,7 +450,7 @@ If you are serious about writing a parser, there are a number of modules or oddities that will make your life a lot easier. There is the CPAN module Parse::RecDescent, the standard module Text::Balanced, the byacc program, the CPAN module Parse::Yapp, and Mark-Jason -Dominus's excellent I<py> tool at http://www.plover.com/~mjd/perl/py/ +Dominus's excellent I<py> tool at http://www.plover.com/%7Emjd/perl/py/ . One simple destructive, inside-out approach that you might try is to @@ -479,7 +488,7 @@ You can do it yourself: 1 while $string =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e; -Or you can just use the Text::Tabs module (part of the standard perl +Or you can just use the Text::Tabs module (part of the standard Perl distribution). use Text::Tabs; @@ -487,7 +496,7 @@ distribution). =head2 How do I reformat a paragraph? -Use Text::Wrap (part of the standard perl distribution): +Use Text::Wrap (part of the standard Perl distribution): use Text::Wrap; print wrap("\t", ' ', @paragraphs); @@ -570,8 +579,8 @@ To make the first letter of each word upper case: $line =~ s/\b(\w)/\U$1/g; This has the strange effect of turning "C<don't do it>" into "C<Don'T -Do It>". Sometimes you might want this, instead (Suggested by Brian -Foy): +Do It>". Sometimes you might want this, instead (Suggested by brian d. +foy): $string =~ s/ ( (^\w) #at the beginning of the line @@ -627,7 +636,7 @@ quotation-mark-delimited field, escape them with backslashes (eg, C<"like \"this\"">. Unescaping them is a task addressed earlier in this section. -Alternatively, the Text::ParseWords module (part of the standard perl +Alternatively, the Text::ParseWords module (part of the standard Perl distribution) lets you say: use Text::ParseWords; @@ -735,7 +744,7 @@ you can use this kind of thing: =head2 How do I find the soundex value of a string? -Use the standard Text::Soundex module distributed with perl. +Use the standard Text::Soundex module distributed with Perl. But before you do so, you may want to determine whether `soundex' is in fact what you think it is. Knuth's soundex algorithm compresses words into a small space, and so it does not necessarily distinguish between @@ -952,7 +961,7 @@ ordered and whether you wish to preserve the ordering. This is nice in that it doesn't use much extra memory, simulating uniq(1)'s behavior of removing only adjacent duplicates. It's less nice in that it won't work with false values like undef, 0, or ""; -"0 but true" is ok, though. +"0 but true" is OK, though. =item b) If you don't know whether @in is sorted: @@ -973,7 +982,7 @@ nice in that it won't work with false values like undef, 0, or ""; undef @ary; @ary[@in] = @in; - @out = @ary; + @out = grep {defined} @ary; =back @@ -1121,7 +1130,7 @@ Now C<$found_index> has what you want. In general, you usually don't need a linked list in Perl, since with regular arrays, you can push and pop or shift and unshift at either end, or you can use splice to add and/or remove arbitrary number of elements at -arbitrary points. Both pop and shift are both O(1) operations on perl's +arbitrary points. Both pop and shift are both O(1) operations on Perl's dynamic arrays. In the absence of shifts and pops, push in general needs to reallocate on the order every log(N) times, and unshift will need to copy pointers each time. @@ -1427,10 +1436,10 @@ sorting the keys as shown in an earlier question. Don't do that. :-) [lwall] In Perl 4, you were not allowed to modify a hash at all while -interating over it. In Perl 5 you can delete from it, but you still +iterating over it. In Perl 5 you can delete from it, but you still can't add to it, because that might cause a doubling of the hash table, in which half the entries get copied up to the new top half of the -table, at which point you've totally bamboozled the interator code. +table, at which point you've totally bamboozled the iterator code. Even if the table doesn't double, there's no telling whether your new entry will be inserted before or after the current iterator position. @@ -1527,7 +1536,7 @@ And these conditions hold $ary{'d'} is false defined $ary{'d'} is true defined $ary{'a'} is true - exists $ary{'a'} is true (perl5 only) + exists $ary{'a'} is true (Perl5 only) grep ($_ eq 'a', keys %ary) is true If you now say @@ -1551,7 +1560,7 @@ and these conditions now hold; changes in caps: $ary{'d'} is false defined $ary{'d'} is true defined $ary{'a'} is FALSE - exists $ary{'a'} is true (perl5 only) + exists $ary{'a'} is true (Perl5 only) grep ($_ eq 'a', keys %ary) is true Notice the last two: you have an undef value, but a defined key! @@ -1575,7 +1584,7 @@ and these conditions now hold; changes in caps: $ary{'d'} is false defined $ary{'d'} is true defined $ary{'a'} is false - exists $ary{'a'} is FALSE (perl5 only) + exists $ary{'a'} is FALSE (Perl5 only) grep ($_ eq 'a', keys %ary) is FALSE See, the whole entry is gone! @@ -1651,7 +1660,7 @@ whether you store something there or not. That's because functions get scalars passed in by reference. If somefunc() modifies C<$_[0]>, it has to be ready to write it back into the caller's version. -This has been fixed as of perl5.004. +This has been fixed as of Perl5.004. Normally, merely accessing a key's value for a nonexistent key does I<not> cause that key to be forever there. This is different than @@ -1678,7 +1687,7 @@ in L<perltoot>. =head2 How can I use a reference as a hash key? You can't do this directly, but you could use the standard Tie::Refhash -module distributed with perl. +module distributed with Perl. =head1 Data: Misc diff --git a/pod/perlfaq5.pod b/pod/perlfaq5.pod index 1e8252bfa6..3869ff3c5e 100644 --- a/pod/perlfaq5.pod +++ b/pod/perlfaq5.pod @@ -554,7 +554,7 @@ be an atomic operation over NFS. That is, two processes might both successful create or unlink the same file! Therefore O_EXCL isn't so exclusive as you might wish. -See also the new L<perlopentut> if you have it (new for 5.006). +See also the new L<perlopentut> if you have it (new for 5.6). =head2 Why do I sometimes get an "Argument list too long" when I use E<lt>*E<gt>? @@ -606,7 +606,7 @@ It would be a lot clearer to use sysopen(), though: or die "can't open $badpath: $!"; For more information, see also the new L<perlopentut> if you have it -(new for 5.006). +(new for 5.6). =head2 How can I reliably rename a file? @@ -672,7 +672,7 @@ Slavish adherence to portability concerns shouldn't get in the way of your getting your job done.) For more information on file locking, see also L<perlopentut/"File -Locking"> if you have it (new for 5.006). +Locking"> if you have it (new for 5.6). =back @@ -855,11 +855,10 @@ you'd get a list of all the lines: @lines = `cat $file`; -This tiny but expedient solution is neat, clean, and portable to all -systems that you've bothered to install decent tools on, even if you are -a Prisoner of Bill. For those die-hards PoBs who've paid their billtax -and refuse to use the toolbox, or who like writing complicated code for -job security, you can of course read the file manually. +This tiny but expedient solution is neat, clean, and portable to +all systems on which decent tools have been installed. For those +who prefer not to use the toolbox, you can of course read the file +manually, although this makes for more complicated code. { local(*INPUT, $/); @@ -1208,7 +1207,7 @@ of Perl or of its documentation (printed or otherwise), this works is covered under Perl's Artistic License. For separate distributions of all or part of this FAQ outside of that, see L<perlfaq>. -Irrespective of its distribution, all code examples here are public +Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index ddf64d07bb..3e791810db 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1435,7 +1435,7 @@ defined C<END> routines first, but these C<END> routines may not themselves abort the exit. Likewise any object destructors that need to be called are called before the real exit. If this is a problem, you can call C<POSIX:_exit($status)> to avoid END and destructor processing. -See L<perlsub> for details. +See L<perlmod> for details. =item exp EXPR @@ -2118,7 +2118,8 @@ See also C<each>, C<values> and C<sort>. Sends a signal to a list of processes. The first element of the list must be the signal to send. Returns the number of -processes successfully signaled. +processes successfully signaled (which is not necessarily the +same as the number actually killed). $cnt = kill 1, $child1, $child2; kill 9, @goners; @@ -4200,29 +4201,38 @@ a NAME, it's an anonymous function declaration, and does actually return a value: the CODE ref of the closure you just created. See L<perlsub> and L<perlref> for details. -=item substr EXPR,OFFSET,LEN,REPLACEMENT +=item substr EXPR,OFFSET,LENGTH,REPLACEMENT -=item substr EXPR,OFFSET,LEN +=item substr EXPR,OFFSET,LENGTH =item substr EXPR,OFFSET Extracts a substring out of EXPR and returns it. First character is at offset C<0>, or whatever you've set C<$[> to (but don't do that). If OFFSET is negative (or more precisely, less than C<$[>), starts -that far from the end of the string. If LEN is omitted, returns -everything to the end of the string. If LEN is negative, leaves that +that far from the end of the string. If LENGTH is omitted, returns +everything to the end of the string. If LENGTH is negative, leaves that many characters off the end of the string. -If you specify a substring that is partly outside the string, the part -within the string is returned. If the substring is totally outside -the string a warning is produced. - You can use the substr() function as an lvalue, in which case EXPR -must itself be an lvalue. If you assign something shorter than LEN, -the string will shrink, and if you assign something longer than LEN, +must itself be an lvalue. If you assign something shorter than LENGTH, +the string will shrink, and if you assign something longer than LENGTH, the string will grow to accommodate it. To keep the string the same length you may need to pad or chop your value using C<sprintf>. +If OFFSET and LENGTH specify a substring that is partly outside the +string, only the part within the string is returned. If the substring +is beyond either end of the string, substr() returns the undefined +value and produces a warning. When used as an lvalue, specifying a +substring that is entirely outside the string is a fatal error. +Here's an example showing the behavior for boundary cases: + + my $name = 'fred'; + substr($name, 4) = 'dy'; # $name is now 'freddy' + my $null = substr $name, 6, 2; # returns '' (no warning) + my $oops = substr $name, 7; # returns undef, with warning + substr($name, 7) = 'gap'; # fatal error + An alternative to using substr() as an lvalue is to specify the replacement string as the 4th argument. This allows you to replace parts of the EXPR and return what was there before in one operation, @@ -4368,7 +4378,8 @@ The return value is the exit status of the program as returned by the C<wait> call. To get the actual exit value divide by 256. See also L</exec>. This is I<not> what you want to use to capture the output from a command, for that you should use merely backticks or -C<qx//>, as described in L<perlop/"`STRING`">. +C<qx//>, as described in L<perlop/"`STRING`">. Return value of -1 +indicates a failure to start the program (inspect $! for the reason). Like C<exec>, C<system> allows you to lie to a program about its name if you use the C<system PROGRAM LIST> syntax. Again, see L</exec>. diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 2c6d3a2e75..f297560b19 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -366,9 +366,9 @@ The hash algorithm is defined in the C<PERL_HASH(hash, key, klen)> macro: hash = 0; while (klen--) hash = (hash * 33) + *key++; - hash = hash + (hash >> 5); /* after 5.006 */ + hash = hash + (hash >> 5); /* after 5.6 */ -The last step was added in version 5.006 to improve distribution of +The last step was added in version 5.6 to improve distribution of lower bits in the resulting hash value. See L<Understanding the Magic of Tied Hashes and Arrays> for more diff --git a/pod/perlhist.pod b/pod/perlhist.pod index 7ba44291c8..ec6f3f2fab 100644 --- a/pod/perlhist.pod +++ b/pod/perlhist.pod @@ -314,7 +314,7 @@ the strings?). 5.005_03-MT5 1999-Jan-28 5.005_03 1999-Mar-28 - Sarathy 5.005_50 1998-Jul-26 The 5.006 development track. + Sarathy 5.005_50 1998-Jul-26 The 5.6 development track. 5.005_51 1998-Aug-10 5.005_52 1998-Sep-25 5.005_53 1998-Oct-31 diff --git a/pod/perlop.pod b/pod/perlop.pod index 0f8117ced9..3234131f90 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -620,9 +620,7 @@ function as operators, providing various kinds of interpolating and pattern matching capabilities. Perl provides customary quote characters for these behaviors, but also provides a way for you to choose your quote character for any of them. In the following table, a C<{}> represents -any pair of delimiters you choose. Non-bracketing delimiters use -the same character fore and aft, but the 4 sorts of brackets -(round, angle, square, curly) will all nest. +any pair of delimiters you choose. Customary Generic Meaning Interpolates '' q{} Literal no @@ -634,6 +632,23 @@ the same character fore and aft, but the 4 sorts of brackets s{}{} Substitution yes (unless '' is delimiter) tr{}{} Transliteration no (but see below) +Non-bracketing delimiters use the same character fore and aft, but the four +sorts of brackets (round, angle, square, curly) will all nest, which means +that + + q{foo{bar}baz} + +is the same as + + 'foo{bar}baz' + +Note, however, that this does not always work for quoting Perl code: + + $s = q{ if($a eq "}") ... }; # WRONG + +is a syntax error. The C<Text::Balanced> module on CPAN is able to do this +properly. + There can be whitespace between the operator and the quoting characters, except when C<#> is being used as the quoting character. C<q#foo#> is parsed as the string C<foo>, while C<q #foo#> is the diff --git a/pod/perlport.pod b/pod/perlport.pod index 7c73cd25a8..6837b4c549 100644 --- a/pod/perlport.pod +++ b/pod/perlport.pod @@ -705,7 +705,7 @@ may run a slightly modified version of MacPerl, using the Carbon interfaces. S<Mac OS X Server> and its Open Source version, Darwin, both run Unix perl natively (with a few patches). Full support for these -is slated for perl5.006. +is slated for perl 5.6. Also see: diff --git a/pod/perltodo.pod b/pod/perltodo.pod index 5962fc8f16..4b2ed48a09 100644 --- a/pod/perltodo.pod +++ b/pod/perltodo.pod @@ -714,7 +714,7 @@ criticized for being of questionable value. =head2 Making my() work on "package" variables Being able to say my($Foo::Bar), something that sounds ludicrous and -the 5.006 pumpking has mocked. +the 5.6 pumpking has mocked. =head2 "or" testing defined not truth diff --git a/pod/perltoot.pod b/pod/perltoot.pod index c77a971b57..89e5cbe993 100644 --- a/pod/perltoot.pod +++ b/pod/perltoot.pod @@ -329,7 +329,7 @@ do more than fetch or set one particular field. sub exclaim { my $self = shift; return sprintf "Hi, I'm %s, age %d, working with %s", - $self->{NAME}, $self->{AGE}, join(", ", $self->{PEERS}); + $self->{NAME}, $self->{AGE}, join(", ", @{$self->{PEERS}}); } Or maybe even one like this: diff --git a/pod/perltootc.pod b/pod/perltootc.pod index f7157e83aa..85ae6fba03 100644 --- a/pod/perltootc.pod +++ b/pod/perltootc.pod @@ -111,12 +111,12 @@ hard-coded in so many places. Both these problems can be easily fixed. Just add the C<use strict> pragma, then pre-declare your package variables. (The C<our> operator -will be new in 5.006, and will work for package globals just like C<my> +will be new in 5.6, and will work for package globals just like C<my> works for scoped lexicals.) package Some_Class; use strict; - our($CData1, $CData2); # our() is new to perl5.006 + our($CData1, $CData2); # our() is new to perl5.6 sub CData1 { shift; # XXX: ignore calling class/object $CData1 = shift if @_; @@ -148,7 +148,7 @@ Here's what to do. First, make just one hash to hold all class attributes. package Some_Class; use strict; - our %ClassData = ( # our() is new to perl5.006 + our %ClassData = ( # our() is new to perl5.6 CData1 => "", CData2 => "", ); @@ -287,7 +287,7 @@ used to implement the class. use strict; # create class meta-object using that most perfect of names - our %Some_Class = ( # our() is new to perl5.006 + our %Some_Class = ( # our() is new to perl5.6 CData1 => "", CData2 => "", ); @@ -339,7 +339,7 @@ class the object belongs to. package Some_Class; use strict; - our %Some_Class = ( # our() is new to perl5.006 + our %Some_Class = ( # our() is new to perl5.6 CData1 => "", CData2 => "", ); @@ -373,7 +373,7 @@ L<perlbot>, but there may be variations in the example below that you haven't thought of before. package Some_Class; - our($CData1, $CData2); # our() is new to perl5.006 + our($CData1, $CData2); # our() is new to perl5.6 sub new { my $obclass = shift; @@ -424,7 +424,7 @@ proper package's data. package Some_Class; use strict; - our %Some_Class = ( # our() is new to perl5.006 + our %Some_Class = ( # our() is new to perl5.6 CData1 => "", CData2 => "", ); @@ -738,7 +738,7 @@ these attributes similar to the way process attributes like environment variables, user and group IDs, or the current working directory are treated across a fork(). You can change only yourself, but you will see those changes reflected in your unspawned children. Changes to one object -will propagate enither up to the parent nor down to any existing child objects. +will propagate neither up to the parent nor down to any existing child objects. Those objects made later, however, will see the changes. If you have an object with an actual attribute value, and you want to @@ -757,7 +757,7 @@ Here's a complete implementation of Vermin as described above. # so the latter can be used for both initialization # and translucency. - our %Vermin = ( # our() is new to perl5.006 + our %Vermin = ( # our() is new to perl5.6 PopCount => 0, # capital for class attributes color => "beige", # small for instance attributes ); @@ -1125,7 +1125,7 @@ Here's one way: No one--absolutely no one--is allowed to read or write the class attributes without the mediation of the managing accessor method, since only that method has access to the lexical variable it's managing. -This use of mediated access to class attributes is a form privacy far +This use of mediated access to class attributes is a form of privacy far stronger than most OO languages provide. The repetition of code used to create per-datum accessor methods chafes @@ -1157,8 +1157,8 @@ the &UNIVERSAL::can method and SUPER as shown previously. =head2 Translucency Revisited -The Vermin class used to demonstrate translucency used an eponymously -named package variable, %Vermin, as its meta-object. If you prefer to +The Vermin class demonstrates translucency using a package variable, +eponymously named %Vermin, as its meta-object. If you prefer to use absolutely no package variables beyond those necessary to appease inheritance or possibly the Exporter, this strategy is closed to you. That's too bad, because translucent attributes are an appealing @@ -1287,7 +1287,7 @@ better approach. We use the hypothetical our() syntax for package variables. It works like C<use vars>, but looks like my(). It should be in this summer's -major release (5.006) of perl--we hope. +major release (5.6) of perl--we hope. You can't use file-scoped lexicals in conjunction with the SelfLoader or the AutoLoader, because they alter the lexical scope in which the diff --git a/pod/perlvar.pod b/pod/perlvar.pod index c13c41742b..3a38f553c6 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -45,9 +45,7 @@ you try to assign to this variable, either directly or indirectly through a reference, you'll raise a run-time exception. The following list is ordered by scalar variables first, then the -arrays, then the hashes (except $^M was added in the wrong place). -This is somewhat obscured because %ENV and %SIG are listed as -$ENV{expr} and $SIG{expr}. +arrays, then the hashes. =over 8 @@ -868,7 +866,7 @@ The hash %INC contains entries for each filename included via the C<do>, C<require>, or C<use> operators. The key is the filename you specified (with module names converted to pathnames), and the value is the location of the file found. The C<require> -operator uses this array to determine whether a particular file has +operator uses this hash to determine whether a particular file has already been included. =item %ENV @@ -1047,7 +1045,7 @@ C<W>) is the scalar variable whose name is the single character control-C<W>. This is better than typing a literal control-C<W> into your program. -Finally, new in Perl 5.006, Perl variable names may be alphanumeric +Finally, new in Perl 5.6, Perl variable names may be alphanumeric strings that begin with control characters (or better yet, a caret). These variables must be written in the form C<${^Foo}>; the braces are not optional. C<${^Foo}> denotes the scalar variable whose @@ -39,8 +39,13 @@ static I32 amagic_ncmp(pTHXo_ SV *a, SV *b); static I32 amagic_i_ncmp(pTHXo_ SV *a, SV *b); static I32 amagic_cmp(pTHXo_ SV *a, SV *b); static I32 amagic_cmp_locale(pTHXo_ SV *a, SV *b); +#ifdef PERL_OBJECT static I32 sv_cmp_static(pTHXo_ SV *a, SV *b); static I32 sv_cmp_locale_static(pTHXo_ SV *a, SV *b); +#else +#define sv_cmp_static Perl_sv_cmp +#define sv_cmp_locale_static Perl_sv_cmp_locale +#endif PP(pp_wantarray) { @@ -1911,29 +1916,32 @@ S_dofindlabel(pTHX_ OP *o, char *label, OP **opstack, OP **oplimit) *ops++ = cUNOPo->op_first; if (ops >= oplimit) Perl_croak(aTHX_ too_deep); + *ops = 0; } - *ops = 0; if (o->op_flags & OPf_KIDS) { dTHR; /* First try all the kids at this level, since that's likeliest. */ for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) { - if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) && - kCOP->cop_label && strEQ(kCOP->cop_label, label)) + if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) + && kCOP->cop_label && strEQ(kCOP->cop_label, label)) + { return kid; + } } for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) { if (kid == PL_lastgotoprobe) continue; - if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) && - (ops == opstack || - (ops[-1]->op_type != OP_NEXTSTATE && - ops[-1]->op_type != OP_DBSTATE))) + if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) + && (ops == opstack || (ops[-1]->op_type != OP_NEXTSTATE + && ops[-1]->op_type != OP_DBSTATE))) + { *ops++ = kid; + *ops = 0; + } if (o = dofindlabel(kid, label, ops, oplimit)) return o; } } - *ops = 0; return 0; } @@ -4090,6 +4098,8 @@ amagic_cmp_locale(pTHXo_ register SV *str1, register SV *str2) return sv_cmp_locale(str1, str2); } +#ifdef PERL_OBJECT + static I32 sv_cmp_locale_static(pTHXo_ register SV *str1, register SV *str2) { @@ -4101,3 +4111,5 @@ sv_cmp_static(pTHXo_ register SV *str1, register SV *str2) { return sv_cmp(str1, str2); } + +#endif /* PERL_OBJECT */ @@ -3577,6 +3577,8 @@ PP(pp_system) int status; Sigsave_t ihand,qhand; /* place to save signals during system() */ STRLEN n_a; + I32 did_pipes = 0; + int pp[2]; if (SP - MARK == 1) { if (PL_tainting) { @@ -3587,16 +3589,24 @@ PP(pp_system) } PERL_FLUSHALL_FOR_CHILD; #if (defined(HAS_FORK) || defined(AMIGAOS)) && !defined(VMS) && !defined(OS2) + if (PerlProc_pipe(pp) >= 0) + did_pipes = 1; while ((childpid = vfork()) == -1) { if (errno != EAGAIN) { value = -1; SP = ORIGMARK; PUSHi(value); + if (did_pipes) { + PerlLIO_close(pp[0]); + PerlLIO_close(pp[1]); + } RETURN; } sleep(5); } if (childpid > 0) { + if (did_pipes) + PerlLIO_close(pp[1]); rsignal_save(SIGINT, SIG_IGN, &ihand); rsignal_save(SIGQUIT, SIG_IGN, &qhand); do { @@ -3607,17 +3617,43 @@ PP(pp_system) STATUS_NATIVE_SET(result == -1 ? -1 : status); do_execfree(); /* free any memory child malloced on vfork */ SP = ORIGMARK; + if (did_pipes) { + int errkid; + int n = 0, n1; + + while (n < sizeof(int)) { + n1 = PerlLIO_read(pp[0], + (void*)(((char*)&errkid)+n), + (sizeof(int)) - n); + if (n1 <= 0) + break; + n += n1; + } + PerlLIO_close(pp[0]); + if (n) { /* Error */ + if (n != sizeof(int)) + Perl_croak(aTHX_ "panic: kid popen errno read"); + errno = errkid; /* Propagate errno from kid */ + STATUS_CURRENT = -1; + } + } PUSHi(STATUS_CURRENT); RETURN; } + if (did_pipes) { + PerlLIO_close(pp[0]); +#if defined(HAS_FCNTL) && defined(F_SETFD) + fcntl(pp[1], F_SETFD, FD_CLOEXEC); +#endif + } if (PL_op->op_flags & OPf_STACKED) { SV *really = *++MARK; - value = (I32)do_aexec(really, MARK, SP); + value = (I32)do_aexec5(really, MARK, SP, pp[1], did_pipes); } else if (SP - MARK != 1) - value = (I32)do_aexec(Nullsv, MARK, SP); + value = (I32)do_aexec5(Nullsv, MARK, SP, pp[1], did_pipes); else { - value = (I32)do_exec(SvPVx(sv_mortalcopy(*SP), n_a)); + value = (I32)do_exec3(SvPVx(sv_mortalcopy(*SP), n_a), pp[1], did_pipes); } PerlProc__exit(-1); #else /* ! FORK or VMS or OS/2 */ @@ -95,6 +95,7 @@ VIRTUAL OP* Perl_vdie(pTHX_ const char* pat, va_list* args); VIRTUAL OP* Perl_die_where(pTHX_ char* message, STRLEN msglen); VIRTUAL void Perl_dounwind(pTHX_ I32 cxix); VIRTUAL bool Perl_do_aexec(pTHX_ SV* really, SV** mark, SV** sp); +VIRTUAL bool Perl_do_aexec5(pTHX_ SV* really, SV** mark, SV** sp, int fd, int flag); VIRTUAL int Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int flag); VIRTUAL void Perl_do_chop(pTHX_ SV* asv, SV* sv); VIRTUAL bool Perl_do_close(pTHX_ GV* gv, bool not_implicit); @@ -197,6 +198,7 @@ VIRTUAL void Perl_hv_undef(pTHX_ HV* tb); VIRTUAL I32 Perl_ibcmp(pTHX_ const char* a, const char* b, I32 len); VIRTUAL I32 Perl_ibcmp_locale(pTHX_ const char* a, const char* b, I32 len); VIRTUAL I32 Perl_ingroup(pTHX_ I32 testgid, I32 effective); +VIRTUAL void Perl_init_debugger(pTHX); VIRTUAL void Perl_init_stacks(pTHX); VIRTUAL U32 Perl_intro_my(pTHX); VIRTUAL char* Perl_instr(pTHX_ const char* big, const char* little); @@ -790,7 +792,6 @@ STATIC void S_forbid_setid(pTHX_ char *); STATIC void S_incpush(pTHX_ char *, int); STATIC void S_init_interp(pTHX); STATIC void S_init_ids(pTHX); -STATIC void S_init_debugger(pTHX); STATIC void S_init_lexer(pTHX); STATIC void S_init_main_stash(pTHX); STATIC void S_init_perllib(pTHX); @@ -1107,17 +1107,10 @@ Perl_sv_2iv(pTHX_ register SV *sv) return SvIV(tmpstr); return (IV)SvRV(sv); } - if (SvREADONLY(sv)) { - if (SvNOKp(sv)) { - return I_V(SvNVX(sv)); - } - if (SvPOKp(sv) && SvLEN(sv)) - return asIV(sv); - { - dTHR; - if (ckWARN(WARN_UNINITIALIZED)) - Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit); - } + if (SvREADONLY(sv) && !SvOK(sv)) { + dTHR; + if (ckWARN(WARN_UNINITIALIZED)) + Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit); return 0; } } @@ -1252,17 +1245,10 @@ Perl_sv_2uv(pTHX_ register SV *sv) return SvUV(tmpstr); return (UV)SvRV(sv); } - if (SvREADONLY(sv)) { - if (SvNOKp(sv)) { - return U_V(SvNVX(sv)); - } - if (SvPOKp(sv) && SvLEN(sv)) - return asUV(sv); - { - dTHR; - if (ckWARN(WARN_UNINITIALIZED)) - Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit); - } + if (SvREADONLY(sv) && !SvOK(sv)) { + dTHR; + if (ckWARN(WARN_UNINITIALIZED)) + Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit); return 0; } } @@ -1423,19 +1409,8 @@ Perl_sv_2nv(pTHX_ register SV *sv) return SvNV(tmpstr); return (NV)(unsigned long)SvRV(sv); } - if (SvREADONLY(sv)) { + if (SvREADONLY(sv) && !SvOK(sv)) { dTHR; - if (SvPOKp(sv) && SvLEN(sv)) { - if (ckWARN(WARN_NUMERIC) && !SvIOKp(sv) && !looks_like_number(sv)) - not_a_number(sv); - return Atof(SvPVX(sv)); - } - if (SvIOKp(sv)) { - if (SvIsUV(sv)) - return (NV)SvUVX(sv); - else - return (NV)SvIVX(sv); - } if (ckWARN(WARN_UNINITIALIZED)) Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit); return 0.0; @@ -1817,29 +1792,10 @@ Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp) *lp = strlen(s); return s; } - if (SvREADONLY(sv)) { - if (SvNOKp(sv)) { /* See note in sv_2uv() */ - /* XXXX 64-bit? IV may have better precision... */ - Gconvert(SvNVX(sv), DBL_DIG, 0, tmpbuf); - tsv = Nullsv; - goto tokensave; - } - if (SvIOKp(sv)) { - char *ebuf; - - if (SvIsUV(sv)) - tmpbuf = uiv_2buf(tbuf, 0, SvUVX(sv), 1, &ebuf); - else - tmpbuf = uiv_2buf(tbuf, SvIVX(sv), 0, 0, &ebuf); - *ebuf = 0; - tsv = Nullsv; - goto tokensave; - } - { - dTHR; - if (ckWARN(WARN_UNINITIALIZED)) - Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit); - } + if (SvREADONLY(sv) && !SvOK(sv)) { + dTHR; + if (ckWARN(WARN_UNINITIALIZED)) + Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit); *lp = 0; return ""; } @@ -1872,30 +1828,36 @@ Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp) } else if (SvIOKp(sv)) { U32 isIOK = SvIOK(sv); + U32 isUIOK = SvIsUV(sv); char buf[TYPE_CHARS(UV)]; char *ebuf, *ptr; if (SvTYPE(sv) < SVt_PVIV) sv_upgrade(sv, SVt_PVIV); - if (SvIsUV(sv)) { + if (isUIOK) ptr = uiv_2buf(buf, 0, SvUVX(sv), 1, &ebuf); - sv_setpvn(sv, ptr, ebuf - ptr); - SvIsUV_on(sv); - } - else { + else ptr = uiv_2buf(buf, SvIVX(sv), 0, 0, &ebuf); - sv_setpvn(sv, ptr, ebuf - ptr); - } + SvGROW(sv, ebuf - ptr + 1); /* inlined from sv_setpvn */ + Move(ptr,SvPVX(sv),ebuf - ptr,char); + SvCUR_set(sv, ebuf - ptr); s = SvEND(sv); + *s = '\0'; if (isIOK) SvIOK_on(sv); else SvIOKp_on(sv); + if (isUIOK) + SvIsUV_on(sv); + SvPOK_on(sv); } else { dTHR; - if (ckWARN(WARN_UNINITIALIZED) && !PL_localizing && !(SvFLAGS(sv) & SVs_PADTMP)) + if (ckWARN(WARN_UNINITIALIZED) + && !PL_localizing && !(SvFLAGS(sv) & SVs_PADTMP)) + { Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit); + } *lp = 0; if (SvTYPE(sv) < SVt_PV) /* Typically the caller expects that sv_any is not NULL now. */ @@ -1905,7 +1867,8 @@ Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp) *lp = s - SvPVX(sv); SvCUR_set(sv, *lp); SvPOK_on(sv); - DEBUG_c(PerlIO_printf(Perl_debug_log, "0x%lx 2pv(%s)\n",(unsigned long)sv,SvPVX(sv))); + DEBUG_c(PerlIO_printf(Perl_debug_log, "0x%lx 2pv(%s)\n", + (unsigned long)sv,SvPVX(sv))); return SvPVX(sv); tokensave: diff --git a/t/comp/proto.t b/t/comp/proto.t index 6d60342b5f..ecfbec60da 100755 --- a/t/comp/proto.t +++ b/t/comp/proto.t @@ -16,7 +16,7 @@ BEGIN { use strict; -print "1..100\n"; +print "1..107\n"; my $i = 1; @@ -448,11 +448,21 @@ star2 $star, $star, sub { print "ok $i\n" star2($star, $star, sub { print "ok $i\n" if $_[0] eq 'FOO' and $_[1] eq 'FOO' }); $i++; star2 *FOO, *BAR, sub { print "ok $i\n" - if $_[0] eq \*FOO and $_[0] eq \*BAR }; $i++; + if $_[0] eq \*FOO and $_[1] eq \*BAR }; $i++; star2(*FOO, *BAR, sub { print "ok $i\n" - if $_[0] eq \*FOO and $_[0] eq \*BAR }); $i++; + if $_[0] eq \*FOO and $_[1] eq \*BAR }); $i++; star2 \*FOO, \*BAR, sub { no strict 'refs'; print "ok $i\n" - if $_[0] eq \*{'FOO'} and $_[0] eq \*{'BAR'} }; $i++; + if $_[0] eq \*{'FOO'} and $_[1] eq \*{'BAR'} }; $i++; star2(\*FOO, \*BAR, sub { no strict 'refs'; print "ok $i\n" - if $_[0] eq \*{'FOO'} and $_[0] eq \*{'BAR'} }); $i++; + if $_[0] eq \*{'FOO'} and $_[1] eq \*{'BAR'} }); $i++; +# test scalarref prototype +sub sreftest (\$$) { + print "ok $_[1]\n" if ref $_[0]; +} +{ + no strict 'vars'; + sreftest my $sref, $i++; + sreftest($helem{$i}, $i++); + sreftest $aelem[0], $i++; +} diff --git a/t/op/chars.t b/t/op/chars.t new file mode 100755 index 0000000000..efdea027bb --- /dev/null +++ b/t/op/chars.t @@ -0,0 +1,74 @@ +#!./perl + +print "1..33\n"; + +# because of ebcdic.c these should be the same on asciiish +# and ebcdic machines. +# Peter Prymmer <pvhp@best.com>. + +my $c = "\c@"; +print +((ord($c) == 0) ? "" : "not "),"ok 1\n"; +$c = "\cA"; +print +((ord($c) == 1) ? "" : "not "),"ok 2\n"; +$c = "\cB"; +print +((ord($c) == 2) ? "" : "not "),"ok 3\n"; +$c = "\cC"; +print +((ord($c) == 3) ? "" : "not "),"ok 4\n"; +$c = "\cD"; +print +((ord($c) == 4) ? "" : "not "),"ok 5\n"; +$c = "\cE"; +print +((ord($c) == 5) ? "" : "not "),"ok 6\n"; +$c = "\cF"; +print +((ord($c) == 6) ? "" : "not "),"ok 7\n"; +$c = "\cG"; +print +((ord($c) == 7) ? "" : "not "),"ok 8\n"; +$c = "\cH"; +print +((ord($c) == 8) ? "" : "not "),"ok 9\n"; +$c = "\cI"; +print +((ord($c) == 9) ? "" : "not "),"ok 10\n"; +$c = "\cJ"; +print +((ord($c) == 10) ? "" : "not "),"ok 11\n"; +$c = "\cK"; +print +((ord($c) == 11) ? "" : "not "),"ok 12\n"; +$c = "\cL"; +print +((ord($c) == 12) ? "" : "not "),"ok 13\n"; +$c = "\cM"; +print +((ord($c) == 13) ? "" : "not "),"ok 14\n"; +$c = "\cN"; +print +((ord($c) == 14) ? "" : "not "),"ok 15\n"; +$c = "\cO"; +print +((ord($c) == 15) ? "" : "not "),"ok 16\n"; +$c = "\cP"; +print +((ord($c) == 16) ? "" : "not "),"ok 17\n"; +$c = "\cQ"; +print +((ord($c) == 17) ? "" : "not "),"ok 18\n"; +$c = "\cR"; +print +((ord($c) == 18) ? "" : "not "),"ok 19\n"; +$c = "\cS"; +print +((ord($c) == 19) ? "" : "not "),"ok 20\n"; +$c = "\cT"; +print +((ord($c) == 20) ? "" : "not "),"ok 21\n"; +$c = "\cU"; +print +((ord($c) == 21) ? "" : "not "),"ok 22\n"; +$c = "\cV"; +print +((ord($c) == 22) ? "" : "not "),"ok 23\n"; +$c = "\cW"; +print +((ord($c) == 23) ? "" : "not "),"ok 24\n"; +$c = "\cX"; +print +((ord($c) == 24) ? "" : "not "),"ok 25\n"; +$c = "\cY"; +print +((ord($c) == 25) ? "" : "not "),"ok 26\n"; +$c = "\cZ"; +print +((ord($c) == 26) ? "" : "not "),"ok 27\n"; +$c = "\c["; +print +((ord($c) == 27) ? "" : "not "),"ok 28\n"; +$c = "\c\\"; +print +((ord($c) == 28) ? "" : "not "),"ok 29\n"; +$c = "\c]"; +print +((ord($c) == 29) ? "" : "not "),"ok 30\n"; +$c = "\c^"; +print +((ord($c) == 30) ? "" : "not "),"ok 31\n"; +$c = "\c_"; +print +((ord($c) == 31) ? "" : "not "),"ok 32\n"; +$c = "\c?"; +print +((ord($c) == 127) ? "" : "not "),"ok 33\n"; diff --git a/t/op/exec.t b/t/op/exec.t index 5cf7386c93..99af53b29d 100755 --- a/t/op/exec.t +++ b/t/op/exec.t @@ -25,7 +25,9 @@ if (system "true") {print "not ok 4\n";} else {print "ok 4\n";} if ((system "/bin/sh -c 'exit 1'") != 256) { print "not "; } print "ok 5\n"; -if ((system "lskdfj") == 255 << 8) {print "ok 6\n";} else {print "not ok 6\n";} +$rc = system "lskdfj"; +if ($rc == 255 << 8 or $rc == -1 and ($! == 2 or $! =~ /\bno\b.*\bfile/i)) + {print "ok 6\n";} else {print "not ok 6\n";} unless (exec "lskdjfalksdjfdjfkls") {print "ok 7\n";} else {print "not ok 7\n";} diff --git a/t/op/goto.t b/t/op/goto.t index 8096aff0f2..7a5de5fea5 100755 --- a/t/op/goto.t +++ b/t/op/goto.t @@ -2,7 +2,7 @@ # "This IS structured code. It's just randomly structured." -print "1..13\n"; +print "1..16\n"; while ($?) { $foo = 1; @@ -55,6 +55,27 @@ exit; FINALE: print "ok 13\n"; + +# does goto LABEL handle block contexts correctly? + +my $cond = 1; +for (1) { + if ($cond == 1) { + $cond = 0; + goto OTHER; + } + elsif ($cond == 0) { + OTHER: + $cond = 2; + print "ok 14\n"; + goto THIRD; + } + else { + THIRD: + print "ok 15\n"; + } +} +print "ok 16\n"; exit; bypass: diff --git a/t/op/ord.t b/t/op/ord.t index ba943f4e8c..bc6d924554 100755 --- a/t/op/ord.t +++ b/t/op/ord.t @@ -1,7 +1,5 @@ #!./perl -# $RCSfile: ord.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:09 $ - print "1..3\n"; # compile time evaluation diff --git a/t/op/tie.t b/t/op/tie.t index daec685d8d..49f07d4d2d 100755 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -166,3 +166,15 @@ sub Self::DESTROY { $b = $_[0] + 0; } } die unless $a == $b; EXPECT +######## +# Interaction of tie and vec + +my ($a, $b); +use Tie::Scalar; +tie $a,Tie::StdScalar or die; +vec($b,1,1)=1; +$a = $b; +vec($a,1,1)=0; +vec($b,1,1)=0; +die unless $a eq $b; +EXPECT @@ -187,10 +187,8 @@ PERLVARI(Tregfree, regfree_t, MEMBER_TO_FPTR(Perl_pregfree)) PERLVARI(Treginterp_cnt,int, 0) /* Whether `Regexp' was interpolated. */ PERLVARI(Treg_starttry, char *, 0) /* -Dr: where regtry was called. */ -#ifdef DEBUGGING PERLVARI(Twatchaddr, char **, 0) PERLVAR(Twatchok, char *) -#endif /* Note that the variables below are all explicitly referenced in the code * as thr->whatever and therefore don't need the 'T' prefix. */ @@ -1416,6 +1416,9 @@ Perl_mess(pTHX_ const char *pat, va_list *args) line_mode ? "line" : "chunk", (long)IoLINES(GvIOp(PL_last_in_gv))); } +#ifdef USE_THREADS + sv_catpvf(sv, " thread %ld", thr->tid); +#endif sv_catpv(sv, PL_dirty ? dgd : ".\n"); } return sv; @@ -2304,10 +2307,11 @@ Perl_my_popen(pTHX_ char *cmd, char *mode) break; n += n1; } + PerlLIO_close(pp[0]); + did_pipes = 0; if (n) { /* Error */ if (n != sizeof(int)) Perl_croak(aTHX_ "panic: kid popen errno read"); - PerlLIO_close(pp[0]); errno = errkid; /* Propagate errno from kid */ return Nullfp; } diff --git a/win32/bin/pl2bat.pl b/win32/bin/pl2bat.pl index 2fa8088500..f33b46c3df 100644 --- a/win32/bin/pl2bat.pl +++ b/win32/bin/pl2bat.pl @@ -64,7 +64,7 @@ EOT } $head =~ s/^\t//gm; my $headlines = 2 + ($head =~ tr/\n/\n/); -my $tail = "__END__\n:endofperl\n"; +my $tail = "\n__END__\n:endofperl\n"; @ARGV = ('-') unless @ARGV; diff --git a/x2p/find2perl.PL b/x2p/find2perl.PL index cbb32fdb65..da94dc9eab 100644 --- a/x2p/find2perl.PL +++ b/x2p/find2perl.PL @@ -29,544 +29,586 @@ print OUT <<"!GROK!THIS!"; $Config{startperl} eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' if \$running_under_some_shell; -\$startperl = "$Config{startperl}"; -\$perlpath = "$Config{perlpath}"; +my \$perlpath = "$Config{perlpath}"; !GROK!THIS! # In the following, perl variables are not expanded during extraction. print OUT <<'!NO!SUBS!'; +use strict; +use vars qw/$statdone/; +my $startperl = "#! $perlpath -w"; -# +# # Modified September 26, 1993 to provide proper handling of years after 1999 # Tom Link <tml+@pitt.edu> # University of Pittsburgh -# +# # Modified April 7, 1998 with nasty hacks to implement the troublesome -follow # Billy Constantine <wdconsta@cs.adelaide.edu.au> <billy@smug.adelaide.edu.au> # University of Adelaide, Adelaide, South Australia -# +# +# Modified 1999-06-10, 1999-07-07 to migrate to cleaner perl5 usage +# Ken Pizzini <ken@halcyon.com> +my @roots = (); while ($ARGV[0] =~ /^[^-!(]/) { push(@roots, shift); } @roots = ('.') unless @roots; -for (@roots) { $_ = "e($_); } -$roots = join(',', @roots); - -$indent = 1; -$stat = 'lstat'; -$decl = ''; +for (@roots) { $_ = "e($_) } +my $roots = join(', ', @roots); + +my $find = "find"; +my $indent_depth = 1; +my $stat = 'lstat'; +my $decl = ''; +my $flushall = ''; +my $initfile = ''; +my $initnewer = ''; +my $out = ''; +my %init = (); while (@ARGV) { $_ = shift; s/^-// || /^[()!]/ || die "Unrecognized switch: $_\n"; if ($_ eq '(') { - $out .= &tab . "(\n"; - $indent++; - next; - } - elsif ($_ eq ')') { - $indent--; - $out .= &tab . ")"; - } - elsif ($_ eq 'follow') { - $stat = 'stat'; - $decl = '%already_seen = ();'; - $out .= &tab . '(not $already_seen{"$dev,$ino"}) &&'; - $out .= "\n" . &tab . '(($already_seen{"$dev,$ino"} = !(-d _)) || 1)'; - } - elsif ($_ eq '!') { - $out .= &tab . "!"; - next; - } - elsif ($_ eq 'name') { - $out .= &tab; - $pat = &fileglob_to_re(shift); - $out .= '/' . $pat . "/"; - } - elsif ($_ eq 'perm') { - $onum = shift; - die "Malformed -perm argument: $onum\n" unless $onum =~ /^-?[0-7]+$/; - if ($onum =~ s/^-//) { - $onum = '0' . sprintf("%o", oct($onum) & 017777); # s/b 07777 ? - $out .= &tab . "((\$mode & $onum) == $onum)"; - } - else { - $onum = '0' . $onum unless $onum =~ /^0/; - $out .= &tab . "((\$mode & 0777) == $onum)"; - } - } - elsif ($_ eq 'type') { - ($filetest = shift) =~ tr/s/S/; - $out .= &tab . "-$filetest _"; - } - elsif ($_ eq 'print') { - $out .= &tab . 'print("$name\n")'; - } - elsif ($_ eq 'print0') { - $out .= &tab . 'print("$name\0")'; - } - elsif ($_ eq 'fstype') { - $out .= &tab; - $type = shift; - if ($type eq 'nfs') - { $out .= '($dev < 0)'; } - else - { $out .= '($dev >= 0)'; } - } - elsif ($_ eq 'user') { - $uname = shift; - $out .= &tab . "(\$uid == \$uid{'$uname'})"; - $inituser++; - } - elsif ($_ eq 'group') { - $gname = shift; - $out .= &tab . "(\$gid == \$gid{'$gname'})"; - $initgroup++; - } - elsif ($_ eq 'nouser') { - $out .= &tab . '!defined $uid{$uid}'; - $inituser++; - } - elsif ($_ eq 'nogroup') { - $out .= &tab . '!defined $gid{$gid}'; - $initgroup++; - } - elsif ($_ eq 'links') { - $out .= &tab . '($nlink ' . &n(shift); - } - elsif ($_ eq 'inum') { - $out .= &tab . '($ino ' . &n(shift); - } - elsif ($_ eq 'size') { - $_ = shift; - if (s/c$//) { - $out .= &tab . '(int(-s _) ' . &n($_); - } else { - $out .= &tab . '(int(((-s _) + 511) / 512) ' . &n($_); - } - } - elsif ($_ eq 'atime') { - $out .= &tab . '(int(-A _) ' . &n(shift); - } - elsif ($_ eq 'mtime') { - $out .= &tab . '(int(-M _) ' . &n(shift); - } - elsif ($_ eq 'ctime') { - $out .= &tab . '(int(-C _) ' . &n(shift); - } - elsif ($_ eq 'exec') { - for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { } - shift; - $_ = "@cmd"; - if (m#^(/bin/)?rm -f {}$#) { - if (!@ARGV) { - $out .= &tab . 'unlink($_)'; - } - else { - $out .= &tab . '(unlink($_) || 1)'; - } - } - elsif (m#^(/bin/)?rm {}$#) { - $out .= &tab . '(unlink($_) || warn "$name: $!\n")'; - } - else { - for (@cmd) { s/'/\\'/g; } - $" = "','"; - $out .= &tab . "&exec(0, '@cmd')"; - $" = ' '; - $initexec++; - } - } - elsif ($_ eq 'ok') { - for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { } - shift; - for (@cmd) { s/'/\\'/g; } - $" = "','"; - $out .= &tab . "&exec(1, '@cmd')"; - $" = ' '; - $initexec++; - } - elsif ($_ eq 'prune') { - $out .= &tab . '($prune = 1)'; - } - elsif ($_ eq 'xdev') { - $out .= &tab . '!($prune |= ($dev != $topdev))'; - } - elsif ($_ eq 'newer') { - $out .= &tab; - $file = shift; - $newername = 'AGE_OF' . $file; - $newername =~ s/[^\w]/_/g; - $newername = "\$$newername"; - $out .= "(-M _ < $newername)"; - $initnewer .= "$newername = -M " . "e($file) . ";\n"; - } - elsif ($_ eq 'eval') { - $prog = "e(shift); - $out .= &tab . "eval $prog"; - } - elsif ($_ eq 'depth') { - $depth++; - next; - } - elsif ($_ eq 'ls') { - $out .= &tab . "&ls"; - $initls++; - } - elsif ($_ eq 'tar') { - $out .= &tab; - die "-tar must have a filename argument\n" unless @ARGV; - $file = shift; - $fh = 'FH' . $file; - $fh =~ s/[^\w]/_/g; - $out .= "&tar($fh)"; - $file = '>' . $file; - $initfile .= "open($fh, " . "e($file) . - qq{) || die "Can't open $fh: \$!\\n";\n}; - $inittar++; - $flushall = "\n&tflushall;\n"; - } - elsif (/^n?cpio$/) { - $depth++; - $out .= &tab; - die "-$_ must have a filename argument\n" unless @ARGV; - $file = shift; - $fh = 'FH' . $file; - $fh =~ s/[^\w]/_/g; - $out .= "&cpio('" . substr($_,0,1) . "', $fh)"; - $file = '>' . $file; - $initfile .= "open($fh, " . "e($file) . - qq{) || die "Can't open $fh: \$!\\n";\n}; - $initcpio++; - $flushall = "\n&flushall;\n"; - } - else { - die "Unrecognized switch: -$_\n"; + $out .= &tab . "(\n"; + $indent_depth++; + next; + } elsif ($_ eq ')') { + --$indent_depth; + $out .= &tab . ")"; + } elsif ($_ eq 'follow') { + $stat = 'stat'; + $decl = "\nmy %already_seen = ();\n"; + $out .= &tab . '(not $already_seen{"$dev,$ino"}) &&' . "\n"; + $out .= &tab . '(($already_seen{"$dev,$ino"} = !(-d _)) || 1)'; + } elsif ($_ eq '!') { + $out .= &tab . "!"; + next; + } elsif ($_ eq 'name') { + $out .= &tab . '/' . &fileglob_to_re(shift) . "/"; + } elsif ($_ eq 'perm') { + my $onum = shift; + $onum =~ /^-?[0-7]+$/ + || die "Malformed -perm argument: $onum\n"; + $out .= &tab; + if ($onum =~ s/^-//) { + $onum = sprintf("0%o", oct($onum) & 07777); + $out .= "((\$mode & $onum) == $onum)"; + } else { + $onum =~ s/^0*/0/; + $out .= "((\$mode & 0777) == $onum)"; + } + } elsif ($_ eq 'type') { + (my $filetest = shift) =~ tr/s/S/; + $out .= &tab . "-$filetest _"; + } elsif ($_ eq 'print') { + $out .= &tab . 'print("$name\n")'; + } elsif ($_ eq 'print0') { + $out .= &tab . 'print("$name\0")'; + } elsif ($_ eq 'fstype') { + my $type = shift; + $out .= &tab; + if ($type eq 'nfs') { + $out .= '($dev < 0)'; + } else { + $out .= '($dev >= 0)'; #XXX + } + } elsif ($_ eq 'user') { + my $uname = shift; + $out .= &tab . "(\$uid == \$uid{'$uname'})"; + $init{user} = 1; + } elsif ($_ eq 'group') { + my $gname = shift; + $out .= &tab . "(\$gid == \$gid{'$gname'})"; + $init{group} = 1; + } elsif ($_ eq 'nouser') { + $out .= &tab . '!exists $uid{$uid}'; + $init{user} = 1; + } elsif ($_ eq 'nogroup') { + $out .= &tab . '!exists $gid{$gid}'; + $init{group} = 1; + } elsif ($_ eq 'links') { + $out .= &tab . &n('$nlink', shift); + } elsif ($_ eq 'inum') { + $out .= &tab . &n('$ino', shift); + } elsif ($_ eq 'size') { + $_ = shift; + my $n = 'int(((-s _) + 511) / 512)'; + if (s/c$//) { + $n = 'int(-s _)'; + } elsif (s/k$//) { + $n = 'int(((-s _) + 1023) / 1024)'; + } + $out .= &tab . &n($n, $_); + } elsif ($_ eq 'atime') { + $out .= &tab . &n('int(-A _)', shift); + } elsif ($_ eq 'mtime') { + $out .= &tab . &n('int(-M _)', shift); + } elsif ($_ eq 'ctime') { + $out .= &tab . &n('int(-C _)', shift); + } elsif ($_ eq 'exec') { + my @cmd = (); + while (@ARGV && $ARGV[0] ne ';') + { push(@cmd, shift) } + shift; + $out .= &tab; + if ($cmd[0] =~m#^(?:(?:/usr)?/bin/)?rm$# + && $cmd[$#cmd] eq '{}' + && (@cmd == 2 || (@cmd == 3 && $cmd[1] eq '-f'))) { + if (@cmd == 2) { + $out .= '(unlink($_) || warn "$name: $!\n")'; + } elsif (!@ARGV) { + $out .= 'unlink($_)'; + } else { + $out .= '(unlink($_) || 1)'; + } + } else { + for (@cmd) + { s/'/\\'/g } + { local $" = "','"; $out .= "&doexec(0, '@cmd')"; } + $init{doexec} = 1; + } + } elsif ($_ eq 'ok') { + my @cmd = (); + while (@ARGV && $ARGV[0] ne ';') + { push(@cmd, shift) } + shift; + $out .= &tab; + for (@cmd) + { s/'/\\'/g } + { local $" = "','"; $out .= "&doexec(0, '@cmd')"; } + $init{doexec} = 1; + } elsif ($_ eq 'prune') { + $out .= &tab . '($File::Find::prune = 1)'; + } elsif ($_ eq 'xdev') { + $out .= &tab . '!($File::Find::prune |= ($dev != $File::Find::topdev))' +; + } elsif ($_ eq 'newer') { + my $file = shift; + my $newername = 'AGE_OF' . $file; + $newername =~ s/\W/_/g; + $newername = '$' . $newername; + $out .= &tab . "(-M _ < $newername)"; + $initnewer .= "my $newername = -M " . "e($file) . ";\n"; + } elsif ($_ eq 'eval') { + my $prog = shift; + $prog =~ s/'/\\'/g; + $out .= &tab . "eval {$prog}"; + } elsif ($_ eq 'depth') { + $find = 'finddepth'; + next; + } elsif ($_ eq 'ls') { + $out .= &tab . "&ls"; + $init{ls} = 1; + } elsif ($_ eq 'tar') { + die "-tar must have a filename argument\n" unless @ARGV; + my $file = shift; + my $fh = 'FH' . $file; + $fh =~ s/\W/_/g; + $out .= &tab . "&tar(*$fh, \$name)"; + $flushall .= "&tflushall;\n"; + $initfile .= "open($fh, " . "e('> ' . $file) . + qq{) || die "Can't open $fh: \$!\\n";\n}; + $init{tar} = 1; + } elsif (/^(n?)cpio$/) { + die "-$_ must have a filename argument\n" unless @ARGV; + my $file = shift; + my $fh = 'FH' . $file; + $fh =~ s/\W/_/g; + $out .= &tab . "&cpio(*$fh, \$name, '$1')"; + $find = 'finddepth'; + $flushall .= "&cflushall;\n"; + $initfile .= "open($fh, " . "e('> ' . $file) . + qq{) || die "Can't open $fh: \$!\\n";\n}; + $init{cpio} = 1; + } else { + die "Unrecognized switch: -$_\n"; } + if (@ARGV) { - if ($ARGV[0] eq '-o') { - { local($statdone) = 1; $out .= "\n" . &tab . "||\n"; } - $statdone = 0 if $indent == 1 && $delayedstat; - $saw_or++; - shift; - } - else { - $out .= " &&" unless $ARGV[0] eq ')'; - $out .= "\n"; - shift if $ARGV[0] eq '-a'; - } + if ($ARGV[0] eq '-o') { + { local($statdone) = 1; $out .= "\n" . &tab . "||\n"; } + $statdone = 0 if $indent_depth == 1 && exists $init{delayedstat}; + $init{saw_or} = 1; + shift; + } else { + $out .= " &&" unless $ARGV[0] eq ')'; + $out .= "\n"; + shift if $ARGV[0] eq '-a'; + } } } + print <<"END"; $startperl eval 'exec $perlpath -S \$0 \${1+"\$@"}' - if \$running_under_some_shell; + if 0; #\$running_under_some_shell + +use strict; +use File::Find (); + +# Set the variable \$File::Find::dont_use_nlink if you're using AFS, +# since AFS cheats. + +# for the convenience of &wanted calls, including -eval statements: +use vars qw/*name *dir *prune/; +*name = *File::Find::name; +*dir = *File::Find::dir; +*prune = *File::Find::prune; END -if ($initls) { + +if (exists $init{ls}) { print <<'END'; -@rwx = ('---','--x','-w-','-wx','r--','r-x','rw-','rwx'); -@moname = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); +my @rwx = qw(--- --x -w- -wx r-- r-x rw- rwx); +my @moname = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); END } -if ($inituser || $initls) { - print 'while (($name, $pw, $uid) = getpwent) {', "\n"; - print ' $uid{$name} = $uid{$uid} = $uid;', "\n" if $inituser; - print ' $user{$uid} = $name unless $user{$uid};', "\n" if $initls; +if (exists $init{user} || exists $init{ls} || exists $init{tar}) { + print "my (%uid, %user);\n"; + print "while (my (\$name, \$pw, \$uid) = getpwent) {\n"; + print ' $uid{$name} = $uid{$uid} = $uid;', "\n" + if exists $init{user}; + print ' $user{$uid} = $name unless exists $user{$uid};', "\n" + if exists $init{ls} || exists $init{tar}; print "}\n\n"; } -if ($initgroup || $initls) { - print 'while (($name, $pw, $gid) = getgrent) {', "\n"; - print ' $gid{$name} = $gid{$gid} = $gid;', "\n" if $initgroup; - print ' $group{$gid} = $name unless $group{$gid};', "\n" if $initls; +if (exists $init{group} || exists $init{ls} || exists $init{tar}) { + print "my (%gid, %group);\n"; + print "while (my (\$name, \$pw, \$gid) = getgrent) {\n"; + print ' $gid{$name} = $gid{$gid} = $gid;', "\n" + if exists $init{group}; + print ' $group{$gid} = $name unless exists $group{$gid};', "\n" + if exists $init{ls} || exists $init{tar}; print "}\n\n"; } -print $initnewer, "\n" if $initnewer; +print $initnewer, "\n" if $initnewer ne ''; +print $initfile, "\n" if $initfile ne ''; +$flushall .= "exit;\n"; +if (exists $init{declarestat}) { + $out = <<'END' . $out; + my ($dev,$ino,$mode,$nlink,$uid,$gid); -print $initfile, "\n" if $initfile; +END +} -$find = $depth ? "finddepth" : "find"; print <<"END"; -require "$find.pl"; - -# Traverse desired filesystems - $decl -&$find($roots); +# Traverse desired filesystems +File::Find::$find(\\&wanted, $roots); $flushall -exit; + sub wanted { $out; } END -if ($initexec) { + +if (exists $init{doexec}) { print <<'END'; -sub exec { - local($ok, @cmd) = @_; - foreach $word (@cmd) { - $word =~ s#{}#$name#g; - } + +BEGIN { + require Cwd; + my $cwd = Cwd::cwd(); +} + +sub doexec { + my $ok = shift; + for my $word (@_) + { $word =~ s#{}#$name#g } if ($ok) { - local($old) = select(STDOUT); - $| = 1; - print "@cmd"; - select($old); - return 0 unless <STDIN> =~ /^y/; - } - chdir $cwd; # sigh - system @cmd; - chdir $dir; + my $old = select(STDOUT); + $| = 1; + print "@_"; + select($old); + return 0 unless <STDIN> =~ /^y/; + } + chdir $cwd; #sigh + system @_; + chdir $File::Find::dir; return !$?; } END } -if ($initls) { - print <<"INTERP", <<'END'; -sub ls { - (\$dev,\$ino,\$mode,\$nlink,\$uid,\$gid,\$rdev,\$sizemm, - \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat\(_\); -INTERP - - $pname = $name; +if (exists $init{ls}) { + print <<'INTRO', <<"SUB", <<'END'; - if (defined $blocks) { - $blocks = int(($blocks + 1) / 2); - } - else { - $blocks = int(($size + 1023) / 1024); - } +sub sizemm { + my $rdev = shift; + sprintf("%3d, %3d", ($rdev >> 8) & 0xff, $rdev & 0xff); +} - if (-f _) { $perms = '-'; } - elsif (-d _) { $perms = 'd'; } - elsif (-c _) { $perms = 'c'; $sizemm = &sizemm; } - elsif (-b _) { $perms = 'b'; $sizemm = &sizemm; } - elsif (-p _) { $perms = 'p'; } - elsif (-S _) { $perms = 's'; } - else { $perms = 'l'; $pname .= ' -> ' . readlink($_); } - - $tmpmode = $mode; - $tmp = $rwx[$tmpmode & 7]; - $tmpmode >>= 3; - $tmp = $rwx[$tmpmode & 7] . $tmp; - $tmpmode >>= 3; - $tmp = $rwx[$tmpmode & 7] . $tmp; - substr($tmp,2,1) =~ tr/-x/Ss/ if -u _; - substr($tmp,5,1) =~ tr/-x/Ss/ if -g _; - substr($tmp,8,1) =~ tr/-x/Tt/ if -k _; - $perms .= $tmp; - - $user = $user{$uid} || $uid; - $group = $group{$gid} || $gid; - - ($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime); - $moname = $moname[$mon]; +sub ls { + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, +INTRO + \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_); +SUB + my $pname = $name; + + $blocks + or $blocks = int(($size + 1023) / 1024); + + my $perms = $rwx[$mode & 7]; + $mode >>= 3; + $perms = $rwx[$mode & 7] . $perms; + $mode >>= 3; + $perms = $rwx[$mode & 7] . $perms; + substr($perms, 2, 1) =~ tr/-x/Ss/ if -u _; + substr($perms, 5, 1) =~ tr/-x/Ss/ if -g _; + substr($perms, 8, 1) =~ tr/-x/Tt/ if -k _; + if (-f _) { $perms = '-' . $perms; } + elsif (-d _) { $perms = 'd' . $perms; } + elsif (-l _) { $perms = 'l' . $perms; $pname .= ' -> ' . readlink($_); } + elsif (-c _) { $perms = 'c' . $perms; $size = sizemm($rdev); } + elsif (-b _) { $perms = 'b' . $perms; $size = sizemm($rdev); } + elsif (-p _) { $perms = 'p' . $perms; } + elsif (-S _) { $perms = 's' . $perms; } + else { $perms = '?' . $perms; } + + my $user = $user{$uid} || $uid; + my $group = $group{$gid} || $gid; + + my ($sec,$min,$hour,$mday,$mon,$timeyear) = localtime($mtime); if (-M _ > 365.25 / 2) { - $timeyear = $year + 1900; - } - else { - $timeyear = sprintf("%02d:%02d", $hour, $min); - } - - printf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n", - $ino, - $blocks, - $perms, - $nlink, - $user, - $group, - $sizemm, - $moname, - $mday, - $timeyear, - $pname; + $timeyear += 1900; + } else { + $timeyear = sprintf("%02d:%02d", $hour, $min); + } + + printf "%5lu %4ld %-10s %3d %-8s %-8s %8s %s %2d %5s %s\n", + $ino, + $blocks, + $perms, + $nlink, + $user, + $group, + $size, + $moname[$mon], + $mday, + $timeyear, + $pname; 1; } -sub sizemm { - sprintf("%3d, %3d", ($rdev >> 8) & 255, $rdev & 255); +END +} + + +if (exists $init{cpio} || exists $init{tar}) { +print <<'END'; + +my %blocks = (); + +sub flush { + my ($fh, $varref, $blksz) = @_; + + while (length($$varref) >= $blksz) { + no strict qw/refs/; + syswrite($fh, $$varref, $blksz); + substr($$varref, 0, $blksz) = ''; + ++$blocks{$fh}; + } } END } -if ($initcpio) { -print <<'START', <<"INTERP", <<'END'; -sub cpio { - local($nc,$fh) = @_; - local($text); - if ($name eq 'TRAILER!!!') { - $text = ''; - $size = 0; - } - else { -START - (\$dev,\$ino,\$mode,\$nlink,\$uid,\$gid,\$rdev,\$size, - \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat\(_\); -INTERP - if (-f _) { - open(IN, "./$_\0") || do { - warn "Couldn't open $name: $!\n"; - return; - }; - } - else { - $text = readlink($_); - $size = 0 unless defined $text; - } - } +if (exists $init{cpio}) { + print <<'INTRO', <<"SUB", <<'END'; + +my %cpout = (); +my %nc = (); - ($nm = $name) =~ s#^\./##; +sub cpio { + my ($fh, $fname, $nc) = @_; + my $text = ''; + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks); + local (*IN); + + if ( ! defined $fname ) { + $fname = 'TRAILER!!!'; + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) = (0) x 13; + } else { + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, +INTRO + \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_); +SUB + if (-f _) { + open(IN, "./$_\0") || do { + warn "Couldn't open $fname: $!\n"; + return; + } + } else { + $text = readlink($_); + $size = 0 unless defined $text; + } + } + + $fname =~ s#^\./##; $nc{$fh} = $nc; if ($nc eq 'n') { - $cpout{$fh} .= - sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0", - 070707, - $dev & 0777777, - $ino & 0777777, - $mode & 0777777, - $uid & 0777777, - $gid & 0777777, - $nlink & 0777777, - $rdev & 0177777, - $mtime, - length($nm)+1, - $size, - $nm); - } - else { - $cpout{$fh} .= "\0" if length($cpout{$fh}) & 1; - $cpout{$fh} .= pack("SSSSSSSSLSLa*", - 070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime, - length($nm)+1, $size, $nm . (length($nm) & 1 ? "\0" : "\0\0")); - } - if ($text ne '') { - $cpout{$fh} .= $text; - } - elsif ($size) { - &flush($fh) while ($l = length($cpout{$fh})) >= 5120; - while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) { - &flush($fh); - $l = length($cpout{$fh}); - } + $cpout{$fh} .= + sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0", + 070707, + $dev & 0777777, + $ino & 0777777, + $mode & 0777777, + $uid & 0777777, + $gid & 0777777, + $nlink & 0777777, + $rdev & 0177777, + $mtime, + length($fname)+1, + $size, + $fname); + } else { + $cpout{$fh} .= "\0" if length($cpout{$fh}) & 1; + $cpout{$fh} .= pack("SSSSSSSSLSLa*", + 070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime, + length($fname)+1, $size, + $fname . (length($fname) & 1 ? "\0" : "\0\0")); } - close IN; -} - -sub flush { - local($fh) = @_; - while (length($cpout{$fh}) >= 5120) { - syswrite($fh,$cpout{$fh},5120); - ++$blocks{$fh}; - substr($cpout{$fh}, 0, 5120) = ''; + if ($text ne '') { + $cpout{$fh} .= $text; + } elsif ($size) { + my $l; + flush($fh, \$cpout{$fh}, 5120) + while ($l = length($cpout{$fh})) >= 5120; + while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) { + flush($fh, \$cpout{$fh}, 5120); + $l = length($cpout{$fh}); + } + close IN; } } -sub flushall { - $name = 'TRAILER!!!'; - foreach $fh (keys %cpout) { - &cpio($nc{$fh},$fh); - $cpout{$fh} .= "0" x (5120 - length($cpout{$fh})); - &flush($fh); - print $blocks{$fh} * 10, " blocks\n"; +sub cflushall { + for my $fh (keys %cpout) { + &cpio($fh, undef, $nc{$fh}); + $cpout{$fh} .= "0" x (5120 - length($cpout{$fh})); + flush($fh, \$cpout{$fh}, 5120); + print $blocks{$fh} * 10, " blocks\n"; } } END } -if ($inittar) { -print <<'START', <<"INTERP", <<'END'; +if (exists $init{tar}) { + print <<'INTRO', <<"SUB", <<'END'; + +my %tarout = (); +my %linkseen = (); + sub tar { - local($fh) = @_; - local($linkname,$header,$l,$slop); - local($linkflag) = "\0"; - -START - (\$dev,\$ino,\$mode,\$nlink,\$uid,\$gid,\$rdev,\$size, - \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat\(_\); -INTERP - $nm = $name; - if ($nlink > 1) { - if ($linkname = $linkseen{$fh,$dev,$ino}) { - $linkflag = 1; - } - else { - $linkseen{$fh,$dev,$ino} = $nm; - } - } - if (-f _) { - open(IN, "./$_\0") || do { - warn "Couldn't open $name: $!\n"; - return; - }; - $size = 0 if $linkflag ne "\0"; - } - else { - $linkname = readlink($_); - $linkflag = 2 if defined $linkname; - $nm .= '/' if -d _; - $size = 0; - } + my ($fh, $fname) = @_; + my $prefix = ''; + my $typeflag = '0'; + my $linkname; + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, +INTRO + \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_); +SUB + local (*IN); - $header = pack("a100a8a8a8a12a12a8a1a100", - $nm, - sprintf("%6o ", $mode & 0777), - sprintf("%6o ", $uid & 0777777), - sprintf("%6o ", $gid & 0777777), - sprintf("%11o ", $size), - sprintf("%11o ", $mtime), - " ", - $linkflag, - $linkname); - $l = length($header) % 512; - substr($header, 148, 6) = sprintf("%6o", unpack("%16C*", $header)); - substr($header, 154, 1) = "\0"; # blech + if ($nlink > 1) { + if ($linkname = $linkseen{$fh, $dev, $ino}) { + if (length($linkname) > 100) { + warn "$0: omitting file with linkname ", + "too long for tar output: $linkname\n"; + return; + } + $typeflag = '1'; + $size = 0; + } else { + $linkseen{$fh, $dev, $ino} = $fname; + } + } + if ($typeflag eq '0') { + if (-f _) { + open(IN, "./$_\0") || do { + warn "Couldn't open $fname: $!\n"; + return; + } + } else { + $linkname = readlink($_); + if (defined $linkname) { $typeflag = '2' } + elsif (-c _) { $typeflag = '3' } + elsif (-b _) { $typeflag = '4' } + elsif (-d _) { $typeflag = '5' } + elsif (-p _) { $typeflag = '6' } + } + } + + if (length($fname) > 100) { + ($prefix, $fname) = ($fname =~ m#\A(.*?)/(.{,100})\Z(?!\n)#); + if (!defined($fname) || length($prefix) > 155) { + warn "$0: omitting file with name too long for tar output: ", + $fname, "\n"; + return; + } + } + + $size = 0 if $typeflag ne '0'; + my $header = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155", + $fname, + sprintf("%7o ", $mode & 0777), + sprintf("%7o ", $uid & 0777777), + sprintf("%7o ", $gid & 0777777), + sprintf("%11o ", $size), + sprintf("%11o ", $mtime), + ' 'x8, + $typeflag, + defined $linkname ? $linkname : '', + "ustar\0", + "00", + $user{$uid}, + $group{$gid}, + ($rdev >> 8) & 0xff, + $rdev & 0xff, + $prefix, + ); + substr($header, 148, 8) = sprintf("%7o ", unpack("%16C*", $header)); + my $l = length($header) % 512; $tarout{$fh} .= $header; $tarout{$fh} .= "\0" x (512 - $l) if $l; - if ($size) { - &tflush($fh) while ($l = length($tarout{$fh})) >= 10240; - while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) { - $slop = length($tarout{$fh}) % 512; - $tarout{$fh} .= "\0" x (512 - $slop) if $slop; - &tflush($fh); - $l = length($tarout{$fh}); - } - } - close IN; -} -sub tflush { - local($fh) = @_; - - while (length($tarout{$fh}) >= 10240) { - syswrite($fh,$tarout{$fh},10240); - ++$blocks{$fh}; - substr($tarout{$fh}, 0, 10240) = ''; + if ($size) { + flush($fh, \$tarout{$fh}, 10240) + while ($l = length($tarout{$fh})) >= 10240; + while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) { + my $slop = length($tarout{$fh}) % 512; + $tarout{$fh} .= "\0" x (512 - $slop) if $slop; + flush($fh, \$tarout{$fh}, 10240); + $l = length($tarout{$fh}); + } + close IN; } } sub tflushall { - local($len); - - foreach $fh (keys %tarout) { - $len = 10240 - length($tarout{$fh}); - $len += 10240 if $len < 1024; - $tarout{$fh} .= "\0" x $len; - &tflush($fh); + my $len; + for my $fh (keys %tarout) { + $len = 10240 - length($tarout{$fh}); + $len += 10240 if $len < 1024; + $tarout{$fh} .= "\0" x $len; + flush($fh, \$tarout{$fh}, 10240); } } @@ -578,52 +620,248 @@ exit; ############################################################################ sub tab { - local($tabstring); + my $tabstring; - $tabstring = "\t" x ($indent / 2) . ' ' x ($indent % 2 * 4); + $tabstring = "\t" x ($indent_depth/2) . ' ' x ($indent_depth%2 * 4); if (!$statdone) { - if ($_ =~ /^(name|print|prune|exec|ok|\(|\))/) { - $delayedstat++; - } - else { - if ($saw_or) { - $tabstring .= <<"ENDOFSTAT" . $tabstring; -(\$nlink || ((\$dev,\$ino,\$mode,\$nlink,\$uid,\$gid) = $stat\(\$_\))) && -ENDOFSTAT - } - else { - $tabstring .= <<"ENDOFSTAT" . $tabstring; -((\$dev,\$ino,\$mode,\$nlink,\$uid,\$gid) = $stat\(\$_\)) && -ENDOFSTAT - } - $statdone = 1; - } + if ($_ =~ /^(?:name|print|prune|exec|ok|\(|\))/) { + $init{delayedstat} = 1; + } else { + my $statcall = '(($dev,$ino,$mode,$nlink,$uid,$gid) = ' + . $stat . '($_))'; + if (exists $init{saw_or}) { + $tabstring .= "(\$nlink || $statcall) &&\n" . $tabstring; + } else { + $tabstring .= "$statcall &&\n" . $tabstring; + } + $statdone = 1; + $init{declarestat} = 1; + } } $tabstring =~ s/^\s+/ / if $out =~ /!$/; $tabstring; } sub fileglob_to_re { - local($tmp) = @_; - - $tmp =~ s#([./^\$()])#\\$1#g; - $tmp =~ s/([?*])/.$1/g; - "^$tmp\$"; + my $x = shift; + $x =~ s#([./^\$()])#\\$1#g; + $x =~ s#([?*])#.$1#g; + "^$x\$"; } sub n { - local($n) = @_; - + my ($pre, $n) = @_; $n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /; $n =~ s/ 0*(\d)/ $1/; - $n . ')'; + "($pre $n)"; } sub quote { - local($string) = @_; - $string =~ s/'/\\'/; + my $string = shift; + $string =~ s/'/\\'/g; "'$string'"; } + +__END__ + +=head1 NAME + +find2perl - translate find command lines to Perl code + +=head1 SYNOPSIS + + find2perl [paths] [predicates] | perl + +=head1 DESCRIPTION + +find2perl is a little translator to convert find command lines to +equivalent Perl code. The resulting code is typically faster than +running find itself. + +"paths" are a set of paths where find2perl will start its searches and +"predicates" are taken from the following list. + +=over 4 + +=item C<! PREDICATE> + +Negate the sense of the following predicate. The C<!> must be passed as +a distinct argument, so it may need to be surrounded by whitespace and/or +quoted from interpretation by the shell using a backslash (just as with +using C<find(1)>). + +=item C<( PREDICATES )> + +Group the given PREDICATES. The parentheses must be passed as distinct +arguments, so they may need to be surrounded by whitespace and/or +quoted from interpretation by the shell using a backslash (just as with +using C<find(1)>). + +=item C<PREDICATE1 PREDICATE2> + +True if _both_ PREDICATE1 and PREDICATE2 are true; PREDICATE2 is not +evaluated if PREDICATE1 is false. + +=item C<PREDICATE1 -o PREDICATE2> + +True if either one of PREDICATE1 or PREDICATE2 is true; PREDICATE2 is +not evaluated if PREDICATE1 is true. + +=item C<-follow> + +Follow (dereference) symlinks. [XXX doesn't work fully, see L<BUGS>] + +=item C<-depth> + +Change directory traversal algorithm from breadth-first to depth-first. + +=item C<-prune> + +Do not descend into the directory currently matched. + +=item C<-xdev> + +Do not traverse mount points (prunes search at mount-point directories). + +=item C<-name GLOB> + +File name matches specified GLOB wildcard pattern. GLOB may need to be +quoted to avoid interpretation by the shell (just as with using +C<find(1)>). + +=item C<-perm PERM> + +Low-order 9 bits of permission match octal value PERM. + +=item C<-perm -PERM> + +The bits specified in PERM are all set in file's permissions. + +=item C<-type X> + +The file's type matches perl's C<-X> operator. + +=item C<-fstype TYPE> + +Filesystem of current path is of type TYPE (only NFS/non-NFS distinction +is implemented). + +=item C<-user USER> + +True if USER is owner of file. + +=item C<-group GROUP> + +True if file's group is GROUP. + +=item C<-nouser> + +True if file's owner is not in password database. + +=item C<-nogroup> + +True if file's group is not in group database. + +=item C<-inum INUM> + +True file's inode number is INUM. + +=item C<-links N> + +True if (hard) link count of file matches N (see below). + +=item C<-size N> + +True if file's size matches N (see below) N is normally counted in +512-byte blocks, but a suffix of "c" specifies that size should be +counted in characters (bytes) and a suffix of "k" specifes that +size should be counted in 1024-byte blocks. + +=item C<-atime N> + +True if last-access time of file matches N (measured in days) (see +below). + +=item C<-ctime N> + +True if last-changed time of file's inode matches N (measured in days, +see below). + +=item C<-mtime N> + +True if last-modified time of file matches N (measured in days, see below). + +=item C<-newer FILE> + +True if last-modified time of file matches N. + +=item C<-print> + +Print out path of file (always true). + +=item C<-print0> + +Like -print, but terminates with \0 instead of \n. + +=item C<-exec OPTIONS ;> + +exec() the arguments in OPTIONS in a subprocess; any occurence of {} in +OPTIONS will first be substituted with the path of the current +file. Note that the command "rm" has been special-cased to use perl's +unlink() function instead (as an optimization). The C<;> must be passed as +a distinct argument, so it may need to be surrounded by whitespace and/or +quoted from interpretation by the shell using a backslash (just as with +using C<find(1)>). + +=item C<-ok OPTIONS ;> + +Like -exec, but first prompts user; if user's response does not begin +with a y, skip the exec. The C<;> must be passed as +a distinct argument, so it may need to be surrounded by whitespace and/or +quoted from interpretation by the shell using a backslash (just as with +using C<find(1)>). + +=item C<-eval EXPR ;> + +Has the perl script eval() the EXPR. The C<;> must be passed as +a distinct argument, so it may need to be surrounded by whitespace and/or +quoted from interpretation by the shell using a backslash (just as with +using C<find(1)>). + +=item C<-ls> + +Simulates C<-exec ls -dils {} ;> + +=item C<-tar FILE> + +Adds current output to tar-format FILE. + +=item C<-cpio FILE> + +Adds current output to old-style cpio-format FILE. + +=item C<-ncpio FILE> + +Adds current output to "new"-style cpio-format FILE. + +=back + +Predicates which take a numeric argument N can come in three forms: + + * N is prefixed with a +: match values greater than N + * N is prefixed with a -: match values less than N + * N is not prefixed with either + or -: match only values equal to N + +=head1 BUGS + +The -follow option doesn't really work yet, because File::Find doesn't +support following symlinks. + +=head1 SEE ALSO + +find + +=cut !NO!SUBS! close OUT or die "Can't close $file: $!"; |