diff options
63 files changed, 4483 insertions, 659 deletions
@@ -79,6 +79,643 @@ Version 5.005_55 Development release working toward 5.006 ---------------- ____________________________________________________________________________ +[ 2828] By: gsar on 1999/02/07 23:38:47 + Log: From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Sun, 7 Feb 1999 17:25:22 -0500 + Message-ID: <19990207172522.B894@monk.mps.ohio-state.edu> + Subject: [PATCH 5.005_53] s/\ba/./g was over-optimized + Branch: perl + + t/op/subst_amp.t t/op/subst_wamp.t + ! MANIFEST regcomp.c t/op/subst.t +____________________________________________________________________________ +[ 2827] By: gsar on 1999/02/07 23:27:32 + Log: From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Sun, 7 Feb 1999 17:00:10 -0500 + Message-ID: <19990207170009.A894@monk.mps.ohio-state.edu> + Subject: [PATCH 5.005_53] Fix list-context //g with zero-length matches + Branch: perl + ! pp_hot.c t/op/pat.t +____________________________________________________________________________ +[ 2826] By: gsar on 1999/02/07 23:26:04 + Log: patch for change#2822, done right; add PERL_OBJECT stuff; regen headers + From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Sun, 7 Feb 1999 15:07:27 -0500 + Message-ID: <19990207150726.A571@monk.mps.ohio-state.edu> + Subject: Re: fixing memory leaks in REx compilation + Branch: perl + ! embed.h embed.pl objXSUB.h proto.h regcomp.c regcomp.h + ! regexec.c +____________________________________________________________________________ +[ 2825] By: jhi on 1999/02/07 18:05:13 + Log: Integrate from mainperl. + Branch: cfgperl + +> lib/DB.pm t/comp/bproto.t + !> MANIFEST ext/Data/Dumper/Dumper.pm ext/SDBM_File/sdbm/sdbm.c + !> lib/Pod/Html.pm op.c perly.c perly.y perly_c.diff + !> pod/perldelta.pod pod/perlfunc.pod pod/perlop.pod regcomp.h + !> toke.c vms/perly_c.vms +____________________________________________________________________________ +[ 2824] By: gsar on 1999/02/07 14:21:48 + Log: tweak doc on bitwise ops + Branch: perl + ! pod/perlop.pod +____________________________________________________________________________ +[ 2823] By: gsar on 1999/02/07 13:38:31 + Log: applied suggested patch; regen perly* and vms/perly* + From: Stephen McCamant <smccam@uclink4.berkeley.edu> + Date: Sun, 13 Dec 1998 01:10:12 -0800 (PST) + Message-ID: <13939.26706.620683.846776@fre-76-120.reshall.berkeley.edu> + Subject: [PATCH] Re: Suggestion for perlobj man page + Branch: perl + ! perly.c perly.y perly_c.diff toke.c vms/perly_c.vms +____________________________________________________________________________ +[ 2822] By: gsar on 1999/02/07 12:39:09 + Log: Ilya's idea for cleaning up failed regex allocs (substantive parts + disabled, fails tests) + Branch: perl + ! regcomp.h +____________________________________________________________________________ +[ 2821] By: gsar on 1999/02/07 11:09:39 + Log: pod2html misinterprets Foo::Bar as a URL (fix suggested by Alexander Barilo + <Alexander.Barilo@aexp.com>) + Branch: perl + ! lib/Pod/Html.pm +____________________________________________________________________________ +[ 2820] By: gsar on 1999/02/07 10:20:35 + Log: add draft debugging API implementation + Branch: perl + + lib/DB.pm + ! MANIFEST +____________________________________________________________________________ +[ 2819] By: gsar on 1999/02/07 09:58:45 + Log: avoid garbage in db->dirbuf + From: Masahiro KAJIURA <masahiro.kajiura@toshiba.co.jp> + Date: Sat, 05 Dec 1998 14:14:54 +0900 + Message-Id: <199812050514.OAA23268@toshiba.co.jp> + Subject: SDBM bug + Branch: perl + ! ext/SDBM_File/sdbm/sdbm.c +____________________________________________________________________________ +[ 2818] By: gsar on 1999/02/07 09:32:24 + Log: missing entry + Branch: perl + ! MANIFEST +____________________________________________________________________________ +[ 2817] By: gsar on 1999/02/07 09:30:47 + Log: properly prototype check parenthesized unary ops (e.g. defined(&a,&b)) + Branch: perl + + t/comp/bproto.t + ! op.c pod/perldelta.pod pod/perlfunc.pod pod/perlop.pod +____________________________________________________________________________ +[ 2816] By: gsar on 1999/02/06 00:14:29 + Log: minor bug in dumping blessed subrefs + Branch: perl + ! ext/Data/Dumper/Dumper.pm +____________________________________________________________________________ +[ 2815] By: gsar on 1999/02/05 03:44:50 + Log: integrate change#2242 from mainline + + fix skipspace() to properly account for newlines in eval''-ed + strings (caused bogus line numbers in diagnostics and debugger) + Branch: maint-5.005/perl + !> toke.c +____________________________________________________________________________ +[ 2814] By: jhi on 1999/02/04 21:21:39 + Log: Stratus perlport update. + Branch: maint-5.005/perl + ! pod/perlport.pod +____________________________________________________________________________ +[ 2813] By: jhi on 1999/02/04 21:16:54 + Log: Stratus VOS update. + + From: Paul_Green@stratus.com + To: jhi@iki.fi + Subject: RE: VOS changes for Perl5.005_03 are ready! + Date: Thu, 4 Feb 1999 14:51:07 -0500 + Message-ID: <1D1A4EF7AD4DD211A80D00A0C9D7DB665A0168@exna1.stratus.com> + Branch: maint-5.005/perl + + vos/vos_accept.c + ! MANIFEST README.vos perl.c pod/perlport.pod vos/Changes + ! vos/build.cm vos/compile_perl.cm vos/config.h + ! vos/config_h.SH_orig vos/perl.bind vos/test_vos_dummies.c + ! vos/vos_dummies.c vos/vosish.h +____________________________________________________________________________ +[ 2812] By: jhi on 1999/02/03 22:02:24 + Log: Enhance change #2808. + + From: "M.J.T. Guy" <mjtg@cus.cam.ac.uk> + To: perl5-porters@perl.org + Subject: Re: [PATCH 5.00*]: perlbug checklist + Date: Wed, 3 Feb 1999 19:02:27 +0000 + Message-Id: <E1087ZD-0005z1-00@taurus.cus.cam.ac.uk> + Branch: cfgperl + ! utils/perlbug.PL +____________________________________________________________________________ +[ 2811] By: jhi on 1999/02/03 21:53:23 + Log: From: Barrie Slaymaker <rbs@telerama.com> + To: perl5-porters@perl.org + CC: pod-people@perl.org + Subject: [PATCH]5.005_54 (pod2html) Generate Relative URLs + Date: Wed, 03 Feb 1999 10:34:18 -0500 + Message-ID: <36B86C7A.E99EFFF1@telerama.com> + + Add File::PathConvert.pm. + Fix Pod::Html and installhtml to understand relative urls. + Branch: cfgperl + + lib/File/PathConvert.pm + ! MANIFEST installhtml lib/Pod/Html.pm +____________________________________________________________________________ +[ 2810] By: jhi on 1999/02/03 20:25:10 + Log: From: Francois Desarmenien <desar@club-internet.fr> + To: Mailing list Perl5 <perl5-porters@perl.org> + Subject: [PATCH]5.005_54 (hints) SCO 3/5 hint files and SysV correction + Date: Wed, 03 Feb 1999 13:13:24 +0000 + Message-ID: <36B84B74.5EC9B6C8@club-internet.fr> + + (note: this patch completely overrides Tom Wolfe's patch, + change #2604) + Branch: cfgperl + + ext/GDBM_File/hints/sco.pl + ! MANIFEST ext/IPC/SysV/SysV.xs hints/sco.sh +____________________________________________________________________________ +[ 2809] By: jhi on 1999/02/03 19:54:16 + Log: h2ph fixes + Configure patch to support them. + + From: "Kurt D. Starsinic" <kstar@chapin.edu> + To: Graham Barr <gbarr@pobox.com>, Jarkko Hietaniemi <jhi@iki.fi>, + Gurusamy Sarathy <gsar@engin.umich.edu> + Cc: perl5-porters@perl.org + Subject: [PATCH 5.00503_MT5] h2ph.PL + Date: Tue, 2 Feb 1999 19:48:06 -0500 + Message-ID: <19990202194806.E10647@O2.chapin.edu> + Branch: maint-5.005/perl + ! Configure utils/h2ph.PL +____________________________________________________________________________ +[ 2808] By: jhi on 1999/02/03 16:59:55 + Log: Enhance the perlbug checklist. + Branch: cfgperl + ! utils/perlbug.PL +____________________________________________________________________________ +[ 2807] By: jhi on 1999/02/03 14:01:37 + Log: Document the standard strftime %formats. + + From: Dominic Dunlop <domo@vo.lu> + To: "Kurt D. Starsinic" <kstar@chapin.edu>, Ben Gertzfield <che@debian.org> + Subject: [PATCH] 5.00[45]*: Re: POSIX's strftime() does not enforce POSIX %C on Solaris + Date: Tue, 2 Feb 1999 15:55:29 +0100 + Message-Id: <v0311070cb2dcb3f5f773@[212.24.192.188]> + Branch: cfgperl + ! ext/POSIX/POSIX.pod +____________________________________________________________________________ +[ 2806] By: jhi on 1999/02/03 13:58:00 + Log: Integrate from mainperl. + Branch: cfgperl + !> perl.h +____________________________________________________________________________ +[ 2805] By: gsar on 1999/02/03 03:32:31 + Log: PL_uuemap[] init needs help for sizeof() + Branch: perl + ! perl.h +____________________________________________________________________________ +[ 2804] By: jhi on 1999/02/02 20:44:30 + Log: These should've been already in #2803. + Branch: cfgperl + ! Configure config_h.SH vms/subconfigure.com +____________________________________________________________________________ +[ 2803] By: jhi on 1999/02/02 20:38:45 + Log: telldir prototype issue, from mists of time... + Branch: cfgperl + ! hints/netbsd.sh pp_sys.c +____________________________________________________________________________ +[ 2802] By: jhi on 1999/02/02 17:41:23 + Log: From: John Bley <jbb6@acpub.duke.edu> + To: perlbug@perl.org + Subject: [PATCH]5.005_54 (DOC) fix minor typos + Date: Tue, 2 Feb 1999 07:52:52 -0500 (EST) + Message-ID: <Pine.SOL.3.91.990202075115.23589A-100000@soc11.acpub.duke.edu> + Branch: maint-5.005/perl + ! pod/perlre.pod +____________________________________________________________________________ +[ 2801] By: jhi on 1999/02/02 17:40:14 + Log: From: John Bley <jbb6@acpub.duke.edu> + To: perlbug@perl.org + Subject: [PATCH]5.005_54 (DOC) fix minor typos + Date: Tue, 2 Feb 1999 07:52:52 -0500 (EST) + Message-ID: <Pine.SOL.3.91.990202075115.23589A-100000@soc11.acpub.duke.edu> + Branch: cfgperl + ! pod/perlre.pod +____________________________________________________________________________ +[ 2800] By: jhi on 1999/02/02 17:26:49 + Log: Update todo with POSIX 1003.1 1996 Edition reminder. + Branch: cfgperl + ! Todo-5.005 +____________________________________________________________________________ +[ 2799] By: jhi on 1999/02/02 17:18:51 + Log: Update FindBin from maint-5.005. + Branch: cfgperl + ! lib/FindBin.pm +____________________________________________________________________________ +[ 2798] By: jhi on 1999/02/02 17:16:07 + Log: Fix typecasts in #2797 + + From: "G. Del Merritt" <del@intranetics.com> + Date: Fri, 29 Jan 1999 11:47:25 -0700 + Message-Id: <199901291847.LAA04828@jhereg.perl.com> + Subject: Not OK: perl 5.00503 +MAINT_TRIAL_5 on MSWin32-x86-object 4.0 (PATCH included) + Branch: cfgperl + ! ext/POSIX/POSIX.xs +____________________________________________________________________________ +[ 2797] By: jhi on 1999/02/02 17:14:37 + Log: From: Ted Law <tedlaw@cibcwg.com> + Date: Wed, 27 Jan 1999 14:54:03 -0500 (EST) + Message-Id: <199901271954.OAA07391@dcm2.cibcwg.com> + Subject: POSIX::strftime buffer overflow problem + Branch: cfgperl + ! ext/POSIX/POSIX.xs +____________________________________________________________________________ +[ 2796] By: jhi on 1999/02/02 17:13:23 + Log: Do not use File::Slurp. + Branch: cfgperl + ! t/lib/textfill.t +____________________________________________________________________________ +[ 2795] By: jhi on 1999/02/02 17:11:48 + Log: perlhist update from maint-5.005. + Branch: cfgperl + ! pod/perlhist.pod +____________________________________________________________________________ +[ 2794] By: jhi on 1999/02/02 17:10:33 + Log: POSIX::redef setv?buf() to IO::Handle:: (by gbarr). + Branch: cfgperl + ! ext/POSIX/POSIX.pm +____________________________________________________________________________ +[ 2793] By: jhi on 1999/02/02 17:08:39 + Log: Missed the html test from change #2787. + Branch: cfgperl + ! t/lib/cgi-html.t +____________________________________________________________________________ +[ 2792] By: jhi on 1999/02/02 17:01:24 + Log: Update Getopt::Long to 2.19. + Branch: cfgperl + ! lib/Getopt/Long.pm +____________________________________________________________________________ +[ 2791] By: jhi on 1999/02/02 16:59:13 + Log: overload syntax is no longer experimental + Branch: cfgperl + ! lib/overload.pm +____________________________________________________________________________ +[ 2790] By: jhi on 1999/02/02 16:51:45 + Log: Re-introduce the typo corrections (update to CGI 2.46 + overran them). + Branch: maint-5.005/perl + ! lib/CGI.pm +____________________________________________________________________________ +[ 2789] By: jhi on 1999/02/02 16:47:50 + Log: Still doc fixes. + Branch: cfgperl + ! lib/diagnostics.pm +____________________________________________________________________________ +[ 2788] By: jhi on 1999/02/02 16:47:07 + Log: Doc fixes. + Branch: cfgperl + ! lib/CGI.pm lib/diagnostics.pm +____________________________________________________________________________ +[ 2787] By: jhi on 1999/02/02 16:38:55 + Log: CGI.pm updated to 2.46 (the CGI docs fixes redone + where applicable). + Branch: cfgperl + ! eg/cgi/RunMeFirst eg/cgi/caution.xbm + ! eg/cgi/clickable_image.cgi eg/cgi/cookie.cgi eg/cgi/crash.cgi + ! eg/cgi/customize.cgi eg/cgi/diff_upload.cgi + ! eg/cgi/dna.small.gif.uu eg/cgi/file_upload.cgi + ! eg/cgi/frameset.cgi eg/cgi/index.html + ! eg/cgi/internal_links.cgi eg/cgi/javascript.cgi + ! eg/cgi/monty.cgi eg/cgi/multiple_forms.cgi + ! eg/cgi/nph-clock.cgi eg/cgi/nph-multipart.cgi eg/cgi/popup.cgi + ! eg/cgi/save_state.cgi eg/cgi/tryit.cgi eg/cgi/wilogo.gif.uu + ! lib/CGI.pm lib/CGI/Apache.pm lib/CGI/Carp.pm lib/CGI/Cookie.pm + ! lib/CGI/Fast.pm lib/CGI/Push.pm lib/CGI/Switch.pm +____________________________________________________________________________ +[ 2786] By: jhi on 1999/02/02 16:17:52 + Log: Update CPAN to 1.47. + Branch: cfgperl + ! lib/CPAN.pm lib/CPAN/FirstTime.pm lib/CPAN/Nox.pm +____________________________________________________________________________ +[ 2785] By: jhi on 1999/02/02 16:09:03 + Log: From: Mark-Jason Dominus <mjd@plover.com> + Date: Sat, 16 Jan 1999 17:22:06 -0500 + Subject: Re: DOC PATCH (5.005_54 perlsub.pod) + Message-ID: <19990116222206.3674.qmail@plover.com> + Branch: cfgperl + ! pod/perlsub.pod +____________________________________________________________________________ +[ 2784] By: jhi on 1999/02/02 16:01:31 + Log: Fix incorrect "used only once" warnings + + From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Fri, 8 Jan 1999 04:37:10 -0500 + Message-ID: <19990108043710.A14390@monk.mps.ohio-state.edu> + Subject: Re: change#965 flakiness + Branch: cfgperl + ! gv.c +____________________________________________________________________________ +[ 2783] By: jhi on 1999/02/02 15:50:38 + Log: perldelta updates. + Branch: cfgperl + ! pod/perldelta.pod +____________________________________________________________________________ +[ 2782] By: jhi on 1999/02/02 14:28:26 + Log: Mirror change #2781. + Branch: cfgperl + ! hints/linux.sh +____________________________________________________________________________ +[ 2781] By: jhi on 1999/02/02 14:27:01 + Log: Update the MkLinux note. + Branch: maint-5.005/perl + ! hints/linux.sh +____________________________________________________________________________ +[ 2780] By: jhi on 1999/02/02 14:10:59 + Log: Update todo. + Branch: cfgperl + ! Todo-5.005 +____________________________________________________________________________ +[ 2779] By: jhi on 1999/02/02 14:00:25 + Log: Integrate from mainperl. + Branch: cfgperl + ! t/lib/textfill.t t/lib/textwrap.t + !> (integrate 32 files) +____________________________________________________________________________ +[ 2778] By: jhi on 1999/02/02 13:56:23 + Log: VMS update, applicable parts of + + From: Dan Sugalski <sugalskd@osshe.edu> + To: perl5-porters@perl.org + Subject: [PATCH 5.005_03MT3]VMS configure tweak + Date: Wed, 20 Jan 1999 12:05:18 -0800 + Message-Id: <3.0.6.32.19990120120518.00a98470@ous.edu> + + From: Dan Sugalski <sugalskd@osshe.edu> + To: perlbug@perl.com, vmsperl@perl.org + Subject: NOT OK: perl 5.00503 +MAINT_TRIAL_4 on VMSAXP (Patch included, of course) + Date: Tue, 26 Jan 1999 14:40:38 -0800 + Message-Id: <3.0.6.32.19990126144038.02e5d650@ous.edu> + + From: Dan Sugalski <sugalskd@osshe.edu> + To: perl5-porters@perl.org, vmsperl@perl.org + Subject: [PATCH 5.005_03-MAILT_TRIAL_4]VMS test patches + Date: Tue, 26 Jan 1999 14:55:29 -0800 + Message-Id: <3.0.6.32.19990126145529.02f22280@ous.edu> + Branch: cfgperl + ! vms/ext/Stdio/test.pl vms/subconfigure.com +____________________________________________________________________________ +[ 2777] By: jhi on 1999/02/02 13:43:24 + Log: Synch usethreads parts from maint-5.005. + Branch: cfgperl + ! hints/aix.sh hints/dec_osf.sh hints/dos_djgpp.sh + ! hints/freebsd.sh hints/hpux.sh hints/irix_4.sh hints/irix_5.sh + ! hints/irix_6.sh hints/irix_6_0.sh hints/irix_6_1.sh + ! hints/linux.sh hints/os2.sh hints/solaris_2.sh hints/vmesa.sh +____________________________________________________________________________ +[ 2776] By: jhi on 1999/02/02 13:17:16 + Log: Jumbo FreeBSD update from Anton Berezin <tobez@plab.ku.dk> + Branch: cfgperl + ! Makefile.SH hints/freebsd.sh +____________________________________________________________________________ +[ 2775] By: jhi on 1999/02/02 13:13:24 + Log: Mention lib/Dumpvalue.pm. + Branch: maint-5.005/perl + ! pod/roffitall +____________________________________________________________________________ +[ 2774] By: jhi on 1999/02/02 13:10:39 + Log: Add perlthrtut, update pod/* machinery. + (a pod/Makefile.SH is sorely needed) + Branch: cfgperl + + pod/perlthrtut.pod + ! MANIFEST pod/Makefile pod/perl.pod pod/roffitall +____________________________________________________________________________ +[ 2773] By: jhi on 1999/02/02 12:54:24 + Log: From: "M.J.T. Guy" <mjtg@cus.cam.ac.uk> + To: perl5-porters@perl.org + Subject: Re: [PATCH] perl5.005_03-MAINT_TRIAL_3: clarify Sv[INU]V versus Sv[INU]VX in perlguts + Date: Tue, 26 Jan 1999 22:25:07 +0000 + Message-Id: <E105Gux-0000Ac-00@taurus.cus.cam.ac.uk> + Branch: cfgperl + ! pod/perlguts.pod +____________________________________________________________________________ +[ 2772] By: jhi on 1999/02/02 12:52:50 + Log: io/fs.t fails test #18. + + From: "G. Del Merritt" <del@intranetics.com> + To: perlbug@perl.com + Subject: NOT OK: perl 5.00503 +MAINT_TRIAL_4 on MSWin32-x86-object (PATCHES included) + Date: Tue, 26 Jan 1999 12:09:09 -0700 + Message-Id: <199901261909.MAA25525@jhereg.perl.com> + + didn't apply cleanly because test #17 is not similar, applied manually + Branch: cfgperl + ! t/io/fs.t +____________________________________________________________________________ +[ 2771] By: jhi on 1999/02/02 12:47:34 + Log: Use perlbug instead of personal email address. + Branch: cfgperl + ! Configure +____________________________________________________________________________ +[ 2770] By: jhi on 1999/02/02 12:42:06 + Log: Miniperl fails to build (pp_sys.c was changed and iperlsys.h wasn't) + + From: "G. Del Merritt" <del@intranetics.com> + To: perlbug@perl.com + Subject: NOT OK: perl 5.00503 +MAINT_TRIAL_4 on MSWin32-x86-object (PATCHES included) + Date: Tue, 26 Jan 1999 12:09:09 -0700 + Message-Id: <199901261909.MAA25525@jhereg.perl.com> + Branch: cfgperl + ! iperlsys.h +____________________________________________________________________________ +[ 2769] By: jhi on 1999/02/02 12:37:57 + Log: From: Ilya Zakharevich <ilya@math.ohio-state.edu> + To: Mailing list Perl5 <perl5-porters@perl.org> + Subject: [PATCH 5.005_*] OS/2 threads + Date: Tue, 26 Jan 1999 13:39:46 -0500 + Message-ID: <19990126133946.A11594@monk.mps.ohio-state.edu> + Branch: cfgperl + ! os2/os2ish.h +____________________________________________________________________________ +[ 2768] By: jhi on 1999/02/02 12:36:16 + Log: Apply change #2711 from maint-5.005: + + make ok", "make okfile", and "make nok" were broken + with -Duseshrplib, because of a shared typo. + + From: Spider Boardman <spider@web.zk3.dec.com> + To: perlbug@perl.com + Subject: Not OK: perl 5.00503 +MAINT_TRIAL_4 on alpha-dec_osf-thread 5.0 (UNINSTALLED) + Date: Wed, 27 Jan 1999 12:27:15 -0500 + Message-Id: <199901271727.MAA233455@web.zk3.dec.com> + Branch: cfgperl + ! Makefile.SH +____________________________________________________________________________ +[ 2767] By: jhi on 1999/02/02 12:29:57 + Log: Demangle spaces to tab+space. + Branch: maint-5.005/perl + ! hints/freebsd.sh +____________________________________________________________________________ +[ 2766] By: jhi on 1999/02/02 12:27:08 + Log: Make Configure use "int main()" instead of bare "main()". + Like maint-5.005 change #2703 but now via metaconfig. + Branch: cfgperl + ! Configure +____________________________________________________________________________ +[ 2765] By: jhi on 1999/02/02 11:59:30 + Log: Undo part of change #2562. + Branch: cfgperl + ! Configure +____________________________________________________________________________ +[ 2764] By: jhi on 1999/02/02 11:52:39 + Log: NetBSD synch with maint-5.005. + Branch: cfgperl + ! Makefile.SH hints/netbsd.sh makedepend.SH unixish.h +____________________________________________________________________________ +[ 2763] By: jhi on 1999/02/02 11:44:07 + Log: $Config{installusrbinperl} + (maint-5.005 changes #2614 and #2709) + Branch: cfgperl + ! Configure installperl +____________________________________________________________________________ +[ 2762] By: jhi on 1999/02/02 11:29:13 + Log: Errno update from maint-5.005 (changes #2583, #2710). + Branch: cfgperl + ! Configure ext/Errno/Errno_pm.PL +____________________________________________________________________________ +[ 2759] By: jhi on 1999/02/02 10:53:20 + Log: Update Trig.pm from maint-5.005. + Branch: cfgperl + ! lib/Math/Trig.pm +____________________________________________________________________________ +[ 2758] By: jhi on 1999/02/02 10:51:26 + Log: Detypo. + Branch: maint-5.005/perl + ! lib/Math/Trig.pm +____________________________________________________________________________ +[ 2757] By: jhi on 1999/02/02 10:41:26 + Log: MPE/iX update (mirror maint-5.005 change #2715) + Branch: cfgperl + ! hints/mpeix.sh mpeix/relink +____________________________________________________________________________ +[ 2756] By: jhi on 1999/02/02 10:38:08 + Log: BeOS update (Mirror maint-5.005 change #2727). + Branch: cfgperl + + ext/DynaLoader/dl_beos.xs + ! Configure MANIFEST Makefile.SH README.beos hints/beos.sh + ! lib/ExtUtils/MM_Unix.pm +____________________________________________________________________________ +[ 2755] By: jhi on 1999/02/02 09:07:51 + Log: Make FreeBSD 2.2.7 work with -Duseshrplib -ders. + Branch: maint-5.005/perl + ! hints/freebsd.sh +____________________________________________________________________________ +[ 2754] By: gsar on 1999/02/02 08:52:13 + Log: Todo updates from Andy Dougherty <doughera@lafayette.edu> + Branch: perl + ! Porting/pumpkin.pod Todo Todo-5.005 +____________________________________________________________________________ +[ 2753] By: gsar on 1999/02/02 08:46:21 + Log: Todo tweaks + Branch: perl + ! Todo Todo-5.005 +____________________________________________________________________________ +[ 2752] By: jhi on 1999/02/01 22:15:12 + Log: Add perlthrtut.pod. + + From: Dan Sugalski <sugalskd@osshe.edu> + To: perl5-porters@perl.org + Subject: perlthrtut.pod + Date: Mon, 01 Feb 1999 10:57:11 -0800 + Message-Id: <3.0.6.32.19990201105711.02e62540@ous.edu> + Branch: maint-5.005/perl + + pod/perlthrtut.pod + ! MANIFEST pod/Makefile pod/buildtoc pod/perldelta.pod + ! pod/roffitall +____________________________________________________________________________ +[ 2751] By: gsar on 1999/02/01 07:28:05 + Log: devnull() support from Jan Dubois <jan.dubois@ibm.net> and others + Branch: perl + ! lib/File/Spec/OS2.pm lib/File/Spec/Unix.pm + ! lib/File/Spec/VMS.pm lib/File/Spec/Win32.pm +____________________________________________________________________________ +[ 2750] By: gsar on 1999/02/01 07:09:20 + Log: From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Fri, 4 Dec 1998 01:02:03 -0500 (EST) + Message-Id: <199812040602.BAA07215@monk.mps.ohio-state.edu> + Subject: [PATCH 5.005_53] Debugging REx with lookbehind + Branch: perl + ! regexec.c +____________________________________________________________________________ +[ 2749] By: gsar on 1999/02/01 07:07:59 + Log: From: Ilya Zakharevich <ilya@math.ohio-state.edu> + Date: Fri, 4 Dec 1998 00:05:41 -0500 (EST) + Message-Id: <199812040505.AAA16616@monk.mps.ohio-state.edu> + Subject: [PATCH 5.005_53] Speed up .*? and half-fix UTF lookbehind + Branch: perl + ! regexec.c +____________________________________________________________________________ +[ 2748] By: gsar on 1999/02/01 06:47:06 + Log: From: "Jonathan I. Kamens" <jik@kamens.brookline.ma.us> + Date: Thu, 3 Dec 1998 15:10:17 -0500 + Message-Id: <199812032010.PAA09692@jik.shore.net> + Subject: sample checksum code in "perlfunc" man page is wrong + Branch: perl + ! pod/perlfunc.pod +____________________________________________________________________________ +[ 2747] By: gsar on 1999/02/01 06:35:13 + Log: typos in Pod/Text.pm + From: "Greg Chapman" <glc@well.com> + Date: Tue, 1 Dec 1998 10:50:18 -0800 + Message-Id: <199812011849.KAA08816@smtp.well.com> + Subject: Glitch in Pod::Text + Branch: perl + ! lib/Pod/Text.pm +____________________________________________________________________________ +[ 2746] By: gsar on 1999/02/01 06:27:35 + Log: various win32-ish changes merged from maint-5.005 + Branch: perl + ! README.win32 embedvar.h globvar.sym lib/ExtUtils/MM_Unix.pm + ! objXSUB.h op.c perl.h perlvars.h pp.c sv.c t/io/fs.t toke.c + ! win32/Makefile win32/config.bc win32/config.vc + ! win32/config_sh.PL win32/makefile.mk win32/runperl.c + ! win32/win32.c +____________________________________________________________________________ +[ 2745] By: gsar on 1999/02/01 04:51:54 + Log: integrate cfgperl changes into mainline + Branch: perl + !> INSTALL hints/aix.sh lib/Time/Local.pm pod/perldelta.pod +____________________________________________________________________________ +[ 2744] By: gsar on 1999/02/01 04:31:09 + Log: improved diagnostic on syntax errors at EOL + Branch: perl + ! toke.c +____________________________________________________________________________ +[ 2743] By: gsar on 1999/02/01 03:59:13 + Log: don't attempt connect() to bogus IP addresses + From: Graham Barr <gbarr@pobox.com> + Date: Sun, 31 Jan 1999 21:50:45 CST + Message-Id: <19990131215045.A633@pobox.com> + Branch: perl + ! t/lib/io_multihomed.t +____________________________________________________________________________ +[ 2742] By: gsar on 1999/02/01 03:08:58 + Log: update Changes + Branch: perl + ! Changes pod/perldelta.pod +____________________________________________________________________________ +[ 2741] By: gbarr on 1999/02/01 03:00:42 + Log: Fix typecasts in #2728 + + From: "G. Del Merritt" <del@intranetics.com> + Date: Fri, 29 Jan 1999 11:47:25 -0700 + Message-Id: <199901291847.LAA04828@jhereg.perl.com> + Subject: Not OK: perl 5.00503 +MAINT_TRIAL_5 on MSWin32-x86-object 4.0 (PATCH included) + Branch: maint-5.005/perl + ! ext/POSIX/POSIX.xs +____________________________________________________________________________ [ 2740] By: gsar on 1999/02/01 02:43:07 Log: CAPI inheritance tweak and doc Branch: maint-5.005/perl @@ -20,8 +20,8 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Fri Jan 22 10:52:50 EET 1999 [metaconfig 3.0 PL70] -# (with additional metaconfig patches by jhi@iki.fi) +# Generated on Mon Feb 8 01:45:46 EET 1999 [metaconfig 3.0 PL70] +# (with additional metaconfig patches by perlbug@perl.com) cat >/tmp/c1$$ <<EOF ARGGGHHHH!!!!! @@ -153,6 +153,9 @@ esac test -d UU || mkdir UU cd UU && rm -f ./* +ccsymbols='' +cppccsymbols='' +cppsymbols='' dynamic_ext='' extensions='' known_extensions='' @@ -386,6 +389,7 @@ longdblsize='' d_longlong='' longlongsize='' d_lstat='' +d_madvise='' d_mblen='' d_mbstowcs='' d_mbtowc='' @@ -396,11 +400,16 @@ d_memset='' d_mkdir='' d_mkfifo='' d_mktime='' +d_mmap='' +mmaptype='' +d_mprotect='' d_msg='' d_msgctl='' d_msgget='' d_msgrcv='' d_msgsnd='' +d_msync='' +d_munmap='' d_nice='' d_open3='' d_fpathconf='' @@ -513,6 +522,7 @@ d_sysconf='' d_system='' d_tcgetpgrp='' d_tcsetpgrp='' +d_telldirproto='' d_time='' timetype='' clocktype='' @@ -609,6 +619,7 @@ i_bsdioctl='' i_sysfilio='' i_sysioctl='' i_syssockio='' +i_sysmman='' i_sysmount='' i_sysndir='' i_sysparam='' @@ -960,7 +971,7 @@ case "$sh" in $me: Fatal Error: I can't find a Bourne Shell anywhere. Usually it's in /bin/sh. How did you even get this far? -Please contact me (Jarkko Hietaniemi) at jhi@iki.fi and +Please contact me (Perl Maintainers) at perlbug@perl.com and we'll try to straighten this all out. EOM exit 1 @@ -1429,7 +1440,7 @@ THIS PACKAGE SEEMS TO BE INCOMPLETE. You have the option of continuing the configuration process, despite the distinct possibility that your kit is damaged, by typing 'y'es. If you do, don't blame me if something goes wrong. I advise you to type 'n'o -and contact the author (jhi@iki.fi). +and contact the author (perlbug@perl.com). EOM echo $n "Continue? [n] $c" >&4 @@ -1654,7 +1665,7 @@ Much effort has been expended to ensure that this shell script will run on any Unix system. If despite that it blows up on yours, your best bet is to edit Configure and run it again. If you can't run Configure for some reason, you'll have to generate a config.sh file by hand. Whatever problems you -have, let me (jhi@iki.fi) know how I blew it. +have, let me (perlbug@perl.com) know how I blew it. This installation script affects things in two ways: @@ -2017,7 +2028,7 @@ EOM (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/ /g' >&4 dflt='' : Half the following guesses are probably wrong... If you have better - : tests or hints, please send them to jhi@iki.fi + : tests or hints, please send them to perlbug@perl.com : The metaconfig authors would also appreciate a copy... $test -f /irix && osname=irix $test -f /xenix && osname=sco_xenix @@ -2510,7 +2521,7 @@ case "$usethreads" in *) cat >&4 <<EOM $osname is not known to support threads. -Please let me (jhi@iki.fi) know how to do that. +Please let perlbug@perl.com know how to do that. Cannot continue, aborting. EOM @@ -2585,7 +2596,7 @@ case "$use64bits" in *) cat >&4 <<EOM $osname is not known to support 64-bit interfaces. -Please let me (jhi@iki.fi) know how to do that. +Please let perlbug@perl.com know how to do that. Cannot continue, aborting. EOM @@ -3025,12 +3036,10 @@ echo ".)" if test 0 -eq "$subversion"; then version=`LC_ALL=C; export LC_ALL; \ - LANGUAGE=C; export LANGUAGE; \ echo $baserev $patchlevel | \ $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'` else version=`LC_ALL=C; export LC_ALL; \ - LANGUAGE=C; export LANGUAGE; \ echo $baserev $patchlevel $subversion | \ $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'` fi @@ -3371,7 +3380,7 @@ fi case "$models" in '') $cat >pdp11.c <<'EOP' -main() { +int main() { #ifdef pdp11 exit(0); #else @@ -3784,7 +3793,7 @@ false) esac case "$cppstdin" in -"$wrapper") ;; +"$wrapper"|'cppstdin') ;; *) $rm -f $wrapper;; esac $rm -f testcpp.c testcpp.out @@ -4201,7 +4210,7 @@ echo " " echo "Checking your choice of C compiler and flags for coherency..." >&4 $cat > try.c <<'EOF' #include <stdio.h> -main() { printf("Ok\n"); exit(0); } +int main() { printf("Ok\n"); exit(0); } EOF set X $cc $optimize $ccflags -o try $ldflags try.c $libs shift @@ -4524,27 +4533,25 @@ fi : determine whether to install perl also as /usr/bin/perl echo " " -case "$installusrbinperl" in -'') if test -d /usr/bin -a "X$installbin" != X/usr/bin; then +if test -d /usr/bin -a "X$installbin" != X/usr/bin; then $cat <<EOM Many scripts expect to perl to be installed as /usr/bin/perl. I can install the perl you are about to compile also as /usr/bin/perl (in addition to $installbin/perl). EOM - dflt='y' + case "$installusrbinperl" in + "$undef"|[nN]*) dflt='n';; + *) dflt='y';; + esac rp="Do you want to install perl as /usr/bin/perl?" . ./myread case "$ans" in [yY]*) val="$define";; - *) val="$undef";; + *) val="$undef" ;; esac - fi - ;; -esac -case "$installusrbinperl" in -"$undef"|[nN]*) val="$undef";; -*) val="$define";; -esac +else + val="$undef" +fi set installusrbinperl eval $setvar @@ -4979,7 +4986,7 @@ yes) else tval=false; fi;; *) - echo "main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c; + echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c; if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1; then tval=true; else tval=false; @@ -5169,6 +5176,7 @@ use no flags, say "none". EOM case "$lddlflags" in '') case "$osname" in + beos) dflt='-nostart' ;; hpux) dflt='-b' ;; linux|irix*) dflt='-shared' ;; next) dflt='none' ;; @@ -5249,7 +5257,7 @@ $undef) ;; *) case "$useshrplib" in '') case "$osname" in - svr4*|dgux|dynixptx|esix|powerux) + svr4*|dgux|dynixptx|esix|powerux|beos) dflt=y also='Building a shared libperl is required for dynamic loading to work on your system.' ;; @@ -5294,6 +5302,7 @@ EOM case "${osname}${osvers}" in next4*) xxx='DYLD_LIBRARY_PATH' ;; os2*) xxx='' ;; # Nothing special needed. + beos*) xxx='' ;; *) xxx='LD_LIBRARY_PATH' ;; esac if test X"$xxx" != "X"; then @@ -5380,7 +5389,7 @@ case "$shrpdir" in *) $cat >&4 <<EOM WARNING: Use of the shrpdir variable for the installation location of the shared $libperl is not supported. It was never documented and -will not work in this version. Let me (jhi@iki.fi) +will not work in this version. Let me (perlbug@perl.com) know of any problems this may cause. EOM @@ -5426,6 +5435,9 @@ if "$useshrplib"; then next) # next doesn't like the default... ;; + beos) + # beos doesn't like the default, either. + ;; *) tmp_shrpenv="env LD_RUN_PATH=$shrpdir" ;; @@ -6353,7 +6365,7 @@ case "$d_access" in #ifdef I_UNISTD #include <unistd.h> #endif -main() { +int main() { exit(R_OK); } EOCP @@ -6553,7 +6565,7 @@ case "$intsize" in echo "Checking to see how big your integers are..." >&4 $cat >intsize.c <<'EOCP' #include <stdio.h> -main() +int main() { printf("intsize=%d;\n", sizeof(int)); printf("longsize=%d;\n", sizeof(long)); @@ -6649,7 +6661,7 @@ $cat >try.c <<EOCP #include <sys/types.h> #include <signal.h> $signal_t blech(s) int s; { exit(3); } -main() +int main() { $xxx i32; double f, g; @@ -6707,7 +6719,7 @@ $signal_t blech_in_list(s) int s; { exit(4); } unsigned long dummy_long(p) unsigned long p; { return p; } unsigned int dummy_int(p) unsigned int p; { return p; } unsigned short dummy_short(p) unsigned short p; { return p; } -main() +int main() { double f; unsigned long along; @@ -6799,7 +6811,7 @@ if set vprintf val -f d_vprintf; eval $csym; $val; then $cat >vprintf.c <<'EOF' #include <varargs.h> -main() { xxx("foo"); } +int main() { xxx("foo"); } xxx(va_alist) va_dcl @@ -7516,7 +7528,7 @@ $cat >open3.c <<'EOCP' #ifdef I_SYS_FILE #include <sys/file.h> #endif -main() { +int main() { if(O_RDONLY); #ifdef O_TRUNC exit(0); @@ -7572,7 +7584,7 @@ case "$o_nonblock" in '') $cat head.c > try.c $cat >>try.c <<'EOCP' -main() { +int main() { #ifdef O_NONBLOCK printf("O_NONBLOCK\n"); exit(0); @@ -7619,7 +7631,7 @@ extern int errno; $signal_t blech(x) int x; { exit(3); } EOCP $cat >> try.c <<'EOCP' -main() +int main() { int pd[2]; int pu[2]; @@ -7768,7 +7780,7 @@ if test "X$timeincl" = X; then #ifdef I_SYSSELECT #include <sys/select.h> #endif -main() +int main() { struct tm foo; #ifdef S_TIMEVAL @@ -7852,7 +7864,7 @@ $cat >fd_set.c <<EOCP #ifdef I_SYS_SELECT #include <sys/select.h> #endif -main() { +int main() { fd_set fds; #ifdef TRYBITS @@ -8406,7 +8418,7 @@ echo " " $cat >isascii.c <<'EOCP' #include <stdio.h> #include <ctype.h> -main() { +int main() { int c = 'A'; if (isascii(c)) exit(0); @@ -8481,7 +8493,7 @@ case "$doublesize" in $echo $n "Checking to see how big your double precision numbers are...$c" >&4 $cat >try.c <<'EOCP' #include <stdio.h> -main() +int main() { printf("%d\n", sizeof(double)); } @@ -8597,6 +8609,10 @@ $rm -f try.c try set lstat d_lstat eval $inlibc +: see if madvise exists +set madvise d_madvise +eval $inlibc + : see if mblen exists set mblen d_mblen eval $inlibc @@ -8637,6 +8653,37 @@ eval $inlibc set mktime d_mktime eval $inlibc +: see if this is a sys/mman.h system +set sys/mman.h i_sysmman +eval $inhdr + +: see if mmap exists +set mmap d_mmap +eval $inlibc +: see what shmat returns +: default to something harmless +mmaptype='void *' +case "$i_sysmman$d_mmap" in +"$define$define") + $cat >mmap.c <<'END' +#include <sys/mman.h> +void *mmap(); +END + if $cc $ccflags -c mmap.c >/dev/null 2>&1; then + mmaptype='void *' + else + mmaptype='caddr_t' + fi + echo "and it returns ($mmaptype)." >&4 + ;; +esac + + + +: see if mprotect exists +set mprotect d_mprotect +eval $inlibc + : see if msgctl exists set msgctl d_msgctl eval $inlibc @@ -8689,6 +8736,14 @@ fi set d_msg eval $setvar +: see if msync exists +set msync d_msync +eval $inlibc + +: see if munmap exists +set munmap d_munmap +eval $inlibc + : see if nice exists set nice d_nice eval $inlibc @@ -8999,7 +9054,7 @@ EOCP #ifdef I_UNISTD # include <unistd.h> /* Needed for NetBSD */ #endif -main() +int main() { char buf[128], abc[128]; char *b; @@ -9075,7 +9130,7 @@ EOCP #ifdef I_UNISTD # include <unistd.h> /* Needed for NetBSD */ #endif -main() +int main() { char buf[128], abc[128]; char *b; @@ -9153,7 +9208,7 @@ EOCP #ifdef I_UNISTD # include <unistd.h> /* Needed for NetBSD */ #endif -main() +int main() { char a = -1; char b = 0; @@ -9638,7 +9693,7 @@ if set sigaction val -f d_sigaction; eval $csym; $val; then #include <stdio.h> #include <sys/types.h> #include <signal.h> -main() +int main() { struct sigaction act, oact; } @@ -9665,7 +9720,7 @@ case "$d_sigsetjmp" in #include <setjmp.h> sigjmp_buf env; int set = 1; -main() +int main() { if (sigsetjmp(env,1)) exit(set); @@ -9755,7 +9810,7 @@ $cat >try.c <<EOP #include <stdio.h> #define FILE_ptr(fp) $stdio_ptr #define FILE_cnt(fp) $stdio_cnt -main() { +int main() { FILE *fp = fopen("try.c", "r"); char c = getc(fp); if ( @@ -9806,7 +9861,7 @@ $define) #include <stdio.h> #define FILE_base(fp) $stdio_base #define FILE_bufsiz(fp) $stdio_bufsiz -main() { +int main() { FILE *fp = fopen("try.c", "r"); char c = getc(fp); if ( @@ -9941,6 +9996,15 @@ eval $inlibc set tcsetpgrp d_tcsetpgrp eval $inlibc +: see if sys/types.h has to be included +set sys/types.h i_systypes +eval $inhdr + +: see if prototype for telldir is available +echo " " +set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h +eval $hasproto + : define an is-a-typedef? function typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@; case "$inclist" in @@ -10084,10 +10148,6 @@ eval $inhdr set sys/ndir.h i_sysndir eval $inhdr -: see if sys/types.h has to be included -set sys/types.h i_systypes -eval $inhdr - : see if closedir exists set closedir d_closedir eval $inlibc @@ -10213,7 +10273,7 @@ struct foobar { char foo; double bar; } try; -main() +int main() { printf("%d\n", (char *)&try.bar - (char *)&try.foo); } @@ -10248,7 +10308,7 @@ I'm now running the test program... EOM $cat >try.c <<'EOCP' #include <stdio.h> -main() +int main() { int i; union { @@ -10343,7 +10403,7 @@ $define) #include <sys/types.h> #include <stdio.h> #include <db.h> -main() +int main() { #ifdef DB_VERSION_MAJOR /* DB version >= 2 */ int Major, Minor, Patch ; @@ -10426,7 +10486,7 @@ size_t size; { } HASHINFO info; -main() +int main() { info.hash = hash_cb; } @@ -10471,7 +10531,7 @@ const DBT *key2; { } BTREEINFO info; -main() +int main() { info.prefix = prefix_cb; } @@ -10524,7 +10584,7 @@ sub() { #endif exit(0); } -main() { sub(); } +int main() { sub(); } EOCP if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then voidflags=$defvoidused @@ -10665,7 +10725,7 @@ echo "Checking to see how many bits your $randfunc() function produces..." >&4 #ifdef I_STDLIB # include <stdlib.h> #endif -main() +int main() { register int i; register unsigned long tmp; @@ -11077,7 +11137,7 @@ case "$ptrsize" in fi $cat >>try.c <<'EOCP' #include <stdio.h> -main() +int main() { printf("%d\n", sizeof(VOID_PTR)); exit(0); @@ -11104,7 +11164,7 @@ echo "Checking how to generate random libraries on your machine..." >&4 echo 'int bar1() { return bar2(); }' > bar1.c echo 'int bar2() { return 2; }' > bar2.c $cat > foo.c <<'EOP' -main() { printf("%d\n", bar1()); exit(0); } +int main() { printf("%d\n", bar1()); exit(0); } EOP $cc $ccflags -c bar1.c >/dev/null 2>&1 $cc $ccflags -c bar2.c >/dev/null 2>&1 @@ -11540,7 +11600,7 @@ $cat > ssize.c <<EOM #include <sys/types.h> #define Size_t $sizetype #define SSize_t $dflt -main() +int main() { if (sizeof(Size_t) == sizeof(SSize_t)) printf("$dflt\n"); @@ -11864,32 +11924,37 @@ $comm -13 ccsym.true ccsym.list >ccsym.own $comm -12 ccsym.true ccsym.list >ccsym.com $comm -23 ccsym.true ccsym.list >ccsym.cpp also='' -symbols='symbols' if $test -z ccsym.raw; then - echo "Your C compiler doesn't seem to define any symbol!" >&4 + echo "Your C compiler doesn't seem to define any symbols!" >&4 echo " " - echo "However, your C preprocessor defines the following ones:" + echo "However, your C preprocessor defines the following symbols:" $cat Cppsym.true + ccsymbols='' + cppsymbols=`$cat Cppsym.true` + cppccsymbols="$cppsymbols" else if $test -s ccsym.com; then echo "Your C compiler and pre-processor define these symbols:" $sed -e 's/\(.*\)=.*/\1/' ccsym.com also='also ' symbols='ones' + cppccsymbols=`$cat ccsym.com` $test "$silent" || sleep 1 fi if $test -s ccsym.cpp; then $test "$also" && echo " " - echo "Your C pre-processor ${also}defines the following $symbols:" + echo "Your C pre-processor ${also}defines the following symbols:" $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp also='further ' + cppsymbols=`$cat ccsym.cpp` $test "$silent" || sleep 1 fi if $test -s ccsym.own; then $test "$also" && echo " " - echo "Your C compiler ${also}defines the following cpp variables:" + echo "Your C compiler ${also}defines the following cpp symbols:" $sed -e 's/\(.*\)=1/\1/' ccsym.own $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true + ccsymbols=`$cat ccsym.own` $test "$silent" || sleep 1 fi fi @@ -12473,6 +12538,7 @@ cc='$cc' cccdlflags='$cccdlflags' ccdlflags='$ccdlflags' ccflags='$ccflags' +ccsymbols='$ccsymbols' cf_by='$cf_by' cf_email='$cf_email' cf_time='$cf_time' @@ -12487,11 +12553,13 @@ cp='$cp' cpio='$cpio' cpp='$cpp' cpp_stuff='$cpp_stuff' +cppccsymbols='$cppccsymbols' cppflags='$cppflags' cpplast='$cpplast' cppminus='$cppminus' cpprun='$cpprun' cppstdin='$cppstdin' +cppsymbols='$cppsymbols' cryptlib='$cryptlib' csh='$csh' d_Gconvert='$d_Gconvert' @@ -12617,6 +12685,7 @@ d_longlong='$d_longlong' d_lseek64='$d_lseek64' d_lstat64='$d_lstat64' d_lstat='$d_lstat' +d_madvise='$d_madvise' d_mblen='$d_mblen' d_mbstowcs='$d_mbstowcs' d_mbtowc='$d_mbtowc' @@ -12627,6 +12696,8 @@ d_memset='$d_memset' d_mkdir='$d_mkdir' d_mkfifo='$d_mkfifo' d_mktime='$d_mktime' +d_mmap='$d_mmap' +d_mprotect='$d_mprotect' d_msg='$d_msg' d_msg_ctrunc='$d_msg_ctrunc' d_msg_dontroute='$d_msg_dontroute' @@ -12638,6 +12709,8 @@ d_msgget='$d_msgget' d_msghdr_s='$d_msghdr_s' d_msgrcv='$d_msgrcv' d_msgsnd='$d_msgsnd' +d_msync='$d_msync' +d_munmap='$d_munmap' d_mymalloc='$d_mymalloc' d_nextkey64='$d_nextkey64' d_nice='$d_nice' @@ -12750,6 +12823,7 @@ d_tcgetpgrp='$d_tcgetpgrp' d_tcsetpgrp='$d_tcsetpgrp' d_telldir64='$d_telldir64' d_telldir='$d_telldir' +d_telldirproto='$d_telldirproto' d_time='$d_time' d_times='$d_times' d_tmpfile64='$d_tmpfile64' @@ -12847,6 +12921,7 @@ i_sysfile='$i_sysfile' i_sysfilio='$i_sysfilio' i_sysin='$i_sysin' i_sysioctl='$i_sysioctl' +i_sysmman='$i_sysmman' i_sysmount='$i_sysmount' i_sysndir='$i_sysndir' i_sysparam='$i_sysparam' @@ -12930,6 +13005,7 @@ medium='$medium' mips='$mips' mips_type='$mips_type' mkdir='$mkdir' +mmaptype='$mmaptype' models='$models' modetype='$modetype' more='$more' @@ -207,6 +207,7 @@ ext/DynaLoader/DynaLoader_pm.PL Dynamic Loader perl module ext/DynaLoader/Makefile.PL Dynamic Loader makefile writer ext/DynaLoader/README Dynamic Loader notes and intro ext/DynaLoader/dl_aix.xs AIX implementation +ext/DynaLoader/dl_beos.xs BeOS implementation ext/DynaLoader/dl_cygwin32.xs Cygwin32 implementation ext/DynaLoader/dl_dld.xs GNU dld style implementation ext/DynaLoader/dl_dlopen.xs BSD/SunOS4&5 dlopen() style implementation @@ -228,6 +229,7 @@ ext/GDBM_File/GDBM_File.pm GDBM extension Perl module ext/GDBM_File/GDBM_File.xs GDBM extension external subroutines ext/GDBM_File/Makefile.PL GDBM extension makefile writer ext/GDBM_File/typemap GDBM extension interface types +ext/GDBM_File/hints/sco.pl Hint for GDBM_File for named architecture ext/IO/ChangeLog IO perl module change log ext/IO/IO.pm Top-level interface to IO::* classes ext/IO/IO.xs IO extension external subroutines @@ -546,6 +548,7 @@ lib/File/Copy.pm Emulation of cp command lib/File/DosGlob.pm Win32 DOS-globbing module lib/File/Find.pm Routines to do a find lib/File/Path.pm Do things like `mkdir -p' and `rm -r' +lib/File/PathConvert.pm converting between file names lib/File/Spec.pm portable operations on file names lib/File/Spec/Mac.pm portable operations on Mac file names lib/File/Spec/OS2.pm portable operations on OS2 file names @@ -952,7 +955,7 @@ pod/perlmodinstall.pod Installing CPAN Modules pod/perlmodlib.pod Module policy info pod/perlobj.pod Object info pod/perlop.pod Operator info -pod/perlopentut.pod Object info +pod/perlopentut.pod open() tutorial pod/perlpod.pod Pod info pod/perlport.pod Portability guide pod/perlre.pod Regular expression info @@ -963,6 +966,7 @@ pod/perlsec.pod Security info pod/perlstyle.pod Style info pod/perlsub.pod Subroutine info pod/perlsyn.pod Syntax info +pod/perlthrtut.pod Threads tutorial pod/perltie.pod Tieing an object class into a simple variable pod/perltoc.pod Table of Contents info pod/perltoot.pod Tom's object-oriented tutorial diff --git a/Makefile.SH b/Makefile.SH index 22bb3357cd..30e5447cb4 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -46,10 +46,10 @@ true) os2*) # OS/2 doesn't need anything special for LD_LIBRARY_PATH. ldlibpth='' ;; - sunos*|freebsd[23]*) + sunos*) linklibperl="-lperl" ;; - netbsd*) + netbsd*|freebsd[234]*) linklibperl="-L. -lperl" ;; aix*) @@ -68,6 +68,8 @@ true) hpux10*|hpux11*) linklibperl="-L `pwd | sed 's/\/UU$//'` -Wl,+b$archlibexp/CORE -lperl" ;; + beos*) ldlibpth="LIBRARY_PATH=`pwd`:$LIBRARY_PATH" + ;; esac ;; *) pldlflags='' @@ -611,13 +613,13 @@ minitest: miniperl lib/re.pm # Please *don't* use this unless all tests pass. # If you want to report test failures, use "make nok" instead. ok: utilities - $(LBLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' + $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' okfile: utilities - $(LBLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok + $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok nok: utilities - $(LBLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' + $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' clist: $(c) echo $(c) | tr ' ' $(TRNL) >.clist diff --git a/Porting/config.sh b/Porting/config.sh index 0c461713e9..d6a19ed3bc 100644 --- a/Porting/config.sh +++ b/Porting/config.sh @@ -8,7 +8,7 @@ # Package name : perl5 # Source directory : . -# Configuration time: Thu Dec 3 15:05:16 EET 1998 +# Configuration time: Mon Feb 8 01:11:15 EET 1999 # Configured by : jhi # Target system : osf1 alpha.hut.fi v4.0 878 alpha @@ -54,7 +54,7 @@ ccdlflags=' ' ccflags='-pthread -std -D__LANGUAGE_C__' cf_by='jhi' cf_email='yourname@yourhost.yourplace.com' -cf_time='Thu Dec 3 15:05:16 EET 1998' +cf_time='Mon Feb 8 01:11:15 EET 1999' chgrp='' chmod='' chown='' @@ -142,6 +142,8 @@ d_fseeko='undef' d_fsetpos64='undef' d_fsetpos='define' d_fstat64='undef' +d_fstatfs='define' +d_fstatvfs='define' d_ftell64='undef' d_ftello64='undef' d_ftello='undef' @@ -194,6 +196,7 @@ d_longlong='define' d_lseek64='undef' d_lstat64='undef' d_lstat='define' +d_madvise='define' d_mblen='define' d_mbstowcs='define' d_mbtowc='define' @@ -204,6 +207,8 @@ d_memset='define' d_mkdir='define' d_mkfifo='define' d_mktime='define' +d_mmap='define' +d_mprotect='define' d_msg='define' d_msg_ctrunc='define' d_msg_dontroute='define' @@ -215,6 +220,8 @@ d_msgget='define' d_msghdr_s='define' d_msgrcv='define' d_msgsnd='define' +d_msync='define' +d_munmap='define' d_mymalloc='undef' d_nextkey64='undef' d_nice='define' @@ -299,6 +306,9 @@ d_socket='define' d_sockpair='define' d_stat64='undef' d_statblks='define' +d_statfs='define' +d_statfsflags='define' +d_statvfs='define' d_stdio_cnt_lval='define' d_stdio_ptr_lval='define' d_stdiobase='define' @@ -324,6 +334,7 @@ d_tcgetpgrp='define' d_tcsetpgrp='define' d_telldir64='undef' d_telldir='define' +d_telldirproto='define' d_time='define' d_times='define' d_tmpfile64='undef' @@ -401,6 +412,7 @@ i_machcthr='undef' i_malloc='define' i_math='define' i_memory='undef' +i_mntent='undef' i_ndbm='define' i_netdb='define' i_neterrno='undef' @@ -420,6 +432,8 @@ i_sysfile='define' i_sysfilio='undef' i_sysin='undef' i_sysioctl='define' +i_sysmman='define' +i_sysmount='define' i_sysndir='undef' i_sysparam='define' i_sysresrc='define' @@ -427,6 +441,7 @@ i_syssecrt='define' i_sysselct='define' i_syssockio='' i_sysstat='define' +i_sysstatvfs='define' i_systime='define' i_systimek='undef' i_systimes='define' @@ -454,6 +469,7 @@ installprivlib='/opt/perl/lib/5.00554' installscript='/opt/perl/bin' installsitearch='/opt/perl/lib/site_perl/5.00554/alpha-dec_osf-thread' installsitelib='/opt/perl/lib/site_perl/5.00554' +installusrbinperl='define' intsize='4' known_extensions='B DB_File Data/Dumper Devel/Peek Fcntl GDBM_File IO IPC/SysV NDBM_File ODBM_File Opcode POSIX SDBM_File Socket Thread attrs re' ksh='' @@ -500,6 +516,7 @@ medium='' mips='' mips_type='' mkdir='mkdir' +mmaptype='void *' models='none' modetype='mode_t' more='more' diff --git a/Porting/config_H b/Porting/config_H index c343f44d84..89e106d06f 100644 --- a/Porting/config_H +++ b/Porting/config_H @@ -17,7 +17,7 @@ /* * Package name : perl5 * Source directory : . - * Configuration time: Thu Dec 3 15:05:16 EET 1998 + * Configuration time: Mon Feb 8 01:11:15 EET 1999 * Configured by : jhi * Target system : osf1 alpha.hut.fi v4.0 878 alpha */ @@ -394,6 +394,18 @@ */ #define HAS_MKTIME /**/ +/* HAS_MSYNC: + * This symbol, if defined, indicates that the msync system call is + * available to synchronize a mapped file. + */ +#define HAS_MSYNC /**/ + +/* HAS_MUNMAP: + * This symbol, if defined, indicates that the munmap system call is + * available to unmap a region, usually mapped by mmap(). + */ +#define HAS_MUNMAP /**/ + /* HAS_NICE: * This symbol, if defined, indicates that the nice routine is * available. @@ -1641,6 +1653,18 @@ #define LONGLONGSIZE 8 /**/ #endif +/* HAS_MMAP: + * This symbol, if defined, indicates that the mmap system call is + * available to map a file into memory. + */ +/* Mmap_t: + * This symbol holds the return type of the mmap() system call + * (and simultaneously the type of the first argument). + * Usually set to 'void *' or 'cadd_t'. + */ +#define HAS_MMAP /**/ +#define Mmap_t void * /**/ + /* HAS_MSG: * This symbol, if defined, indicates that the entire msg*(2) library is * supported (IPC mechanism based on message queues). @@ -2024,6 +2048,18 @@ */ /*#define HAS_FTELLO / **/ +/* HAS_MADVISE: + * This symbol, if defined, indicates that the madvise system call is + * available to map a file into memory. + */ +#define HAS_MADVISE /**/ + +/* HAS_MPROTECT: + * This symbol, if defined, indicates that the mprotect system call is + * available to modify the access protection of a memory mapped file. + */ +#define HAS_MPROTECT /**/ + /* HAS_READV: * This symbol, if defined, indicates that the readv routine is * available to do gather reads. You will also need <sys/uio.h> @@ -2037,6 +2073,34 @@ */ /*#define USE_SFIO / **/ +/* HAS_FSTATFS: + * This symbol, if defined, indicates that the fstatfs routine is + * available to do stat filesystems of file descriptors. + */ +/* HAS_STRUCT_STATFS_FLAGS: + * This symbol, if defined, indicates that the struct statfs + * does have the f_flags member containing the mount flags of + * the filesystem holding the file. + * This kind of struct statfs is coming from sys/mount.h (BSD) + * and not from sys/statfs.h (SYSV). + */ +#define HAS_FSTATFS /**/ +#define HAS_STRUCT_STATFS_FLAGS /**/ + +/* HAS_FSTATVFS: + * This symbol, if defined, indicates that the fstatvfs routine is + * available to do stat filesystems of file descriptors. + */ +#define HAS_FSTATVFS /**/ + +/* HAS_TELLDIR_PROTO: + * This symbol, if defined, indicates that the system provides + * a prototype for the telldir() function. Otherwise, it is up + * to the program to supply one. A good guess is + * extern long telldir _((DIR*)); + */ +#define HAS_TELLDIR_PROTO /**/ + /* HAS_WRITEV: * This symbol, if defined, indicates that the writev routine is * available to do scatter writes. @@ -2110,12 +2174,42 @@ /*#define I_INTTYPES / **/ /*#define HAS_INT64_T / **/ +/* I_MNTENT: + * This symbol, if defined, indicates that <mntent.h> exists and + * should be included. + */ +/*#define I_MNTENT / **/ + /* I_POLL: * This symbol, if defined, indicates that <poll.h> exists and * should be included. */ #define I_POLL /**/ +/* I_SYS_MMAN: + * This symbol, if defined, indicates that <sys/mman.h> exists and + * should be included. + */ +#define I_SYS_MMAN /**/ + +/* I_SYS_MOUNT: + * This symbol, if defined, indicates that <sys/mount.h> exists and + * should be included. + */ +#define I_SYS_MOUNT /**/ + +/* I_SYS_STATVFS: + * This symbol, if defined, indicates that <sys/statvfs.h> exists and + * should be included. + */ +#define I_SYS_STATVFS /**/ + +/* INSTALL_USR_BIN_PERL: + * This symbol, if defined, indicates that Perl is to be installed + * also as /usr/bin/perl. + */ +#define INSTALL_USR_BIN_PERL /**/ + /* HAS_FSTAT64: * This symbol, if defined, indicates that the fstat64 routine is * available to stat files (fds) larger than 2 gigabytes. @@ -2294,6 +2388,12 @@ */ #define USE_64_BITS /**/ +/* MULTIPLICITY: + * This symbol, if defined, indicates that Perl should + * be built to use multiplicity. + */ +/*#define MULTIPLICITY / **/ + /* USE_PERLIO: * This symbol, if defined, indicates that the PerlIO abstraction should * be used throughout. If not defined, stdio should be @@ -2383,7 +2483,7 @@ * in joinable (aka undetached) state. NOTE: not defined * if pthread.h already has defined PTHREAD_CREATE_JOINABLE * (the new version of the constant). - * If defined, possible values are PTHREAD_CREATE_UNDETACHED + * If defined, known values are PTHREAD_CREATE_UNDETACHED * and __UNDETACHED. */ /*#define OLD_PTHREAD_CREATE_JOINABLE / **/ @@ -2413,12 +2513,6 @@ */ /*#define I_MACH_CTHREADS / **/ -/* MULTIPLICITY: - * This symbol, if defined, indicates that Perl should - * be built to use multiplicity. - */ -/*#define MULTIPLICITY / **/ - /* USE_THREADS: * This symbol, if defined, indicates that Perl should * be built to use threads. diff --git a/README.beos b/README.beos index 8c24393d6e..ccd9cbc6c6 100644 --- a/README.beos +++ b/README.beos @@ -1,75 +1,43 @@ -$Id: README.beos,v 1.2 1998/05/02 01:55:04 dogcow Exp dogcow $ - Notes on building perl under BeOS: GENERAL ISSUES -------------- -perl will almost compile straight out of the box with ./Configure -d, but -there are a few gotchas: - -Currently, you have to edit config.sh and remove SDBM_File from the -dynamic_ext= and extensions= lines. SDBM_File does not build properly -at this time. You need to run ./Configure -S after editing config.sh. - -In addition, with mwcc, after doing `make depend`, you need to edit -makefile and x2p/makefile and remove the lines that mention 'Bletch:'. -This is not necessary if you're using gnu cpp. +how to compile perl: -in short: -./Configure -d -remove SDBM_File from config.sh -./Configure -S -make depend -remove Bletch: from makefile and x2p/makefile -make +To compile perl under BeOS R4 x86: -Other than that, perl should build without problems. There are some -technical comments in hints/beos.sh. - -OS RELEASE-SPECIFIC NOTES -------------------------- +`./Configure -d` and hit ^C when it asks you if you want to make changes +to config.sh; -PR1/PPC: -See R3/X86. Same bug, different form. +edit config.sh and do the following: +change d_socket='define' to ='undef'; +remove SDBM, Errno, and Socket from dynamic_ext= and nonxs_ext=; -PR2/PPC: -Signals are somewhat unreliable, but they can work. Use caution. -The POSIX module is still somewhat buggy. +add '#define bool short' to x2p/a2p.h; -R3/X86: -Under R3 x86, there are some serious problems with the math routines -such that numbers are incorrectly printed. This causes problems with -modules that encode their version numbers - in particular, IO.pm will -probably not work properly. This should be fixed under R3.1. +../Configure -S; make; make install -The problem has manifested itself if you see something similar to the -following during the compile: +cd ~/config/lib; ln -s 5.00502/BeOS-BePC/CORE/libperl.so . +(substitute 5.00502 with the appropriate filename) -cc -c -I/usr/local/include -O -DVERSION=\"1.1504\" -DXS_VERSION=\"1.1499999999\" -fpic -I../.. IO.c -(lots of 9's are the indication of the problem.) - -In the meantime, you can use the following workaround: - -make perl -cd ext/IO -cc -c -I/usr/local/include -O -DVERSION=\"1.1504\" -DXS_VERSION=\"1.15\" -fpic -I../.. IO.c -cd .. -make - -(Substitute the correct numbers if IO has been updated.) +OS RELEASE-SPECIFIC NOTES +------------------------- +R4 x86 - dynamic loading finally works! Yay! This means you can compile +your own modules into perl. However, Sockets and Errno still don't work. +(Hopefully, sockets will at least work by R5, if not sooner.) -R3/PPC- -There's math problems, but of a different kind. In particular, -perl -e 'print (240000 - (3e4<<3))' gives a non-zero answer. -I'm looking into this. There is no workaround as yet. Hopefully, -this will be fixed in R3.1. +R4 PPC - I have not tested this. I rather severely doubt that dynamic +loading will work. (My BeBox is in pieces right now, following a nasty +disk crash.) You may have to disable dynamic loading to get the thing +to compile at all. (use `./Configure` without -d, and say 'no' to +'Build a shared libperl.so'.) CONTACT INFORMATION ------------------- If you have comments, problem reports, or even patches or bugfixes (gasp!) please email me. -1 May 1998 +28 Jan 1999 Tom Spindler -dogcow@merit.edu +dogcow@isi.net diff --git a/Todo-5.005 b/Todo-5.005 index 31cf632b1d..58959fab77 100644 --- a/Todo-5.005 +++ b/Todo-5.005 @@ -25,6 +25,22 @@ MULTIPLICITY support complete work on safe recursive interpreters, C<Perl->new()> revisit extra implicit arg that provides curthread/curinterp context +Configure + make configuring+building away from source directory work (VPATH et al) + _r support + cross-compilation configuring + mmap support + POSIX 1003.1 1996 Edition support + +Locales + locales across packages + decimal separator (3,1415927 is Europeanese for an approximation of pi) + +Regexen + POSIX [:foo:] character classes + ([=bar=] and [.zap.] would nice too but there's no API for them) + approximate matching + Reliable Signals alternate runops() for signal despatch figure out how to die() in delayed sighandler diff --git a/config_h.SH b/config_h.SH index b67f029969..7047dfaef3 100644 --- a/config_h.SH +++ b/config_h.SH @@ -408,6 +408,18 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- */ #$d_mktime HAS_MKTIME /**/ +/* HAS_MSYNC: + * This symbol, if defined, indicates that the msync system call is + * available to synchronize a mapped file. + */ +#$d_msync HAS_MSYNC /**/ + +/* HAS_MUNMAP: + * This symbol, if defined, indicates that the munmap system call is + * available to unmap a region, usually mapped by mmap(). + */ +#$d_munmap HAS_MUNMAP /**/ + /* HAS_NICE: * This symbol, if defined, indicates that the nice routine is * available. @@ -1655,6 +1667,18 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- #define LONGLONGSIZE $longlongsize /**/ #endif +/* HAS_MMAP: + * This symbol, if defined, indicates that the mmap system call is + * available to map a file into memory. + */ +/* Mmap_t: + * This symbol holds the return type of the mmap() system call + * (and simultaneously the type of the first argument). + * Usually set to 'void *' or 'cadd_t'. + */ +#$d_mmap HAS_MMAP /**/ +#define Mmap_t $mmaptype /**/ + /* HAS_MSG: * This symbol, if defined, indicates that the entire msg*(2) library is * supported (IPC mechanism based on message queues). @@ -2038,6 +2062,18 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- */ #$d_ftello HAS_FTELLO /**/ +/* HAS_MADVISE: + * This symbol, if defined, indicates that the madvise system call is + * available to map a file into memory. + */ +#$d_madvise HAS_MADVISE /**/ + +/* HAS_MPROTECT: + * This symbol, if defined, indicates that the mprotect system call is + * available to modify the access protection of a memory mapped file. + */ +#$d_mprotect HAS_MPROTECT /**/ + /* HAS_READV: * This symbol, if defined, indicates that the readv routine is * available to do gather reads. You will also need <sys/uio.h> @@ -2071,6 +2107,14 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- */ #$d_fstatvfs HAS_FSTATVFS /**/ +/* HAS_TELLDIR_PROTO: + * This symbol, if defined, indicates that the system provides + * a prototype for the telldir() function. Otherwise, it is up + * to the program to supply one. A good guess is + * extern long telldir _((DIR*)); + */ +#$d_telldirproto HAS_TELLDIR_PROTO /**/ + /* HAS_WRITEV: * This symbol, if defined, indicates that the writev routine is * available to do scatter writes. @@ -2156,6 +2200,12 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- */ #$i_poll I_POLL /**/ +/* I_SYS_MMAN: + * This symbol, if defined, indicates that <sys/mman.h> exists and + * should be included. + */ +#$i_sysmman I_SYS_MMAN /**/ + /* I_SYS_MOUNT: * This symbol, if defined, indicates that <sys/mount.h> exists and * should be included. diff --git a/eg/cgi/file_upload.cgi b/eg/cgi/file_upload.cgi index f6bbbe0b74..38f85479f7 100644 --- a/eg/cgi/file_upload.cgi +++ b/eg/cgi/file_upload.cgi @@ -1,5 +1,6 @@ #!/usr/local/bin/perl -w +use strict 'refs'; use lib '..'; use CGI qw(:standard); use CGI::Carp qw/fatalsToBrowser/; @@ -18,7 +19,7 @@ print h1("File Upload Example"), will count the number of lines, words, and characters in the file.'; -@types = ('count lines','count words','count characters'); +my @types = ('count lines','count words','count characters'); # Start a multipart form. print start_multipart_form(), @@ -31,9 +32,10 @@ print start_multipart_form(), endform; # Process the form if there is a file name entered -if ($file = param('filename')) { - $tmpfile=tmpFileName($file); - $mimetype = uploadInfo($file)->{'Content-Type'} || ''; +if (my $file = param('filename')) { + my %stats; + my $tmpfile=tmpFileName($file); + my $mimetype = uploadInfo($file)->{'Content-Type'} || ''; print hr(), h2($file), h3($tmpfile), diff --git a/eg/cgi/index.html b/eg/cgi/index.html index 75e2d30139..4125b28920 100644 --- a/eg/cgi/index.html +++ b/eg/cgi/index.html @@ -54,7 +54,8 @@ <li><a href="crash.txt">Look at its source code</a> </ul> -<EM>The Following Scripts only Work with Netscape 2.0 & Internet Explorer only!</EM> +<EM>The Following Scripts Work with Netscape Navigator 2.0 and higher, +or Internet Explorer 3.0 and higher</EM> <H2> Prompt for a file to upload and process it</H2> <UL> @@ -113,6 +114,6 @@ <ADDRESS>Lincoln D. Stein, lstein@genome.wi.mit.edu<br> <a href="/">Whitehead Institute/MIT Center for Genome Research</a></ADDRESS> <!-- hhmts start --> -Last modified: Tue May 19 22:16:43 EDT 1998 +Last modified: Tue Nov 24 18:07:15 MET 1998 <!-- hhmts end --> </BODY> </HTML> diff --git a/ext/DynaLoader/dl_beos.xs b/ext/DynaLoader/dl_beos.xs new file mode 100644 index 0000000000..515d187260 --- /dev/null +++ b/ext/DynaLoader/dl_beos.xs @@ -0,0 +1,115 @@ +/* + * dl_beos.xs, by Tom Spindler + * based on dl_dlopen.xs, by Paul Marquess + * $Id:$ + */ + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include <be/kernel/image.h> +#include <OS.h> +#include <stdlib.h> +#include <limits.h> + +#define dlerror() strerror(errno) + +#include "dlutils.c" /* SaveError() etc */ + +static void +dl_private_init() +{ + (void)dl_generic_private_init(); +} + +MODULE = DynaLoader PACKAGE = DynaLoader + +BOOT: + (void)dl_private_init(); + + +void * +dl_load_file(filename, flags=0) + char * filename + int flags + CODE: +{ image_id bogo; + char *path; + path = malloc(PATH_MAX); + if (*filename != '/') { + getcwd(path, PATH_MAX); + strcat(path, "/"); + strcat(path, filename); + } else { + strcpy(path, filename); + } + + DLDEBUG(1,PerlIO_printf(PerlIO_stderr(), "dl_load_file(%s,%x):\n", path, flags)); + bogo = load_add_on(path); + DLDEBUG(2,PerlIO_printf(PerlIO_stderr(), " libref=%lx\n", (unsigned long) RETVAL)); + ST(0) = sv_newmortal() ; + if (bogo < 0) { + SaveError("%s", strerror(bogo)); + fprintf(stderr, "load_add_on(%s) : %d (%s)\n", path, bogo, strerror(bogo)); + } else { + RETVAL = (void *) bogo; + sv_setiv( ST(0), (IV)RETVAL); + } + free(path); +} + +void * +dl_find_symbol(libhandle, symbolname) + void * libhandle + char * symbolname + CODE: + status_t retcode; + void *adr = 0; +#ifdef DLSYM_NEEDS_UNDERSCORE + symbolname = form("_%s", symbolname); +#endif + RETVAL = NULL; + DLDEBUG(2, PerlIO_printf(PerlIO_stderr(), + "dl_find_symbol(handle=%lx, symbol=%s)\n", + (unsigned long) libhandle, symbolname)); + retcode = get_image_symbol((image_id) libhandle, symbolname, + B_SYMBOL_TYPE_TEXT, (void **) &adr); + RETVAL = adr; + DLDEBUG(2, PerlIO_printf(PerlIO_stderr(), + " symbolref = %lx\n", (unsigned long) RETVAL)); + ST(0) = sv_newmortal() ; + if (RETVAL == NULL) { + SaveError("%s", strerror(retcode)) ; + fprintf(stderr, "retcode = %p (%s)\n", retcode, strerror(retcode)); + } else + sv_setiv( ST(0), (IV)RETVAL); + + +void +dl_undef_symbols() + PPCODE: + + + +# These functions should not need changing on any platform: + +void +dl_install_xsub(perl_name, symref, filename="$Package") + char * perl_name + void * symref + char * filename + CODE: + DLDEBUG(2,PerlIO_printf(PerlIO_stderr(), "dl_install_xsub(name=%s, symref=%lx)\n", + perl_name, (unsigned long) symref)); + ST(0)=sv_2mortal(newRV((SV*)newXS(perl_name, (void(*)_((CV *)))symref, filename))); + + +char * +dl_error() + CODE: + RETVAL = LastError ; + OUTPUT: + RETVAL + +# end. diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL index 3df9881eee..f312a6cfaa 100644 --- a/ext/Errno/Errno_pm.PL +++ b/ext/Errno/Errno_pm.PL @@ -31,7 +31,7 @@ sub process_file { } } else { unless(open(FH,"< $file")) { - # This file could be a temporay file created by cppstdin + # This file could be a temporary file created by cppstdin # so only warn under -w, and return warn "Cannot open '$file'" if $^W; return; @@ -44,6 +44,24 @@ sub process_file { close(FH); } +my $cppstdin; + +sub default_cpp { + unless (defined $cppstdin) { + use File::Spec; + $cppstdin = $Config{cppstdin}; + my $upup_cppstdin = File::Spec->catfile(File::Spec->updir, + File::Spec->updir, + "cppstdin"); + my $cppstdin_is_wrapper = + ($cppstdin eq 'cppstdin' + and -f $upup_cppstdin + and -x $upup_cppstdin); + $cppstdin = $upup_cppstdin if $cppstdin_is_wrapper; + } + return "$cppstdin $Config{cppflags} $Config{cppminus}"; +} + sub get_files { my %file = (); # VMS keeps its include files in system libraries (well, except for Gcc) @@ -74,7 +92,7 @@ sub get_files { open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or die "Cannot run '$Config{cpprun} $Config{cppflags} errno.c'"; } else { - my $cpp = "$Config{cppstdin} $Config{cppflags} $Config{cppminus}"; + my $cpp = default_cpp(); open(CPPO,"$cpp < errno.c |") or die "Cannot exec $cpp"; } @@ -106,6 +124,10 @@ sub get_files { sub write_errno_pm { my $err; + # quick sanity check + + die "No error definitions found" unless keys %err; + # create the CPP input open(CPPI,"> errno.c") or @@ -130,7 +152,7 @@ sub write_errno_pm { open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or die "Cannot run '$Config{cpprun} $Config{cppflags} errno.c'"; } else { - my $cpp = "$Config{cppstdin} $Config{cppflags} $Config{cppminus}"; + my $cpp = default_cpp(); open(CPPO,"$cpp < errno.c |") or die "Cannot exec $cpp"; } diff --git a/ext/GDBM_File/hints/sco.pl b/ext/GDBM_File/hints/sco.pl new file mode 100644 index 0000000000..5c74a77495 --- /dev/null +++ b/ext/GDBM_File/hints/sco.pl @@ -0,0 +1,2 @@ +# SCO OSR5 needs to link with libc.so again to have C<fsync> defined +$self->{LIBS} = ['-lgdbm -lc']; diff --git a/ext/IPC/SysV/SysV.xs b/ext/IPC/SysV/SysV.xs index e6c7555c68..06059186c6 100644 --- a/ext/IPC/SysV/SysV.xs +++ b/ext/IPC/SysV/SysV.xs @@ -15,7 +15,7 @@ # include <sys/sem.h> # endif # ifdef HAS_SHM -# if defined(PERL_SCO5) || defined(PERL_ISC) +# if defined(PERL_SCO) || defined(PERL_ISC) # include <sys/sysmacros.h> /* SHMLBA */ # endif # include <sys/shm.h> diff --git a/ext/POSIX/POSIX.pm b/ext/POSIX/POSIX.pm index 76455f70dd..84298cb69a 100644 --- a/ext/POSIX/POSIX.pm +++ b/ext/POSIX/POSIX.pm @@ -899,6 +899,10 @@ sub rmdir { CORE::rmdir($_[0]); } +sub setbuf { + redef "IO::Handle::setbuf()"; +} + sub setgid { usage "setgid(gid)" if @_ != 1; $( = $_[0]; @@ -909,6 +913,10 @@ sub setuid { $< = $_[0]; } +sub setvbuf { + redef "IO::Handle::setvbuf()"; +} + sub sleep { usage "sleep(seconds)" if @_ != 1; CORE::sleep($_[0]); diff --git a/ext/POSIX/POSIX.pod b/ext/POSIX/POSIX.pod index 7b21810567..6ad74b74b9 100644 --- a/ext/POSIX/POSIX.pod +++ b/ext/POSIX/POSIX.pod @@ -1019,7 +1019,11 @@ The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero. I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The year (C<year>) is given in years since 1900. I.e., the year 1995 is 95; the year 2001 is 101. Consult your system's C<strftime()> manpage for details -about these and the other arguments. The given arguments are made consistent +about these and the other arguments. +If you want your code to be portable, your format (C<fmt>) argument +should use only the conversion specifiers defined by the ANSI C +standard. These are C<aAbBcdHIjmMpSUwWxXyYZ%>. +The given arguments are made consistent by calling C<mktime()> before calling your system's C<strftime()> function. The string for Tuesday, December 12, 1995. diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index c948cc6fad..474a694298 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -3631,7 +3631,41 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) mytm.tm_isdst = isdst; (void) mktime(&mytm); len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm); - ST(0) = sv_2mortal(newSVpv(tmpbuf, len)); + /* + ** The following is needed to handle to the situation where + ** tmpbuf overflows. Basically we want to allocate a buffer + ** and try repeatedly. The reason why it is so complicated + ** is that getting a return value of 0 from strftime can indicate + ** one of the following: + ** 1. buffer overflowed, + ** 2. illegal conversion specifier, or + ** 3. the format string specifies nothing to be returned(not + ** an error). This could be because format is an empty string + ** or it specifies %p that yields an empty string in some locale. + ** If there is a better way to make it portable, go ahead by + ** all means. + */ + if ( ( len > 0 && len < sizeof(tmpbuf) ) + || ( len == 0 && strlen(fmt) == 0 ) ) { + ST(0) = sv_2mortal(newSVpv(tmpbuf, len)); + } else { + /* Possibly buf overflowed - try again with a bigger buf */ + int bufsize = strlen(fmt) + sizeof(tmpbuf); + char* buf = (char *) safemalloc(bufsize); + int buflen; + while( buf ) { + buflen = strftime(buf, bufsize, fmt, &mytm); + if ( buflen > 0 && buflen < bufsize ) break; + bufsize *= 2; + buf = (char *) saferealloc(buf, bufsize); + } + if ( buf ) { + ST(0) = sv_2mortal(newSVpv(buf, buflen)); + safefree(buf); + } else { + ST(0) = sv_2mortal(newSVpv(tmpbuf, len)); + } + } } void @@ -107,7 +107,7 @@ gv_init(GV *gv, HV *stash, char *name, STRLEN len, int multi) GvSTASH(gv) = (HV*)SvREFCNT_inc(stash); GvNAME(gv) = savepvn(name, len); GvNAMELEN(gv) = len; - if (multi) + if (multi || doproto) /* doproto means it _was_ mentioned */ GvMULTI_on(gv); if (doproto) { /* Replicate part of newSUB here. */ SvIOK_off(gv); diff --git a/hints/beos.sh b/hints/beos.sh index ab752769b6..8d76bc5146 100644 --- a/hints/beos.sh +++ b/hints/beos.sh @@ -1,11 +1,12 @@ # BeOS hints file # $Id: beos.sh,v 1.1 1998/02/16 03:51:45 dogcow Exp $ -if [ ! -f beos/nm ]; then mwcc -w all -o beos/nm beos/nm.c; fi +if [ ! -f beos/nm ]; then mwcc -w all -o beos/nm beos/nm.c 2>/dev/null; fi +# If this fails, that's all right - it's only for PPC. prefix="/boot/home/config" -cpp="mwcc -e" +#cpp="mwcc -e" libpth='/boot/beos/system/lib /boot/home/config/lib' usrinc='/boot/develop/headers/posix' @@ -37,9 +38,16 @@ d_syserrlst='undef' # the array syserrlst[] is useless for the most part. # large negative numbers really kind of suck in arrays. -#d_socket='undef' +d_socket='undef' +d_gethbyaddr='undef' +d_gethbyname='undef' +d_getsbyname='undef' + +ld='gcc' + # Sockets really don't work with the current version of perl and the # current BeOS sockets; I suspect that a new module a la GSAR's WIN32 port # will be required. +# Of course, this may also change with R5. export PATH="$PATH:$PWD/beos" diff --git a/hints/dos_djgpp.sh b/hints/dos_djgpp.sh index db09cbc6d9..7c59428c7e 100644 --- a/hints/dos_djgpp.sh +++ b/hints/dos_djgpp.sh @@ -63,4 +63,3 @@ $define|true|[yY]*) ;; esac EOCBU - diff --git a/hints/freebsd.sh b/hints/freebsd.sh index e341de4107..66f6ca02bf 100644 --- a/hints/freebsd.sh +++ b/hints/freebsd.sh @@ -108,10 +108,10 @@ case "$osvers" in lddlflags="-shared " else if [ -e /usr/lib/aout ]; then - libpth="/usr/lib/aout /usr/local/lib /usr/lib" - glibpth="/usr/lib/aout /usr/local/lib /usr/lib" - fi - lddlflags='-Bshareable' + libpth="/usr/lib/aout /usr/local/lib /usr/lib" + glibpth="/usr/lib/aout /usr/local/lib /usr/lib" + fi + lddlflags='-Bshareable' fi cccdlflags='-DPIC -fpic' ;; @@ -140,39 +140,82 @@ EOM signal_t='void' d_voidsig='define' +# set libperl.so.X.X for 2.2.X +case "$osvers" in +2.2*) + # unfortunately this code gets executed before + # the equivalent in the main Configure so we copy a little + # from Configure XXX Configure should be fixed. + if $test -r $src/patchlevel.h;then + patchlevel=`awk '/define[ ]+PATCHLEVEL/ {print $3}' $src/patchlevel.h` + subversion=`awk '/define[ ]+SUBVERSION/ {print $3}' $src/patchlevel.h` + else + patchlevel=0 + subversion=0 + fi + libperl="libperl.so.$patchlevel.$subversion" + unset patchlevel + unset subversion + ;; +esac + # This script UU/usethreads.cbu will get 'called-back' by Configure # after it has prompted the user for whether to use threads. cat > UU/usethreads.cbu <<'EOCBU' case "$usethreads" in $define|true|[yY]*) + lc_r=`/sbin/ldconfig -r|grep ':-lc_r'|awk '{print $NF}'` case "$osvers" in - 3.*|4.0*) ldflags="-pthread $ldflags" - ;; - 2.2*) if [ ! -r /usr/lib/libc_r ]; then - cat <<'EOM' >&4 -POSIX threads are not supported by default on FreeBSD $osvers. Follow the -instructions in 'man pthread' to build and install the needed libraries. + 2.2.8*|3.*|4.*) + if [ ! -r "$lc_r" ]; then + cat <<EOM >&4 +POSIX threads should be supported by FreeBSD $osvers -- +but your system is missing the shared libc_r. +(/sbin/ldconfig -r doesn't find any). + +Consider using the latest STABLE release. +EOM + exit 1 + fi + ldflags="-pthread $ldflags" + ;; + 2.2*) + cat <<EOM >&4 +POSIX threads are not supported well by FreeBSD $osvers. + +Please consider upgrading to at least FreeBSD 2.2.8, +or preferably to 3.something. + +(While 2.2.7 does have pthreads, it has some problems + with the combination of threads and pipes and therefore + many Perl tests will either hang or fail.) EOM - exit 1 - fi - set `echo X "$libswanted "| sed -e 's/ c / c_r /'` - shift - libswanted="$*" - # Configure will probably pick the wrong libc to use for nm - # scan. - # The safest quick-fix is just to not use nm at all. - usenm=false - ;; - *) cat <<'EOM' >&4 - -It is not known if FreeBSD $osvers supports POSIX threads or not. -Consider upgrading to the latest STABLE release. + exit 1 + ;; + *) cat <<EOM >&4 +I did not know that FreeBSD $osvers supports POSIX threads. +Feel free to tell perlbug@perl.com otherwise. EOM - exit 1 - ;; + exit 1 + ;; + esac + + set `echo X "$libswanted "| sed -e 's/ c / c_r /'` + shift + libswanted="$*" + # Configure will probably pick the wrong libc to use for nm scan. + # The safest quick-fix is just to not use nm at all... + usenm=false + + case "$osvers" in + 2.2.8*) + # ... but this does not apply for 2.2.8 - we know it's safe + libc="$lc_r" + usenm=true + ;; esac - ;; + + unset lc_r esac EOCBU - diff --git a/hints/irix_6.sh b/hints/irix_6.sh index cb2f5dd609..6a115b85bd 100644 --- a/hints/irix_6.sh +++ b/hints/irix_6.sh @@ -177,7 +177,7 @@ EOM 6.2) cat >&4 <<EOM IRIX 6.2 can have the POSIX threads. -However,the following IRIX patches (or their replacements) MUST be installed: +However, the following IRIX patches (or their replacements) MUST be installed: 1404 Irix 6.2 Posix 1003.1b man pages 1645 IRIX 6.2 & 6.3 POSIX header file updates 2000 Irix 6.2 Posix 1003.1b support modules diff --git a/hints/linux.sh b/hints/linux.sh index a49e004bbd..4764e9ea4b 100644 --- a/hints/linux.sh +++ b/hints/linux.sh @@ -208,13 +208,21 @@ fi # Shimpei Yamashita <shimpei@socrates.patnet.caltech.edu> # Message-Id: <33EF1634.B36B6500@pobox.com> # -# MkLinux (osname=linux,archname=ppc-linux), which differs slightly from other -# linuces, needs special flags passed in order for dynamic loading to work. +# The DR2 of MkLinux (osname=linux,archname=ppc-linux) may need +# special flags passed in order for dynamic loading to work. # instead of the recommended: +# # ccdlflags='-rdynamic' # # it should be: # ccdlflags='-Wl,-E' +# +# So if your DR2 (DR3 came out summer 1998, consider upgrading) +# has problems with dynamic loading, uncomment the +# following three lines, make distclean, and re-Configure: +#case "`uname -r | sed 's/^[0-9.-]*//'``arch`" in +#'osfmach3ppc') ccdlflags='-Wl,-E' ;; +#esac # This script UU/usethreads.cbu will get 'called-back' by Configure # after it has prompted the user for whether to use threads. diff --git a/hints/mpeix.sh b/hints/mpeix.sh index 4a32b77fa2..9ebb0bad1e 100644 --- a/hints/mpeix.sh +++ b/hints/mpeix.sh @@ -51,8 +51,8 @@ toke_cflags='ccflags="$ccflags -DARG_ZERO_IS_SCRIPT"' # Linking. # lddlflags='-b' -libs='-lbind -lsvipc -lsocket -lm -lc' -loclibpth='/usr/local/lib /usr/contrib/lib /BIND/PUB/lib' +libs='-lbind -lsyslog -lcurses -lsvipc -lsocket -lm -lc' +loclibpth='/usr/local/lib /usr/contrib/lib /BIND/PUB/lib /SYSLOG/PUB' # # External functions and data items. # diff --git a/hints/netbsd.sh b/hints/netbsd.sh index a8cc7dc708..a07d3726db 100644 --- a/hints/netbsd.sh +++ b/hints/netbsd.sh @@ -51,20 +51,18 @@ case "$osvers" in 0.9*|1.[012]*|1.3|1.3.1) d_setregid="$undef" d_setreuid="$undef" - d_setrgid="$undef" - d_setruid="$undef" ;; esac +# These are obsolete in any netbsd. +d_setrgid="$undef" +d_setruid="$undef" + # there's no problem with vfork. case "$usevfork" in '') usevfork=true ;; esac -# Avoid telldir prototype conflict in pp_sys.c (NetBSD uses const DIR *) -# Configure should test for this. Volunteers? -pp_sys_cflags='ccflags="$ccflags -DHAS_TELLDIR_PROTOTYPE"' - # Pre-empt the /usr/bin/perl question of installperl. installusrbinperl='n' diff --git a/hints/os2.sh b/hints/os2.sh index fe0c2d3ab5..5365522c5a 100644 --- a/hints/os2.sh +++ b/hints/os2.sh @@ -261,6 +261,21 @@ d_setprior='define' cp ./README.os2 ./pod/perlos2.pod +# This script UU/usethreads.cbu will get 'called-back' by Configure +# after it has prompted the user for whether to use threads. +cat > UU/usethreads.cbu <<'EOCBU' +case "$usethreads" in +$define|true|[yY]*) + ccflags="-Zmt $ccflags" + cppflags="-Zmt $cppflags" # Do we really need to set this? + aout_ccflags="-DUSE_THREADS $aout_ccflags" + aout_cppflags="-DUSE_THREADS $aout_cppflags" + aout_lddlflags="-Zmt $aout_lddlflags" + aout_ldflags="-Zmt $aout_ldflags" + ;; +esac +EOCBU + # Now install the external modules. We are in the ./hints directory. cd ./os2/OS2 @@ -289,20 +304,5 @@ for xxx in * ; do fi done -# This script UU/usethreads.cbu will get 'called-back' by Configure -# after it has prompted the user for whether to use threads. -cat > UU/usethreads.cbu <<'EOCBU' -case "$usethreads" in -$define|true|[yY]*) - ccflags="-Zmt $ccflags" - cppflags="-Zmt $cppflags" # Do we really need to set this? - aout_ccflags="-DUSE_THREADS $aout_ccflags" - aout_cppflags="-DUSE_THREADS $aout_cppflags" - aout_lddlflags="-Zmt $aout_lddlflags" - aout_ldflags="-Zmt $aout_ldflags" - ;; -esac -EOCBU - # Now go back cd ../.. diff --git a/hints/sco.sh b/hints/sco.sh index 1323cab39c..eb598452a1 100644 --- a/hints/sco.sh +++ b/hints/sco.sh @@ -1,42 +1,188 @@ # sco.sh # Courtesy of Joel Rosi-Schwartz <j.schwartz@agonet.it> - +############################################################### # Additional SCO version info from # Peter Wolfe <wolfe@teloseng.com> -# Last revised # Fri Jul 19 14:54:25 EDT 1996 # and again Tue Sep 29 16:37:25 EDT 1998 # by Andy Dougherty <doughera@lafayette.edu> - +# Mostly rewritten on +# Tue Jan 19 23:00:00 CET 1999 +# by Francois Desarmenien <desar@club-internet.fr> +############################################################### +# +# To use cc, use sh Configure # To use gcc, use sh Configure -Dcc=gcc -# To use icc, use sh Configure -Dcc=icc +# +# Default on 3.2v4 is to use static link (dynamic loading unsupported). +# Default on 3.2v5 is to use dynamic loading. +# To use static linkink instead, use to sh Configure -Dusedl=n +# +# Warning: - to use dynamic loading with gcc, you need gcc 2.8.0 or later +# ******** - to compile with older releases of gcc, use Configure -Dusedl=n +# or it wont compile properly +# +############################################################### +# NOTES: +# ----- +# +# I Have removed inclusion of ODBM_File for OSR5 +# because it core dumps and make tests fails. +# +# Support for icc compiler has been removed, because it 'breaks' +# a lot of code :-( +# +# It's *always* a good idea to first make a static link to be sure to +# have all symbols resolved with the current choice of libraries, since +# with dynamic linking, unresolved symbols are allowed an will be detected +# only at runtime (when you try to load the module or worse, when you call +# the symbol) +# +# The best choice of compiler on OSR 5 (3.2v5.*) seems to be gcc >= 2.8.0: +# -You cannot optimize with genuine sco cc (miniperl core dumps), +# so Perl is faster if compiled with gcc. +# -Even optimized for speed, gcc generated code is smaller (!!!) +# -gcc is free +# -I use ld to link which is distributed with the core OS distribution, so you +# don't need to buy the developement kit, just find someone kind enough to +# give you a binary release of gcc. +# +# +############################################################### # figure out what SCO version we are. The output of uname -X is # something like: # System = SCO_SV # Node = xxxxx # Release = 3.2v5.0.0 # KernelID = 95/08/08 -# Machine = Pentium +# Machine = Pentium # BusType = ISA # Serial = xxxxx # Users = 5-user # OEM# = 0 # Origin# = 1 -# NumCPU = 1 +# NumCPU = 1 # Use /bin/uname (because GNU uname may be first in $PATH and # it does not support -X) to figure out what SCO version we are: -case `/bin/uname -X | egrep '^Release'` in -*3.2v4.*) scorls=3 ;; # I don't know why this is 3 instead of 4. -*3.2v5.*) scorls=5 ;; -*) scorls=5 ;; # Hope the future will be compatible. +# Matching '^Release' is broken by locale setting: +# matching '3.2v' should be enough -- FD +case `/bin/uname -X | egrep '3\.2v'` in +*3.2v4.*) scorls=3 ;; # OSR 3 +*3.2v5.*) scorls=5 ;; # OSR 5 +*) + # Future of SCO OSR is SCO UnixWare: there should not be new OSR releases + echo "************************************************************" >&4 + echo "" >&4 + echo " sco.sh hints file only supports:" >&4 + echo "" >&4 + echo " - SCO Unix 3.2v4.x (OSR 3)" >&4 + echo " - SCO Unix 3.2v5.x (OSR 5)" >&4 + echo "" >&4 + echo "" >&4 + echo " For UnixWare, use svr4.sh hints instead" >&4 + echo "" >&4 + echo "***********************************************************" >&4 + exit +;; esac +############################################################### +# Common fixes for all compilers an releases: + +############################################################### +# What is true for SCO5 is true for SCO3 too today, so let's have a single +# symbol for both +ccflags="-U M_XENIX -D PERL_SCO" + +############################################################### +# Compilers options section: +if test "$scorls" = "3" +then + dlext='' + case "$cc" in + gcc) optimize='-O2' ;; + *) ccflags="$ccflags -W0 -quiet" + optimize='-O' ;; + esac +else + ############################################################### + # Need this in release 5 because of changed fpu exeption rules + ccflags="$ccflags -D PERL_SCO5" + + ############################################################### + # In Release 5, always compile ELF objects + case "$cc" in + gcc) + ccflags="$ccflags -melf" + optimize='-O2' + ;; + *) + ccflags="$ccflags -w0 -belf" + optimize='-O0' + ;; + esac + ############################################################### + # Dynamic loading section: + # + # We use ld to build shared libraries as it is always available + # and seems to work better than GNU's one on SCO + # + # ccdlflags : must tell the linker to export all global symbols + # cccdlflags: must tell the compiler to generate relocatable code + # lddlflags : must tell the linker to output a shared library + # + # /usr/local/lib is added for convenience, since 'foreign' libraries + # are usually put there in sco + # + if test "$usedl" != "n"; then + ld='ld' + case "$cc" in + gcc) + ccdlflags='-Xlinker -Bexport -L/usr/local/lib' + cccdlflags='-fpic' + lddlflags='-G -L/usr/local/lib' + ;; + *) + ccdlflags='-Bexport -L/usr/local/lib' + cccdlflags='-Kpic' + lddlflags='-G -L/usr/local/lib' + ;; + esac + + ############################################################### + # Use dynamic loading + usedl='define' + dlext='so' + dlsrc='dl_dlopen.xs' + + ############################################################### + # Force to define those symbols, as they are #defines and not + # catched by Configure, and they are useful + d_dlopen='define' + d_dlerror='define' + fi +fi + + +############################################################### +# Various hints, common to all releases, to have it work better: + +############################################################### +# We need to remove libdl, as libdl.so exists, but ld complains +# it can't find libdl.a ! Bug or feature ? :-) +libswanted=`echo " $libswanted " | sed -e 's/ dl / /'` +set X $libswanted +shift +libswanted="$*" + +############################################################### # Try to use libintl.a since it has strcoll and strxfrm libswanted="intl $libswanted" + +############################################################### # Try to use libdbm.nfs.a since it has dbmclose. -# if test -f /usr/lib/libdbm.nfs.a ; then libswanted=`echo "dbm.nfs $libswanted " | sed -e 's/ dbm / /'` set X $libswanted @@ -44,64 +190,19 @@ if test -f /usr/lib/libdbm.nfs.a ; then libswanted="$*" fi +############################################################### +# We disable ODBM_File if OSR5 because it's mostly broken +# but keep it for ODT3 as it seems to work. +if test "$scorls" = "5"; then + i_dbm='undef' +fi + +############################################################### # We don't want Xenix cross-development libraries glibpth=`echo $glibpth | sed -e 's! /usr/lib/386 ! !' -e 's! /lib/386 ! !'` xlibpth='' -# Common fix for all compilers. -ccflags="$ccflags -U M_XENIX" - -# Set flags for optimization and warning levels. -case "$cc" in -*gcc*) case "$optimize" in - '') optimize='-O2' ;; - esac - ;; -scocc) ;; # Anybody know anything about this? -*) # icc or cc -- only relevant difference is safe level of - # optimization. Apparently. - case $scorls in - 3) ccflags="$ccflags -W0 -quiet" ;; - *) ccflags="$ccflags -w0 -DPERL_SCO5" ;; - esac - case "$optimize" in - '') case "$cc" in - icc) optimize="-O1" ;; - *) optimize="-O0" ;; - esac - ;; - esac - ;; -esac - -# DYNAMIC LOADING: Dynamic loading won't work with scorls=3. -# It ought to work with Release = 3.2v5.0.0 or later. -if test "$scorls" = "3" -a "X$usedl" = "X"; then - usedl=$undef -else - # I do not know exactly which of these are essential, - # but this set has been recommended. --AD - # These ought to be patched back into metaconfig, but the - # current metaconfig units don't touch ccflags. - # Unfortunately, the default on SCO is to produce COFF output, but - # ELF is needed for dynamic loading, and the cc man page recommends - # "Always specify option -b elf if ELF and COFF files might be mixed." - # Therefore, we'll compile everything with -b elf. - case "$cc" in - *gcc*) ;; - *) ccflags="$ccflags -b elf" ;; - esac - cccdlflags=none - ccdlflags='-W l,-Bexport' - lddlflags="$lddlflags -b elf -G" - ldflags="$ldflags -b elf -W l,-Bexport" - dlext='so' - dlsrc='dl_dlopen.xs' - d_dlerror='define' - d_dlopen='define' - usedl='define' -fi - +############################################################### # I have received one report that nm extraction doesn't work if you're # using the scocc compiler. This system had the following 'myconfig' # uname='xxx xxx 3.2 2 i386 ' @@ -111,15 +212,22 @@ case "$usenm" in '') usenm='false' ;; esac +############################################################### # If you want to use nm, you'll probably have to use nm -p. The # following does that for you: nm_opt='-p' +############################################################### # I have received one report that you can't include utime.h in # pp_sys.c. Uncomment the following line if that happens to you: # i_utime=undef +############################################################### # Perl 5.003_05 and later try to include both <time.h> and <sys/select.h> # in pp_sys.c, but that fails due to a redefinition of struct timeval. # This will generate a WHOA THERE. Accept the default. i_sysselct=$undef + + +############################################################### +#END of hint file diff --git a/installhtml b/installhtml index 053858d790..ad7e66e70a 100755 --- a/installhtml +++ b/installhtml @@ -576,6 +576,7 @@ sub runpod2html { #system("./pod2html", Pod::Html'pod2html( #Pod::Html'pod2html($pod2html, + "--htmldir=$htmldir", "--htmlroot=$htmlroot", "--podpath=".join(":", @podpath), "--podroot=$podroot", "--netscape", diff --git a/installperl b/installperl index 7a555fbe27..979000c633 100755 --- a/installperl +++ b/installperl @@ -256,7 +256,8 @@ if (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VM my $mainperl_is_instperl = 0; -if (!$versiononly && !$nonono && !$Is_W32 && !$Is_VMS && -t STDIN && -t STDERR +if ($Config{installusrbinperl} eq 'define' && + !$versiononly && !$nonono && !$Is_W32 && !$Is_VMS && -t STDIN && -t STDERR && -w $mainperldir && ! samepath($mainperldir, $installbin)) { my($usrbinperl) = "$mainperldir/$perl$exe_ext"; my($instperl) = "$installbin/$perl$exe_ext"; diff --git a/lib/CGI.pm b/lib/CGI.pm index 9fe8f40d6b..f5615f268b 100644 --- a/lib/CGI.pm +++ b/lib/CGI.pm @@ -15,11 +15,10 @@ require 5.004; # listing the modifications you have made. # The most recent version and complete docs are available at: -# http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html -# ftp://ftp-genome.wi.mit.edu/pub/software/WWW/ +# http://stein.cshl.org/WWW/software/CGI/ -$CGI::revision = '$Id: CGI.pm,v 1.32 1998/05/28 21:55:43 lstein Exp lstein $'; -$CGI::VERSION='2.42'; +$CGI::revision = '$Id: CGI.pm,v 1.5 1998/12/06 10:19:48 lstein Exp $'; +$CGI::VERSION='2.46'; # HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES. # UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING. @@ -59,6 +58,12 @@ sub initialize_globals { # Change this to 1 to disable uploads entirely: $DISABLE_UPLOADS = 0; + # Change this to 1 to suppress redundant HTTP headers + $HEADERS_ONCE = 0; + + # separate the name=value pairs by semicolons rather than ampersands + $USE_PARAM_SEMICOLONS = 0; + # Other globals that you shouldn't worry about. undef $Q; $BEEN_THERE = 0; @@ -116,8 +121,9 @@ $SL = { $IIS++ if defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTWARE'}=~/IIS/; # Turn on special checking for Doug MacEachern's modperl -if (defined($ENV{'GATEWAY_INTERFACE'}) && - ($MOD_PERL = $ENV{'GATEWAY_INTERFACE'} =~ /^CGI-Perl\//)) +if (exists $ENV{'GATEWAY_INTERFACE'} + && + ($MOD_PERL = $ENV{'GATEWAY_INTERFACE'} =~ /^CGI-Perl/)) { $| = 1; require Apache; @@ -151,20 +157,21 @@ if ($needs_binmode) { tt u i b blockquote pre img a address cite samp dfn html head base body Link nextid title meta kbd start_html end_html input Select option comment/], - ':html3'=>[qw/div table caption th td TR Tr sup sub strike applet Param + ':html3'=>[qw/div table caption th td TR Tr sup Sub strike applet Param embed basefont style span layer ilayer font frameset frame script small big/], ':netscape'=>[qw/blink fontsize center/], ':form'=>[qw/textfield textarea filefield password_field hidden checkbox checkbox_group submit reset defaults radio_group popup_menu button autoEscape scrolling_list image_button start_form end_form startform endform - start_multipart_form isindex tmpFileName uploadInfo URL_ENCODED MULTIPART/], - ':cgi'=>[qw/param path_info path_translated url self_url script_name cookie dump - raw_cookie request_method query_string accept user_agent remote_host + start_multipart_form end_multipart_form isindex tmpFileName uploadInfo URL_ENCODED MULTIPART/], + ':cgi'=>[qw/param path_info path_translated url self_url script_name cookie Dump + raw_cookie request_method query_string Accept user_agent remote_host remote_addr referer server_name server_software server_port server_protocol virtual_host remote_ident auth_type http use_named_parameters save_parameters restore_parameters param_fetch remote_user user_name header redirect import_names put Delete Delete_all url_param/], ':ssl' => [qw/https/], + ':imagemap' => [qw/Area Map/], ':cgi-lib' => [qw/ReadParse PrintHeader HtmlTop HtmlBot SplitParam/], ':html' => [qw/:html2 :html3 :netscape/], ':standard' => [qw/:html2 :html3 :form :cgi/], @@ -206,6 +213,7 @@ sub compile { sub expand_tags { my($tag) = @_; + return ("start_$1","end_$1") if $tag=~/^(?:\*|start_|end_)(.+)/; my(@r); return ($tag) unless $EXPORT_TAGS{$tag}; foreach (@{$EXPORT_TAGS{$tag}}) { @@ -273,7 +281,7 @@ sub param { $name = $p[0]; } - return () unless defined($name) && $self->{$name}; + return unless defined($name) && $self->{$name}; return wantarray ? @{$self->{$name}} : $self->{$name}->[0]; } @@ -315,6 +323,7 @@ sub self_or_CGI { sub init { my($self,$initializer) = @_; my($query_string,$meth,$content_length,$fh,@lines) = ('','','',''); + local($/) = "\n"; # if we get called more than once, we want to initialize # ourselves from the original query (which may be gone @@ -341,7 +350,7 @@ sub init { && $ENV{'CONTENT_TYPE'}=~m|^multipart/form-data| && !defined($initializer) ) { - my($boundary) = $ENV{'CONTENT_TYPE'} =~ /boundary=\"?([^\";]+)\"?/; + my($boundary) = $ENV{'CONTENT_TYPE'} =~ /boundary=\"?([^\";,]+)\"?/; $self->read_multipart($boundary,$content_length); last METHOD; } @@ -496,7 +505,7 @@ sub save_request { sub parse_params { my($self,$tosplit) = @_; - my(@pairs) = split('&',$tosplit); + my(@pairs) = split(/[&;]/,$tosplit); my($param,$value); foreach (@pairs) { ($param,$value) = split('=',$_,2); @@ -526,11 +535,9 @@ sub binmode { } sub _make_tag_func { - my $tagname = shift; - return qq{ + my ($self,$tagname) = @_; + my $func = qq# sub $tagname { - # handle various cases in which we're called - # most of this bizarre stuff is to avoid -w errors shift if \$_[0] && (!ref(\$_[0]) && \$_[0] eq \$CGI::DefaultClass) || (ref(\$_[0]) && @@ -542,12 +549,20 @@ sub _make_tag_func { my(\@attr) = make_attributes( '',shift() ); \$attr = " \@attr" if \@attr; } + #; + if ($tagname=~/start_(\w+)/i) { + $func .= qq! return "<\U$1\E\$attr>";} !; + } elsif ($tagname=~/end_(\w+)/i) { + $func .= qq! return "<\U/$1\E>"; } !; + } else { + $func .= qq# my(\$tag,\$untag) = ("\U<$tagname\E\$attr>","\U</$tagname>\E"); return \$tag unless \@_; my \@result = map { "\$tag\$_\$untag" } (ref(\$_[0]) eq 'ARRAY') ? \@{\$_[0]} : "\@_"; return "\@result"; - } -} + }#; + } +return $func; } sub AUTOLOAD { @@ -619,12 +634,13 @@ sub _compile { $code = "sub $AUTOLOAD { }" if (!$code and $func_name eq 'DESTROY'); if (!$code) { + (my $base = $func_name) =~ s/^(start_|end_)//i; if ($EXPORT{':any'} || $EXPORT{'-any'} || - $EXPORT{$func_name} || + $EXPORT{$base} || (%EXPORT_OK || grep(++$EXPORT_OK{$_},&expand_tags(':html'))) - && $EXPORT_OK{$func_name}) { - $code = _make_tag_func($func_name); + && $EXPORT_OK{$base}) { + $code = $CGI::DefaultClass->_make_tag_func($func_name); } } die "Undefined subroutine $AUTOLOAD\n" unless $code; @@ -644,14 +660,15 @@ sub _setup_symbols { my $self = shift; my $compile = 0; foreach (@_) { - $NPH++, next if /^[:-]nph$/; - $NO_DEBUG++, next if /^[:-]no_?[Dd]ebug$/; - $PRIVATE_TEMPFILES++, next if /^[:-]private_tempfiles$/; - $EXPORT{$_}++, next if /^[:-]any$/; - $compile++, next if /^[:-]compile$/; + $HEADERS_ONCE++, next if /^[:-]unique_headers$/; + $NPH++, next if /^[:-]nph$/; + $NO_DEBUG++, next if /^[:-]no_?[Dd]ebug$/; + $USE_PARAM_SEMICOLONS++, next if /^[:-]newstyle_urls$/; + $PRIVATE_TEMPFILES++, next if /^[:-]private_tempfiles$/; + $EXPORT{$_}++, next if /^[:-]any$/; + $compile++, next if /^[:-]compile$/; - # This is probably extremely evil code -- to be deleted - # some day. + # This is probably extremely evil code -- to be deleted some day. if (/^[-]autoload$/) { my($pkg) = caller(1); *{"${pkg}::AUTOLOAD"} = sub { @@ -978,7 +995,7 @@ sub url_param { unless (exists($self->{'.url_param'})) { $self->{'.url_param'}={}; # empty hash if ($ENV{QUERY_STRING} =~ /=/) { - my(@pairs) = split('&',$ENV{QUERY_STRING}); + my(@pairs) = split(/[&;]/,$ENV{QUERY_STRING}); my($param,$value); foreach (@pairs) { ($param,$value) = split('=',$_,2); @@ -1043,6 +1060,7 @@ sub save { $filehandle = to_filehandle($filehandle); my($param); local($,) = ''; # set print field separator back to a sane value + local($\) = ''; # set output line separator to a sane value foreach $param ($self->param) { my($escaped_param) = escape($param); my($value); @@ -1141,18 +1159,21 @@ sub header { my($self,@p) = self_or_default(@_); my(@header); + return undef if $self->{'.header_printed'}++ and $HEADERS_ONCE; + my($type,$status,$cookie,$target,$expires,$nph,@other) = - $self->rearrange([TYPE,STATUS,[COOKIE,COOKIES],TARGET,EXPIRES,NPH],@p); + $self->rearrange([['TYPE','CONTENT_TYPE','CONTENT-TYPE'], + STATUS,[COOKIE,COOKIES],TARGET,EXPIRES,NPH],@p); $nph ||= $NPH; # rearrange() was designed for the HTML portion, so we # need to fix it up a little. foreach (@other) { - next unless my($header,$value) = /([^\s=]+)=\"?([^\"]+)\"?/; + next unless my($header,$value) = /([^\s=]+)=\"?(.+?)\"?$/; ($_ = $header) =~ s/^(\w)(.*)/$1 . lc ($2) . ": $value"/e; } - $type = $type || 'text/html'; + $type ||= 'text/html' unless defined($type); # Maybe future compatibility. Maybe not. my $protocol = $ENV{SERVER_PROTOCOL} || 'HTTP/1.0'; @@ -1164,7 +1185,8 @@ sub header { if ($cookie) { my(@cookie) = ref($cookie) && ref($cookie) eq 'ARRAY' ? @{$cookie} : $cookie; foreach (@cookie) { - push(@header,"Set-Cookie: " . (UNIVERSAL::isa($_,'CGI::Cookie') ? $_->as_string : $_)); + my $cs = UNIVERSAL::isa($_,'CGI::Cookie') ? $_->as_string : $_; + push(@header,"Set-Cookie: $cs") if $cs ne ''; } } # if the user indicates an expiration time, then we need @@ -1175,7 +1197,7 @@ sub header { push(@header,"Date: " . expires(0,'http')) if $expires || $cookie; push(@header,"Pragma: no-cache") if $self->cache(); push(@header,@other); - push(@header,"Content-Type: $type"); + push(@header,"Content-Type: $type") if $type ne ''; my $header = join($CRLF,@header)."${CRLF}${CRLF}"; if ($MOD_PERL and not $nph) { @@ -1221,6 +1243,7 @@ sub redirect { '-nph'=>$nph); unshift(@o,'-Target'=>$target) if $target; unshift(@o,'-Cookie'=>$cookie) if $cookie; + unshift(@o,'-Type'=>''); return $self->header(@o); } END_OF_FUNC @@ -1407,6 +1430,11 @@ sub start_form { } END_OF_FUNC +'end_multipart_form' => <<'END_OF_FUNC', +sub end_multipart_form { + &endform; +} +END_OF_FUNC #### Method: start_multipart_form # synonym for startform @@ -1459,8 +1487,11 @@ sub _textfield { $name = defined($name) ? $self->escapeHTML($name) : ''; my($s) = defined($size) ? qq/ SIZE=$size/ : ''; my($m) = defined($maxlength) ? qq/ MAXLENGTH=$maxlength/ : ''; - my($other) = @other ? " @other" : ''; - return qq/<INPUT TYPE="$tag" NAME="$name" VALUE="$current"$s$m$other>/; + my($other) = @other ? " @other" : ''; + # this entered at cristy's request to fix problems with file upload fields + # and WebTV -- not sure it won't break stuff + my($value) = $current ne '' ? qq(VALUE="$current") : ''; + return qq/<INPUT TYPE="$tag" NAME="$name" $value$s$m$other>/; } END_OF_FUNC @@ -1787,12 +1818,17 @@ END_OF_FUNC sub unescapeHTML { my $string = ref($_[0]) ? $_[1] : $_[0]; return undef unless defined($string); - $string=~s/&/&/ig; - $string=~s/"/\"/ig; - $string=~s/>/>/ig; - $string=~s/</</ig; - $string=~s/&#(\d+);/chr($1)/eg; - $string=~s/&#[xX]([0-9a-fA-F]);/chr(hex($1))/eg; + # thanks to Randal Schwartz for the correct solution to this one + $string=~ s[&(.*?);]{ + local $_ = $1; + /^amp$/i ? "&" : + /^quot$/i ? '"' : + /^gt$/i ? ">" : + /^lt$/i ? "<" : + /^#(\d+)$/ ? chr($1) : + /^#x([0-9a-f]+)$/i ? chr(hex($1)) : + $_ + }gex; return $string; } END_OF_FUNC @@ -1867,14 +1903,13 @@ sub radio_group { } else { $checked = $default; } - # If no check array is specified, check the first by default - $checked = $values->[0] unless defined($checked) && $checked ne ''; - $name=$self->escapeHTML($name); - my(@elements,@values); - @values = $self->_set_values_and_labels($values,\$labels,$name); + # If no check array is specified, check the first by default + $checked = $values[0] unless defined($checked) && $checked ne ''; + $name=$self->escapeHTML($name); + my($other) = @other ? " @other" : ''; foreach (@values) { my($checkit) = $checked eq $_ ? ' CHECKED' : ''; @@ -2321,7 +2356,7 @@ sub query_string { push(@pairs,"$eparam=$value"); } } - return join("&",@pairs); + return join($USE_PARAM_SEMICOLONS ? ';' : '&',@pairs); } END_OF_FUNC @@ -2337,8 +2372,8 @@ END_OF_FUNC # declares a quantitative score for it. # This handles MIME type globs correctly. #### -'accept' => <<'END_OF_FUNC', -sub accept { +'Accept' => <<'END_OF_FUNC', +sub Accept { my($self,$search) = self_or_CGI(@_); my(%prefs,$type,$pref,$pat); @@ -2758,6 +2793,7 @@ sub read_multipart { chmod 0600,$tmp; # only the owner can tamper with it my ($data); + local($\) = ''; while (defined($data = $buffer->read)) { print $filehandle $data; } @@ -2841,10 +2877,18 @@ $AUTOLOADED_ROUTINES=<<'END_OF_AUTOLOAD'; 'asString' => <<'END_OF_FUNC', sub asString { my $self = shift; - my $i = $$self; - $i=~ s/^\*(\w+::)+//; # get rid of package name + # get rid of package name + (my $i = $$self) =~ s/^\*(\w+::)+//; $i =~ s/\\(.)/$1/g; return $i; +# BEGIN DEAD CODE +# This was an extremely clever patch that allowed "use strict refs". +# Unfortunately it relied on another bug that caused leaky file descriptors. +# The underlying bug has been fixed, so this no longer works. However +# "strict refs" still works for some reason. +# my $self = shift; +# return ${*{$self}{SCALAR}}; +# END DEAD CODE } END_OF_FUNC @@ -2861,11 +2905,12 @@ sub new { my($pack,$name,$file,$delete) = @_; require Fcntl unless defined &Fcntl::O_RDWR; ++$FH; - *{$FH} = quotemeta($name); - sysopen($FH,$file,Fcntl::O_RDWR()|Fcntl::O_CREAT()|Fcntl::O_EXCL()) + my $ref = \*{'Fh::' . quotemeta($name)}; + sysopen($ref,$file,Fcntl::O_RDWR()|Fcntl::O_CREAT()|Fcntl::O_EXCL()) || die "CGI open of $file: $!\n"; unlink($file) if $delete; - return bless \*{$FH},$pack; + delete $Fh::{$FH}; + return bless $ref,$pack; } END_OF_FUNC @@ -2883,10 +2928,10 @@ END_OF_AUTOLOAD package MultipartBuffer; # how many bytes to read at a time. We use -# a 5K buffer by default. -$INITIAL_FILLUNIT = 1024 * 5; -$TIMEOUT = 10*60; # 10 minute timeout -$SPIN_LOOP_MAX = 1000; # bug fix for some Netscape servers +# a 4K buffer by default. +$INITIAL_FILLUNIT = 1024 * 4; +$TIMEOUT = 240*60; # 4 hour timeout for big files +$SPIN_LOOP_MAX = 2000; # bug fix for some Netscape servers $CRLF=$CGI::CRLF; #reuse the autoload function @@ -2930,8 +2975,8 @@ sub new { # characters "--" PLUS the Boundary string # BUG: IE 3.01 on the Macintosh uses just the boundary -- not - # the two extra spaces. We do a special case here on the user-agent!!!! - $boundary = "--$boundary" unless CGI::user_agent('MSIE 3\.0[12]; Mac'); + # the two extra hyphens. We do a special case here on the user-agent!!!! + $boundary = "--$boundary" unless CGI::user_agent('MSIE 3\.0[12]; ?Mac'); } else { # otherwise we find it ourselves my($old); @@ -3088,6 +3133,7 @@ sub fillBuffer { \$self->{BUFFER}, $bytesToRead, $bufferLength); + $self->{BUFFER} = '' unless defined $self->{BUFFER}; # An apparent bug in the Apache server causes the read() # to return zero bytes repeatedly without blocking if the @@ -3129,7 +3175,7 @@ $MAC = $CGI::OS eq 'MACINTOSH'; my ($vol) = $MAC ? MacPerl::Volumes() =~ /:(.*)/ : ""; unless ($TMPDIRECTORY) { @TEMP=("${SL}usr${SL}tmp","${SL}var${SL}tmp", - "${SL}tmp","${SL}temp","${vol}${SL}Temporary Items", + "C:${SL}temp","${SL}tmp","${SL}temp","${vol}${SL}Temporary Items", "${SL}WWW_ROOT"); foreach (@TEMP) { do {$TMPDIRECTORY = $_; last} if -d $_ && -w _; @@ -3276,7 +3322,7 @@ script and restore it later. For example, using the object oriented style, here is how you create a simple "Hello World" HTML page: - #!/usr/local/bin/perl -w + #!/usr/local/bin/perl use CGI; # load CGI routines $q = new CGI; # create new CGI object print $q->header, # create the HTTP header @@ -3294,7 +3340,7 @@ The main differences are that we now need to import a set of functions into our name space (usually the "standard" functions), and we don't need to create the CGI object. - #!/usr/local/bin/pelr + #!/usr/local/bin/perl use CGI qw/:standard/; # load standard CGI routines print header, # create the HTTP header start_html('hello world'), # start the HTML @@ -3819,6 +3865,17 @@ parsed header) script. You may need to do other things as well to tell the server that the script is NPH. See the discussion of NPH scripts below. +=item -newstyle_urls + +Separate the name=value pairs in CGI parameter query strings with +semicolons rather than ampersands. For example: + + ?name=fred;age=24;favorite_color=3 + +Semicolon-delimited query strings are always accepted, but will not be +emitted by self_url() and query_string() unless the -newstyle_urls +pragma is specified. + =item -autoload This overrides the autoloader so that any function in your program @@ -3859,7 +3916,51 @@ upload, even if it is confidential information. On Unix systems, the -private_tempfiles pragma will cause the temporary file to be unlinked as soon as it is opened and before any data is written into it, eliminating the risk of eavesdropping. -n + +=back + +=head2 SPECIAL FORMS FOR IMPORTING HTML-TAG FUNCTIONS + +Many of the methods generate HTML tags. As described below, tag +functions automatically generate both the opening and closing tags. +For example: + + print h1('Level 1 Header'); + +produces + + <H1>Level 1 Header</H1> + +There will be some times when you want to produce the start and end +tags yourself. In this case, you can use the form start_I<tag_name> +and end_I<tag_name>, as in: + + print start_h1,'Level 1 Header',end_h1; + +With a few exceptions (described below), start_I<tag_name> and +end_I<tag_name> functions are not generated automatically when you +I<use CGI>. However, you can specify the tags you want to generate +I<start/end> functions for by putting an asterisk in front of their +name, or, alternatively, requesting either "start_I<tag_name>" or +"end_I<tag_name>" in the import list. + +Example: + + use CGI qw/:standard *table start_ul/; + +In this example, the following functions are generated in addition to +the standard ones: + +=over 4 + +=item 1. start_table() (generates a <TABLE> tag) + +=item 2. end_table() (generates a </TABLE> tag) + +=item 3. start_ul() (generates a <UL> tag) + +=item 4. end_ul() (generates a </UL> tag) + =back =head1 GENERATING DYNAMIC DOCUMENTS @@ -4114,19 +4215,19 @@ header. Just pass the list of script sections as an array reference. this allows you to specify different source files for different dialects of JavaScript. Example: - print $q->start_html(-title=>'The Riddle of the Sphinx', - -script=>[ - { -language => 'JavaScript1.0', - -src => '/javascript/utilities10.js' + print $q->start_html(-title=>'The Riddle of the Sphinx', + -script=>[ + { -language => 'JavaScript1.0', + -src => '/javascript/utilities10.js' }, - { -language => 'JavaScript1.1', - -src => '/javascript/utilities11.js' + { -language => 'JavaScript1.1', + -src => '/javascript/utilities11.js' }, - { -language => 'JavaScript1.2', - -src => '/javascript/utilities12.js' + { -language => 'JavaScript1.2', + -src => '/javascript/utilities12.js' }, - { -language => 'JavaScript28.2', - -src => '/javascript/utilities219.js' + { -language => 'JavaScript28.2', + -src => '/javascript/utilities219.js' } ] ); @@ -4247,6 +4348,25 @@ as a synonym. =back +=head2 MIXING POST AND URL PARAMETERS + + $color = $query->url_param('color'); + +It is possible for a script to receive CGI parameters in the URL as +well as in the fill-out form by creating a form that POSTs to a URL +containing a query string (a "?" mark followed by arguments). The +B<param()> method will always return the contents of the POSTed +fill-out form, ignoring the URL's query string. To retrieve URL +parameters, call the B<url_param()> method. Use it in the same way as +B<param()>. The main difference is that it allows you to read the +parameters, but not set them. + + +Under no circumstances will the contents of the URL query string +interfere with similarly-named CGI parameters in POSTed forms. If you +try to mix a URL query string with a form submitted with the GET +method, the results will not be what you expect. + =head1 CREATING STANDARD HTML ELEMENTS: CGI.pm defines general HTML shortcut methods for most, if not all of @@ -4262,7 +4382,7 @@ This example shows how to use the HTML methods: print $q->blockquote( "Many years ago on the island of", $q->a({href=>"http://crete.org/"},"Crete"), - "there lived a Minotaur named", + "there lived a minotaur named", $q->strong("Fred."), ), $q->hr; @@ -4410,11 +4530,21 @@ begin with initial caps: Tr Link Delete + Accept + Sub In addition, start_html(), end_html(), start_form(), end_form(), start_multipart_form() and all the fill-out form tags are special. See their respective sections. +=head2 PRETTY-PRINTING HTML + +By default, all the HTML produced by these functions comes out as one +long line without carriage returns or indentation. This is yuck, but +it does reduce the size of the documents by 10-20%. To get +pretty-printed output, please use L<CGI::Pretty>, a subclass +contributed by Brian Paulsen. + =head1 CREATING FILL-OUT FORMS: I<General note> The various form-creating methods all return strings @@ -4469,7 +4599,7 @@ default is to process the query with the current script. print $query->startform(-method=>$method, -action=>$action, - -encoding=>$encoding); + -enctype=>$encoding); <... various form stuff ...> print $query->endform; @@ -4484,11 +4614,11 @@ action and form encoding that you specify. The defaults are: method: POST action: this script - encoding: application/x-www-form-urlencoded + enctype: application/x-www-form-urlencoded endform() returns the closing </FORM> tag. -Startform()'s encoding method tells the browser how to package the various +Startform()'s enctype argument tells the browser how to package the various fields of the form before sending the form to the server. Two values are possible: @@ -4671,12 +4801,11 @@ The first parameter is the required name for the field (-name). The optional second parameter is the starting value for the field contents to be used as the default file name (-default). -The beta2 version of Netscape 2.0 currently doesn't pay any attention -to this field, and so the starting value will always be blank. Worse, -the field loses its "sticky" behavior and forgets its previous -contents. The starting value field is called for in the HTML -specification, however, and possibly later versions of Netscape will -honor it. +For security reasons, browsers don't pay any attention to this field, +and so the starting value will always be blank. Worse, the field +loses its "sticky" behavior and forgets its previous contents. The +starting value field is called for in the HTML specification, however, +and possibly some browser will eventually provide support for it. =item 3. @@ -5157,6 +5286,9 @@ reset() creates the "reset" button. Note that it restores the form to its value from the last time the script was called, NOT necessarily to the defaults. +Note that this conflicts with the Perl reset() built-in. Use +CORE::reset() to get the original reset function. + =head2 CREATING A DEFAULT BUTTON print $query->defaults('button_label') @@ -5263,11 +5395,12 @@ pointed to by the B<-onClick> parameter will be executed. On non-Netscape browsers this form element will probably not even display. -=head1 NETSCAPE COOKIES +=head1 HTTP COOKIES -Netscape browsers versions 1.1 and higher support a so-called -"cookie" designed to help maintain state within a browser session. -CGI.pm has several methods that support cookies. +Netscape browsers versions 1.1 and higher, and all versions of +Internet Explorer, support a so-called "cookie" designed to help +maintain state within a browser session. CGI.pm has several methods +that support cookies. A cookie is a name=value pair much like the named parameters in a CGI query string. CGI scripts create one or more cookies and send @@ -5285,15 +5418,15 @@ optional attributes: This is a time/date string (in a special GMT format) that indicates when a cookie expires. The cookie will be saved and returned to your script until this expiration date is reached if the user exits -Netscape and restarts it. If an expiration date isn't specified, the cookie -will remain active until the user quits Netscape. +the browser and restarts it. If an expiration date isn't specified, the cookie +will remain active until the user quits the browser. =item 2. a domain This is a partial or complete domain name for which the cookie is valid. The browser will return the cookie to any host that matches the partial domain name. For example, if you specify a domain name -of ".capricorn.com", then Netscape will return the cookie to +of ".capricorn.com", then the browser will return the cookie to Web servers running on any of the machines "www.capricorn.com", "www2.capricorn.com", "feckless.capricorn.com", etc. Domain names must contain at least two periods to prevent attempts to match @@ -5318,7 +5451,7 @@ script if the CGI request is occurring on a secure channel, such as SSL. =back -The interface to Netscape cookies is the B<cookie()> method: +The interface to HTTP cookies is the B<cookie()> method: $cookie = $query->cookie(-name=>'sessionID', -value=>'xyzzy', @@ -5335,7 +5468,7 @@ B<cookie()> creates a new cookie. Its parameters include: =item B<-name> The name of the cookie (required). This can be any string at all. -Although Netscape limits its cookie names to non-whitespace +Although browsers limit their cookie names to non-whitespace alphanumeric characters, CGI.pm removes this restriction by escaping and unescaping cookies behind the scenes. @@ -5406,19 +5539,11 @@ simple to turn a CGI parameter into a cookie, and vice-versa: See the B<cookie.cgi> example script for some ideas on how to use cookies effectively. -B<NOTE:> There appear to be some (undocumented) restrictions on -Netscape cookies. In Netscape 2.01, at least, I haven't been able to -set more than three cookies at a time. There may also be limits on -the length of cookies. If you need to store a lot of information, -it's probably better to create a unique session ID, store it in a -cookie, and use the session ID to locate an external file/database -saved on the server's side of the connection. - -=head1 WORKING WITH NETSCAPE FRAMES +=head1 WORKING WITH FRAMES -It's possible for CGI.pm scripts to write into several browser -panels and windows using Netscape's frame mechanism. -There are three techniques for defining new frames programmatically: +It's possible for CGI.pm scripts to write into several browser panels +and windows using the HTML 4 frame mechanism. There are three +techniques for defining new frames programmatically: =over 4 @@ -5441,12 +5566,12 @@ You may provide a B<-target> parameter to the header() method: print $q->header(-target=>'ResultsWindow'); -This will tell Netscape to load the output of your script into the -frame named "ResultsWindow". If a frame of that name doesn't -already exist, Netscape will pop up a new window and load your -script's document into that. There are a number of magic names -that you can use for targets. See the frame documents on Netscape's -home pages for details. +This will tell the browser to load the output of your script into the +frame named "ResultsWindow". If a frame of that name doesn't already +exist, the browser will pop up a new window and load your script's +document into that. There are a number of magic names that you can +use for targets. See the frame documents on Netscape's home pages for +details. =item 3. Specify the destination for the document in the <FORM> tag @@ -5591,13 +5716,8 @@ Produces something that looks like: </UL> </UL> -You can pass a value of 'true' to dump() in order to get it to -print the results out as plain text, suitable for incorporating -into a <PRE> section. - -As a shortcut, as of version 1.56 you can interpolate the entire CGI -object into a string and it will be replaced with the a nice HTML dump -shown above: +As a shortcut, you can interpolate the entire CGI object into a string +and it will be replaced with the a nice HTML dump shown above: $query=new CGI; print "<H2>Current Values</H2> $query\n"; @@ -5609,24 +5729,25 @@ through this interface. The methods are as follows: =over 4 -=item B<accept()> +=item B<Accept()> + +Return a list of MIME types that the remote browser accepts. If you +give this method a single argument corresponding to a MIME type, as in +$query->Accept('text/html'), it will return a floating point value +corresponding to the browser's preference for this type from 0.0 +(don't want) to 1.0. Glob types (e.g. text/*) in the browser's accept +list are handled correctly. -Return a list of MIME types that the remote browser -accepts. If you give this method a single argument -corresponding to a MIME type, as in -$query->accept('text/html'), it will return a -floating point value corresponding to the browser's -preference for this type from 0.0 (don't want) to 1.0. -Glob types (e.g. text/*) in the browser's accept list -are handled correctly. +Note that the capitalization changed between version 2.43 and 2.44 in +order to avoid conflict with Perl's accept() function. =item B<raw_cookie()> Returns the HTTP_COOKIE variable, an HTTP extension implemented by -Netscape browsers version 1.1 and higher. Cookies have a special -format, and this method call just returns the raw form (?cookie -dough). See cookie() for ways of setting and retrieving cooked -cookies. +Netscape browsers version 1.1 and higher, and all versions of Internet +Explorer. Cookies have a special format, and this method call just +returns the raw form (?cookie dough). See cookie() for ways of +setting and retrieving cooked cookies. Called with no parameters, raw_cookie() returns the packed cookie structure. You can separate it into individual cookies by splitting @@ -5708,10 +5829,9 @@ verification, if this script is protected. =item B<user_name ()> -Attempt to obtain the remote user's name, using a variety -of different techniques. This only works with older browsers -such as Mosaic. Netscape does not reliably report the user -name! +Attempt to obtain the remote user's name, using a variety of different +techniques. This only works with older browsers such as Mosaic. +Newer browsers do not report the user name for privacy reasons! =item B<request_method()> @@ -5935,14 +6055,17 @@ of CGI.pm without rewriting your old scripts from scratch. =head1 AUTHOR INFORMATION -Copyright 1995-1997, Lincoln D. Stein. All rights reserved. It may -be used and modified freely, but I do request that this copyright -notice remain attached to the file. You may modify this module as you -wish, but if you redistribute a modified version, please attach a note -listing the modifications you have made. +Copyright 1995-1998, Lincoln D. Stein. All rights reserved. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. -Address bug reports and comments to: -lstein@genome.wi.mit.edu +Address bug reports and comments to: lstein@cshl.org. When sending +bug reports, please provide the version of CGI.pm, the version of +Perl, the name and version of your Web server, and the name and +version of the operating system you are using. If the problem is even +remotely browser dependent, please provide information about the +affected browers as well. =head1 CREDITS @@ -5962,7 +6085,7 @@ Thanks very much to: =item Joergen Haegg (jh@axis.se) -=item Laurent Delfosse (delfosse@csgrad1.cs.wvu.edu) +=item Laurent Delfosse (delfosse@delfosse.com) =item Richard Resnick (applepi1@aol.com) @@ -6054,7 +6177,7 @@ for suggestions and bug fixes. -rows=>10, -columns=>50); - print "<P>",$query->reset; + print "<P>",$query->Reset; print $query->submit('Action','Shout'); print $query->submit('Action','Scream'); print $query->endform; @@ -6095,8 +6218,8 @@ warnings when programs are run with the B<-w> switch. =head1 SEE ALSO L<CGI::Carp>, L<URI::URL>, L<CGI::Request>, L<CGI::MiniSvr>, -L<CGI::Base>, L<CGI::Form>, L<CGI::Apache>, L<CGI::Switch>, -L<CGI::Push>, L<CGI::Fast> +L<CGI::Base>, L<CGI::Form>, L<CGI::Push>, L<CGI::Fast>, +L<CGI::Pretty> =cut diff --git a/lib/CGI/Carp.pm b/lib/CGI/Carp.pm index e20f7542b8..dfae1a61b7 100644 --- a/lib/CGI/Carp.pm +++ b/lib/CGI/Carp.pm @@ -14,6 +14,12 @@ B<CGI::Carp> - CGI routines for writing to the HTTPD (or other) error log warn "I'm confused"; die "I'm dying.\n"; + use CGI::Carp qw(cluck); + cluck "I wouldn't do that if I were you"; + + use CGI::Carp qw(fatalsToBrowser); + die "Fatal error messages are now sent to browser"; + =head1 DESCRIPTION CGI scripts have a nasty habit of leaving warning messages in the error @@ -155,11 +161,21 @@ set_message() from within a BEGIN{} block. 1.10 Patch from Chris Dean (ctdean@cogit.com) to allow module to run correctly under mod_perl. +1.11 Changed order of > and < escapes. + +1.12 Changed die() on line 217 to CORE::die to avoid B<-w> warning. + +1.13 Added cluck() to make the module orthogonal with Carp. + More mod_perl related fixes. + =head1 AUTHORS -Lincoln D. Stein <lstein@genome.wi.mit.edu>. Feel free to redistribute -this under the Perl Artistic License. +Copyright 1995-1998, Lincoln D. Stein. All rights reserved. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. +Address bug reports and comments to: lstein@cshl.org =head1 SEE ALSO @@ -174,11 +190,11 @@ use Carp; @ISA = qw(Exporter); @EXPORT = qw(confess croak carp); -@EXPORT_OK = qw(carpout fatalsToBrowser wrap set_message); +@EXPORT_OK = qw(carpout fatalsToBrowser wrap set_message cluck); $main::SIG{__WARN__}=\&CGI::Carp::warn; $main::SIG{__DIE__}=\&CGI::Carp::die; -$CGI::Carp::VERSION = '1.101'; +$CGI::Carp::VERSION = '1.13'; $CGI::Carp::CUSTOM_MSG = undef; # fancy import routine detects and handles 'errorWrap' specially. @@ -194,7 +210,6 @@ sub import { } # These are the originals -# XXX Why not just use CORE::die etc., instead of these two? GSAR sub realwarn { CORE::warn(@_); } sub realdie { CORE::die(@_); } @@ -230,8 +245,7 @@ sub warn { # eval. These evals don't count when looking at the stack backtrace. sub _longmess { my $message = Carp::longmess(); - my $mod_perl = ($ENV{'GATEWAY_INTERFACE'} - && $ENV{'GATEWAY_INTERFACE'} =~ /^CGI-Perl\//); + my $mod_perl = exists $ENV{MOD_PERL}; $message =~ s,eval[^\n]+Apache/Registry\.pm.*,,s if $mod_perl; return( $message ); } @@ -240,7 +254,7 @@ sub die { my $message = shift; my $time = scalar(localtime); my($file,$line,$id) = id(1); - $message .= " at $file line $line.\n" unless $message=~/\n$/; + $message .= " at $file line $line." unless $message=~/\n$/; &fatalsToBrowser($message) if $WRAP && _longmess() !~ /eval [{\']/m; my $stamp = stamp; $message=~s/^/$stamp/gm; @@ -258,8 +272,9 @@ sub set_message { local $^W=0; eval <<EOF; sub confess { CGI::Carp::die Carp::longmess \@_; } -sub croak { CGI::Carp::die Carp::shortmess \@_; } -sub carp { CGI::Carp::warn Carp::shortmess \@_; } +sub croak { CGI::Carp::die Carp::shortmess \@_; } +sub carp { CGI::Carp::warn Carp::shortmess \@_; } +sub cluck { CGI::Carp::warn Carp::longmess \@_; } EOF ; } @@ -269,7 +284,7 @@ EOF sub carpout { my($in) = @_; my($no) = fileno(to_filehandle($in)); - realdie "Invalid filehandle $in\n" unless defined $no; + realdie("Invalid filehandle $in\n") unless defined $no; open(SAVEERR, ">&STDERR"); open(STDERR, ">&$no") or @@ -279,9 +294,9 @@ sub carpout { # headers sub fatalsToBrowser { my($msg) = @_; + $msg=~s/&/&/g; $msg=~s/>/>/g; $msg=~s/</</g; - $msg=~s/&/&/g; $msg=~s/\"/"/g; my($wm) = $ENV{SERVER_ADMIN} ? qq[the webmaster (<a href="mailto:$ENV{SERVER_ADMIN}">$ENV{SERVER_ADMIN}</a>)] : @@ -291,7 +306,9 @@ For help, please send mail to $wm, giving this error message and the time and date of the error. END ; - print STDOUT "Content-type: text/html\n\n"; + my $mod_perl = exists $ENV{MOD_PERL}; + print STDOUT "Content-type: text/html\n\n" + unless $mod_perl; if ($CUSTOM_MSG) { if (ref($CUSTOM_MSG) eq 'CODE') { @@ -302,13 +319,30 @@ END } } - print STDOUT <<END; + my $mess = <<END; <H1>Software error:</H1> <CODE>$msg</CODE> <P> -$outer_message; +$outer_message END ; + + if ($mod_perl) { + my $r = Apache->request; + # If bytes have already been sent, then + # we print the message out directly. + # Otherwise we make a custom error + # handler to produce the doc for us. + if ($r->bytes_sent) { + $r->print($mess); + $r->exit; + } else { + $r->status(500); + $r->custom_response(500,$mess); + } + } else { + print STDOUT $mess; + } } # Cut and paste from CGI.pm so that we don't have the overhead of diff --git a/lib/CGI/Cookie.pm b/lib/CGI/Cookie.pm index c32891a331..204d67b08a 100644 --- a/lib/CGI/Cookie.pm +++ b/lib/CGI/Cookie.pm @@ -69,7 +69,9 @@ sub parse { my($key,$value) = split("="); my(@values) = map CGI::unescape($_),split('&',$value); $key = CGI::unescape($key); - $results{$key} = $self->new(-name=>$key,-value=>\@values); + # A bug in Netscape can cause several cookies with same name to + # appear. The FIRST one in HTTP_COOKIE is the most recent version. + $results{$key} ||= $self->new(-name=>$key,-value=>\@values); } return \%results unless wantarray; return %results; @@ -399,13 +401,12 @@ Get or set the cookie's expiration time. =head1 AUTHOR INFORMATION -be used and modified freely, but I do request that this copyright -notice remain attached to the file. You may modify this module as you -wish, but if you redistribute a modified version, please attach a note -listing the modifications you have made. +Copyright 1997-1998, Lincoln D. Stein. All rights reserved. -Address bug reports and comments to: -lstein@genome.wi.mit.edu +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +Address bug reports and comments to: lstein@cshl.org =head1 BUGS diff --git a/lib/CGI/Fast.pm b/lib/CGI/Fast.pm index 03b54072c9..a39fe052e8 100644 --- a/lib/CGI/Fast.pm +++ b/lib/CGI/Fast.pm @@ -16,7 +16,7 @@ package CGI::Fast; # The most recent version and complete docs are available at: # http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html # ftp://ftp-genome.wi.mit.edu/pub/software/WWW/ -$CGI::Fast::VERSION='1.00a'; +$CGI::Fast::VERSION='1.01'; use CGI; use FCGI; @@ -34,9 +34,11 @@ sub save_request { # New is slightly different in that it calls FCGI's # accept() method. sub new { - return undef unless FCGI::accept() >= 0; - my($self,@param) = @_; - return $CGI::Q = $self->SUPER::new(@param); + my ($self, $initializer, @param) = @_; + unless (defined $initializer) { + return undef unless FCGI::accept() >= 0; + } + return $CGI::Q = $self->SUPER::new($initializer, @param); } 1; @@ -154,13 +156,12 @@ I haven't tested this very much. =head1 AUTHOR INFORMATION -be used and modified freely, but I do request that this copyright -notice remain attached to the file. You may modify this module as you -wish, but if you redistribute a modified version, please attach a note -listing the modifications you have made. +Copyright 1996-1998, Lincoln D. Stein. All rights reserved. -Address bug reports and comments to: -lstein@genome.wi.mit.edu +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +Address bug reports and comments to: lstein@cshl.org =head1 BUGS diff --git a/lib/CGI/Push.pm b/lib/CGI/Push.pm index 60a461759b..e4a66aee72 100644 --- a/lib/CGI/Push.pm +++ b/lib/CGI/Push.pm @@ -14,8 +14,7 @@ package CGI::Push; # listing the modifications you have made. # The most recent version and complete docs are available at: -# http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html -# ftp://ftp-genome.wi.mit.edu/pub/software/WWW/ +# http://stein.cshl.org/WWW/software/CGI/ $CGI::Push::VERSION='1.01'; use CGI; @@ -204,7 +203,7 @@ itself should have exactly the same calling conventions as the This optional parameter indicates the content type of each page. It defaults to "text/html". Normally the module assumes that each page -is of a homogeneous MIME type. However if you provide either of the +is of a homogenous MIME type. However if you provide either of the magic values "heterogeneous" or "dynamic" (the latter provided for the convenience of those who hate long parameter names), you can specify the MIME type -- and other header fields -- on a per-page basis. See @@ -287,19 +286,14 @@ Recognition of NPH scripts happens automatically with WebSTAR and Microsoft IIS. Users of other servers should see their documentation for help. -=head1 CAVEATS - -This is a new module. It hasn't been extensively tested. - =head1 AUTHOR INFORMATION -be used and modified freely, but I do request that this copyright -notice remain attached to the file. You may modify this module as you -wish, but if you redistribute a modified version, please attach a note -listing the modifications you have made. +Copyright 1995-1998, Lincoln D. Stein. All rights reserved. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. -Address bug reports and comments to: -lstein@genome.wi.mit.edu +Address bug reports and comments to: lstein@cshl.org =head1 BUGS diff --git a/lib/CPAN.pm b/lib/CPAN.pm index f12d41c0e6..0c6b5d9250 100644 --- a/lib/CPAN.pm +++ b/lib/CPAN.pm @@ -5,13 +5,13 @@ use vars qw{$Try_autoload $Revision $Frontend $Defaultsite }; -$VERSION = '1.44_54'; +$VERSION = '1.47'; -# $Id: CPAN.pm,v 1.250 1999/01/14 12:26:13 k Exp $ +# $Id: CPAN.pm,v 1.256 1999/01/25 13:06:22 k Exp $ # only used during development: $Revision = ""; -# $Revision = "[".substr(q$Revision: 1.250 $, 10)."]"; +# $Revision = "[".substr(q$Revision: 1.256 $, 10)."]"; use Carp (); use Config (); @@ -27,6 +27,7 @@ use FileHandle (); use Safe (); use Text::ParseWords (); use Text::Wrap; +use File::Spec; END { $End++; &cleanup; } @@ -314,16 +315,51 @@ use vars qw($AUTOLOAD @ISA); @CPAN::Tarzip::ISA = qw(CPAN::Debug); package CPAN::Queue; -# currently only used to determine if we should or shouldn't announce -# the availability of a new CPAN module -# but now we try to use it for dependency tracking. For that to happen +# One use of the queue is to determine if we should or shouldn't +# announce the availability of a new CPAN module + +# Now we try to use it for dependency tracking. For that to happen # we need to draw a dependency tree and do the leaves first. This can # easily be reached by running CPAN.pm recursively, but we don't want # to waste memory and run into deep recursion. So what we can do is -# this: run the queue as the user suggested. When a dependency is -# detected check if it is in the queue. If so, rearrange, otherwise -# unshift it on the queue. +# this: + +# CPAN::Queue is the package where the queue is maintained. Dependencies +# often have high priority and must be brought to the head of the queue, +# possibly by jumping the queue if they are already there. My first code +# attempt tried to be extremely correct. Whenever a module needed +# immediate treatment, I either unshifted it to the front of the queue, +# or, if it was already in the queue, I spliced and let it bypass the +# others. This became a too correct model that made it impossible to put +# an item more than once into the queue. Why would you need that? Well, +# you need temporary duplicates as the manager of the queue is a loop +# that +# +# (1) looks at the first item in the queue without shifting it off +# +# (2) cares for the item +# +# (3) removes the item from the queue, *even if its agenda failed and +# even if the item isn't the first in the queue anymore* (that way +# protecting against never ending queues) +# +# So if an item has prerequisites, the installation fails now, but we +# want to retry later. That's easy if we have it twice in the queue. +# +# I also expect insane dependency situations where an item gets more +# than two lives in the queue. Simplest example is triggered by 'install +# Foo Foo Foo'. People make this kind of mistakes and I don't want to +# get in the way. I wanted the queue manager to be a dumb servant, not +# one that knows everything. +# +# Who would I tell in this model that the user wants to be asked before +# processing? I can't attach that information to the module object, +# because not modules are installed but distributions. So I'd have to +# tell the distribution object that it should ask the user before +# processing. Where would the question be triggered then? Most probably +# in CPAN::Distribution::rematein. +# Hope that makes sense, my head is a bit off:-) -- AK use vars qw{ @All }; @@ -334,7 +370,6 @@ sub new { # my @all = map { $_->{mod} } @All; # warn "Adding Queue object for mod[$mod] all[@all]"; return $self; - } sub first { @@ -556,13 +591,18 @@ sub has_inst { $file =~ s|/|\\|g if $^O eq 'MSWin32'; $file .= ".pm"; if ($INC{$file}) { -# warn "$file in %INC"; #debug + # checking %INC is wrong, because $INC{LWP} may be true + # although $INC{"URI/URL.pm"} may have failed. But as + # I really want to say "bla loaded OK", I have to somehow + # cache results. + ### warn "$file in %INC"; #debug return 1; } elsif (eval { require $file }) { # eval is good: if we haven't yet read the database it's # perfect and if we have installed the module in the meantime, # it tries again. The second require is only a NOOP returning # 1 if we had success, otherwise it's retrying + $CPAN::Frontend->myprint("CPAN: $mod loaded ok\n"); if ($mod eq "CPAN::WAIT") { push @CPAN::Shell::ISA, CPAN::WAIT; @@ -583,6 +623,8 @@ sub has_inst { }); sleep 2; + } else { + delete $INC{$file}; # if it inc'd LWP but failed during, say, URI } return 0; } @@ -676,7 +718,8 @@ sub entries { $getcwd = $CPAN::Config->{'getcwd'} || 'cwd'; my($cwd) = CPAN->$getcwd(); chdir $dir or Carp::croak("Can't chdir to $dir: $!"); - my $dh = DirHandle->new(".") or Carp::croak("Couldn't opendir $dir: $!"); + my $dh = DirHandle->new(File::Spec->curdir) + or Carp::croak("Couldn't opendir $dir: $!"); my(@entries); for ($dh->read) { next if $_ eq "." || $_ eq ".."; @@ -700,9 +743,15 @@ sub disk_usage { my($Du) = 0; find( sub { - $File::Find::prune++ if $CPAN::Signal; - return if -l $_; - $Du += (-s _); # parens to help cperl-mode + $File::Find::prune++ if $CPAN::Signal; + return if -l $_; + if ($^O eq 'MacOS') { + require Mac::Files; + my $cat = Mac::Files::FSpGetCatInfo($_); + $Du += $cat->ioFlLgLen() + $cat->ioFlRLgLen(); + } else { + $Du += (-s _); + } }, $dir ); @@ -1261,8 +1310,7 @@ sub reload { CPAN::Index->force_reload; } else { $CPAN::Frontend->myprint(qq{cpan re-evals the CPAN.pm file -index re-reads the index files -}); +index re-reads the index files\n}); } } @@ -1764,6 +1812,20 @@ sub localize { $self->debug("file[$file] aslocal[$aslocal] force[$force]") if $CPAN::DEBUG; + if ($^O eq 'MacOS') { + my($name, $path) = File::Basename::fileparse($aslocal, ''); + if (length($name) > 31) { + $name =~ s/(\.(readme(\.(gz|Z))?|(tar\.)?(gz|Z)|tgz|zip|pm\.(gz|Z)))$//; + my $suf = $1; + my $size = 31 - length($suf); + while (length($name) > $size) { + chop $name; + } + $name .= $suf; + $aslocal = File::Spec->catfile($path, $name); + } + } + return $aslocal if -f $aslocal && -r _ && !($force & 1); my($restore) = 0; if (-f $aslocal){ @@ -1820,6 +1882,7 @@ sub localize { } else { @levels = qw/easy hard hardest/; } + @levels = qw/easy/ if $^O eq 'MacOS'; for $level (@levels) { my $method = "host$level"; my @host_seq = $level eq "easy" ? @@ -2433,26 +2496,35 @@ sub reload { my $needshort = $^O eq "dos"; - $cl->rd_authindex($cl->reload_x( - "authors/01mailrc.txt.gz", - $needshort ? "01mailrc.gz" : "", - $force)); + $cl->rd_authindex($cl + ->reload_x( + "authors/01mailrc.txt.gz", + $needshort ? + File::Spec->catfile('authors', '01mailrc.gz') : + File::Spec->catfile('authors', '01mailrc.txt.gz'), + $force)); $t2 = time; $debug = "timing reading 01[".($t2 - $time)."]"; $time = $t2; return if $CPAN::Signal; # this is sometimes lengthy - $cl->rd_modpacks($cl->reload_x( - "modules/02packages.details.txt.gz", - $needshort ? "02packag.gz" : "", - $force)); + $cl->rd_modpacks($cl + ->reload_x( + "modules/02packages.details.txt.gz", + $needshort ? + File::Spec->catfile('modules', '02packag.gz') : + File::Spec->catfile('modules', '02packages.details.txt.gz'), + $force)); $t2 = time; $debug .= "02[".($t2 - $time)."]"; $time = $t2; return if $CPAN::Signal; # this is sometimes lengthy - $cl->rd_modlist($cl->reload_x( - "modules/03modlist.data.gz", - $needshort ? "03mlist.gz" : "", - $force)); + $cl->rd_modlist($cl + ->reload_x( + "modules/03modlist.data.gz", + $needshort ? + File::Spec->catfile('modules', '03mlist.gz') : + File::Spec->catfile('modules', '03modlist.data.gz'), + $force)); $t2 = time; $debug .= "03[".($t2 - $time)."]"; $time = $t2; @@ -2485,7 +2557,8 @@ sub reload_x { #-> sub CPAN::Index::rd_authindex ; sub rd_authindex { - my($cl,$index_target) = @_; + my($cl, $index_target) = @_; + my @lines; return unless defined $index_target; $CPAN::Frontend->myprint("Going to read $index_target\n"); # my $fh = CPAN::Tarzip->TIEHANDLE($index_target); @@ -2494,8 +2567,8 @@ sub rd_authindex { local(*FH); tie *FH, CPAN::Tarzip, $index_target; local($/) = "\n"; - while (<FH>) { - chomp; + push @lines, split /\012/ while <FH>; + foreach (@lines) { my($userid,$fullname,$email) = m/alias\s+(\S+)\s+\"([^\"\<]+)\s+\<([^\>]+)\>\"/; next unless $userid && $fullname && $email; @@ -2516,15 +2589,23 @@ sub userid { #-> sub CPAN::Index::rd_modpacks ; sub rd_modpacks { - my($cl,$index_target) = @_; + my($cl, $index_target) = @_; + my @lines; return unless defined $index_target; $CPAN::Frontend->myprint("Going to read $index_target\n"); my $fh = CPAN::Tarzip->TIEHANDLE($index_target); local($/) = "\n"; while ($_ = $fh->READLINE) { - last if /^\s*$/; + s/\012/\n/g; + my @ls = map {"$_\n"} split /\n/, $_; + unshift @ls, "\n" x length($1) if /^(\n+)/; + push @lines, @ls; } - while ($_ = $fh->READLINE) { + while (@lines) { + my $shift = shift(@lines); + last if $shift =~ /^\s*$/; + } + foreach (@lines) { chomp; my($mod,$version,$dist) = split; ### $version =~ s/^\+//; @@ -2607,13 +2688,19 @@ sub rd_modlist { my @eval; local($/) = "\n"; while ($_ = $fh->READLINE) { - if (/^Date:\s+(.*)/){ + s/\012/\n/g; + my @ls = map {"$_\n"} split /\n/, $_; + unshift @ls, "\n" x length($1) if /^(\n+)/; + push @eval, @ls; + } + while (@eval) { + my $shift = shift(@eval); + if ($shift =~ /^Date:\s+(.*)/){ return if $date_of_03 eq $1; ($date_of_03) = $1; } - last if /^\s*$/; + last if $shift =~ /^\s*$/; } - push @eval, $_ while $_ = $fh->READLINE; undef $fh; push @eval, q{CPAN::Modulelist->data;}; local($^W) = 0; @@ -2775,11 +2862,12 @@ sub get { } else { $self->{archived} = "NO"; } - chdir ".."; + chdir File::Spec->updir; if ($self->{archived} ne 'NO') { - chdir "tmp"; + chdir File::Spec->catdir(File::Spec->curdir, "tmp"); # Let's check if the package has its own directory. - my $dh = DirHandle->new(".") or Carp::croak("Couldn't opendir .: $!"); + my $dh = DirHandle->new(File::Spec->curdir) + or Carp::croak("Couldn't opendir .: $!"); my @readdir = grep $_ !~ /^\.\.?$/, $dh->read; ### MAC?? $dh->close; my ($distdir,$packagedir); @@ -2802,7 +2890,7 @@ sub get { } } $self->{'build_dir'} = $packagedir; - chdir ".."; + chdir File::Spec->updir; $self->debug("Changed directory to .. (self is $self [".$self->as_string."])") if $CPAN::DEBUG; @@ -2933,6 +3021,12 @@ sub readme { $local_file = CPAN::FTP->localize("authors/id/$sans.readme", $local_wanted) or $CPAN::Frontend->mydie(qq{No $sans.readme found});; + + if ($^O eq 'MacOS') { + ExtUtils::MM_MacOS::launch_file($local_file); + return; + } + my $fh_pager = FileHandle->new; local($SIG{PIPE}) = "IGNORE"; $fh_pager->open("|$CPAN::Config->{'pager'}") @@ -2999,6 +3093,7 @@ sub MD5_check_file { if (open $fh, $chk_file){ local($/); my $eval = <$fh>; + $eval =~ s/\015?\012/\n/g; close $fh; my($comp) = Safe->new(); $cksum = $comp->reval($eval); @@ -3184,6 +3279,11 @@ or chdir $builddir or Carp::croak("Couldn't chdir $builddir: $!"); $self->debug("Changed directory to $builddir") if $CPAN::DEBUG; + if ($^O eq 'MacOS') { + ExtUtils::MM_MacOS::make($self); + return; + } + my $system; if ($self->{'configure'}) { $system = $self->{'configure'}; @@ -3203,10 +3303,11 @@ or if ($CPAN::Config->{inactivity_timeout}) { eval { alarm $CPAN::Config->{inactivity_timeout}; - local $SIG{CHLD} = sub { wait }; + local $SIG{CHLD}; # = sub { wait }; if (defined($pid = fork)) { if ($pid) { #parent - wait; + # wait; + waitpid $pid, 0; } else { #child # note, this exec isn't necessary if # inactivity_timeout is 0. On the Mac I'd @@ -3245,7 +3346,6 @@ or for my $p (@prereq) { $CPAN::Frontend->myprint(" $p\n"); } - sleep 2; my $follow = 0; if ($CPAN::Config->{prerequisites_policy} eq "follow") { $follow = 1; @@ -3255,6 +3355,9 @@ or "Shall I follow them and prepend them to the queue of modules we are processing right now?", "yes"); $follow = $answer =~ /^\s*y/i; + } else { + local($") = ", "; + $CPAN::Frontend->myprint(" Ignoring dependencies on modules @prereq\n"); } if ($follow) { CPAN::Queue->jumpqueue(@prereq,$id); # requeue yourself @@ -3279,46 +3382,33 @@ sub needs_prereq { my $fh = FileHandle->new("<Makefile") or $CPAN::Frontend->mydie("Couldn't open Makefile: $!"); local($/) = "\n"; - my($v); - while (<$fh>) { - last if ($v) = m| ^ \# \s+ ( \d+\.\d+ ) .* Revision: |x; - } my(@p,@need); - if (1) { # probably all versions of MakeMaker ever so far - while (<$fh>) { - last if /MakeMaker post_initialize section/; - my($p) = m{^[\#] + while (<$fh>) { + last if /MakeMaker post_initialize section/; + my($p) = m{^[\#] \s+PREREQ_PM\s+=>\s+(.+) }x; - next unless $p; - # warn "Found prereq expr[$p]"; + next unless $p; + # warn "Found prereq expr[$p]"; - while ( $p =~ m/(?:\s)([\w\:]+)=>q\[.*?\],?/g ){ - push @p, $1; - } - last; - } - } else { # MakeMaker after a patch I suggested. Let's wait and see - while (<$fh>) { - last if /MakeMaker post_initialize section/; - my($p) = m|\# prerequisite (\S+).+not found|; - next unless $p; - push @p, $p; + while ( $p =~ m/(?:\s)([\w\:]+)=>q\[.*?\],?/g ){ + push @p, $1; } + last; } for my $p (@p) { - unless ($CPAN::META->instance("CPAN::Module",$p)->inst_file){ - if ($self->{'have_sponsored'}{$p}++) { - # We have already sponsored it and for some reason it's still - # not available. So we do nothing. Or what should we do? - } else { - # warn "----- Protegere $p -----"; - push @need, $p; - # CPAN::Queue->jumpqueue($p); - # $ret++; - } + my $mo = $CPAN::META->instance("CPAN::Module",$p); + next if $mo->uptodate; + # it's not needed, so don't push it. We cannot omit this step, because + # if 'force' is in effect, nobody else will check. + if ($self->{'have_sponsored'}{$p}++){ + # We have already sponsored it and for some reason it's still + # not available. So we do nothing. Or what should we do? + # if we push it again, we have a potential infinite loop + next; } + push @need, $p; } return @need; } @@ -3345,6 +3435,12 @@ sub test { Carp::croak("Couldn't chdir to $self->{'build_dir'}"); $self->debug("Changed directory to $self->{'build_dir'}") if $CPAN::DEBUG; + + if ($^O eq 'MacOS') { + ExtUtils::MM_MacOS::make_test($self); + return; + } + my $system = join " ", $CPAN::Config->{'make'}, "test"; if (system($system) == 0) { $CPAN::Frontend->myprint(" $system -- OK\n"); @@ -3367,6 +3463,12 @@ sub clean { chdir $self->{'build_dir'} or Carp::croak("Couldn't chdir to $self->{'build_dir'}"); $self->debug("Changed directory to $self->{'build_dir'}") if $CPAN::DEBUG; + + if ($^O eq 'MacOS') { + ExtUtils::MM_MacOS::make_clean($self); + return; + } + my $system = join " ", $CPAN::Config->{'make'}, "clean"; if (system($system) == 0) { $CPAN::Frontend->myprint(" $system -- OK\n"); @@ -3409,6 +3511,12 @@ sub install { Carp::croak("Couldn't chdir to $self->{'build_dir'}"); $self->debug("Changed directory to $self->{'build_dir'}") if $CPAN::DEBUG; + + if ($^O eq 'MacOS') { + ExtUtils::MM_MacOS::make_install($self); + return; + } + my $system = join(" ", $CPAN::Config->{'make'}, "install", $CPAN::Config->{make_install_arg}); my($stderr) = $^O =~ /Win/i ? "" : " 2>&1 "; @@ -3523,7 +3631,14 @@ sub find_bundle_file { or Carp::croak("Couldn't open $manifest: $!"); local($/) = "\n"; my $what2 = $what; - $what2 =~ s|Bundle/||; + if ($^O eq 'MacOS') { + $what =~ s/^://; + $what2 =~ tr|:|/|; + $what2 =~ s/:Bundle://; + $what2 =~ tr|:|/|; + } else { + $what2 =~ s|Bundle/||; + } my $bu; while (<$fh>) { next if /^\s*\#/; @@ -3537,6 +3652,7 @@ sub find_bundle_file { # have no Bundle directory $bu = $file if $file =~ m|\Q$what2\E$|; } + $bu =~ tr|/|:| if $^O eq 'MacOS'; return MM->catfile($where, $bu) if $bu; Carp::croak("Couldn't find a Bundle file in $where"); } @@ -3839,15 +3955,12 @@ sub uptodate { if (defined $inst_file) { $have = $self->inst_version; } - if (1){ # A block for scoping $^W, the if is just for the visual - # appeal - local($^W)=0; - if ($inst_file - && - $have >= $latest - ) { - return 1; - } + local($^W)=0; + if ($inst_file + && + $have >= $latest + ) { + return 1; } return; } @@ -4058,6 +4171,10 @@ sub untar { my $tar = Archive::Tar->new($file,1); $tar->extract($tar->list_files); # I'm pretty sure we have nothing # that isn't compressed + + ExtUtils::MM_MacOS::convert_files([$tar->list_files], 1) + if ($^O eq 'MacOS'); + return 1; } else { $CPAN::Frontend->mydie(qq{ @@ -4176,11 +4293,13 @@ each as object-E<gt>as_glimpse. E.g. =item make, test, install, clean modules or distributions -These commands take any number of arguments and investigate what is +These commands take any number of arguments and investigates what is necessary to perform the action. If the argument is a distribution -file name (recognized by embedded slashes), it is processed. If it is a -module, CPAN determines the distribution file in which this module is -included and processes that. +file name (recognized by embedded slashes), it is processed. If it is +a module, CPAN determines the distribution file in which this module +is included and processes that, following any dependencies named in +the module's Makefile.PL (this behavior is controlled by +I<prerequisites_policy>.) Any C<make> or C<test> are run unconditionally. An @@ -4505,6 +4624,9 @@ defined: make_install_arg same as make_arg for 'make install' makepl_arg arguments passed to 'perl Makefile.PL' pager location of external program more (or any pager) + prerequisites_policy + what to do if you are missing module prerequisites + ('follow' automatically, 'ask' me, or 'ignore') scan_cache controls scanning of cache ('atstart' or 'never') tar location of external program tar unzip location of external program unzip @@ -4572,7 +4694,7 @@ install foreign, unmasked, unsigned code on your machine. We compare to a checksum that comes from the net just as the distribution file itself. If somebody has managed to tamper with the distribution file, they may have as well tampered with the CHECKSUMS file. Future -development will go towards strong authentification. +development will go towards strong authentication. =head1 EXPORT @@ -4636,7 +4758,7 @@ will need to use Net::FTP. =item One way visibility -I say one way visibility as these firewalls try to make themselves look +I say one way visibility as these firewalls try to make themselve look invisible to the users inside the firewall. An FTP data connection is normally created by sending the remote server your IP address and then listening for the connection. But the remote server will not be able to diff --git a/lib/CPAN/FirstTime.pm b/lib/CPAN/FirstTime.pm index 14ef54169b..0d32a23c06 100644 --- a/lib/CPAN/FirstTime.pm +++ b/lib/CPAN/FirstTime.pm @@ -16,7 +16,7 @@ use FileHandle (); use File::Basename (); use File::Path (); use vars qw($VERSION); -$VERSION = substr q$Revision: 1.33 $, 10; +$VERSION = substr q$Revision: 1.35 $, 10; =head1 NAME @@ -183,7 +183,9 @@ policy to one of the three values. $default = $CPAN::Config->{prerequisites_policy} || 'follow'; do { - $ans = prompt("Perform cache scanning (follow, ask or ignore)?", $default); + $ans = + prompt("Policy on building prerequisites (follow, ask or ignore)?", + $default); } while ($ans ne 'follow' && $ans ne 'ask' && $ans ne 'ignore'); $CPAN::Config->{prerequisites_policy} = $ans; @@ -200,9 +202,16 @@ those. }; + my $old_warn = $^W; + local $^W if $^O eq 'MacOS'; my(@path) = split /$Config{'path_sep'}/, $ENV{'PATH'}; + local $^W = $old_warn; my $progname; for $progname (qw/gzip tar unzip make lynx ncftpget ncftp ftp/){ + if ($^O eq 'MacOS') { + $CPAN::Config->{$progname} = 'not_here'; + next; + } my $progcall = $progname; # we don't need ncftp if we have ncftpget next if $progname eq "ncftp" && $CPAN::Config->{ncftpget} gt " "; @@ -231,7 +240,8 @@ those. } my $path = $CPAN::Config->{'pager'} || $ENV{PAGER} || find_exe("less",[@path]) || - find_exe("more",[@path]) || "more"; + find_exe("more",[@path]) || ($^O eq 'MacOS' ? $ENV{EDITOR} : 0 ) + || "more"; $ans = prompt("What is your favorite pager program?",$path); $CPAN::Config->{'pager'} = $ans; $path = $CPAN::Config->{'shell'}; @@ -240,9 +250,13 @@ those. $path = ""; } $path ||= $ENV{SHELL}; - $path =~ s,\\,/,g if $^O eq 'os2'; # Cosmetic only - $ans = prompt("What is your favorite shell?",$path); - $CPAN::Config->{'shell'} = $ans; + if ($^O eq 'MacOS') { + $CPAN::Config->{'shell'} = 'not_here'; + } else { + $path =~ s,\\,/,g if $^O eq 'os2'; # Cosmetic only + $ans = prompt("What is your favorite shell?",$path); + $CPAN::Config->{'shell'} = $ans; + } # # Arguments to make etc. @@ -396,6 +410,7 @@ sub read_mirrored_by { my(%all,$url,$expected_size,$default,$ans,$host,$dst,$country,$continent,@location); my $fh = FileHandle->new; $fh->open($local) or die "Couldn't open $local: $!"; + local $/ = "\012"; while (<$fh>) { ($host) = /^([\w\.\-]+)/ unless defined $host; next unless defined $host; diff --git a/lib/File/PathConvert.pm b/lib/File/PathConvert.pm new file mode 100644 index 0000000000..a709601d5b --- /dev/null +++ b/lib/File/PathConvert.pm @@ -0,0 +1,1119 @@ +# +# Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved. +# This program is free software; you can redistribute it and/or +# modify it under the same terms as Perl itself. +# +# File::PathConvert.pm +# + +package File::PathConvert; +require 5.002; + +use strict ; + +BEGIN { + use Exporter (); + use vars qw($VERSION @ISA @EXPORT_OK); + $VERSION = 0.85; + @ISA = qw(Exporter); + @EXPORT_OK = qw(setfstype splitpath joinpath splitdirs joindirs realpat + abs2rel rel2abs $maxsymlinks $verbose $SL $resolved ); +} + +use vars qw( $maxsymlinks $verbose $SL $resolved ) ; +use Cwd; + +# +# Initialize @EXPORT_OK vars +# +$maxsymlinks = 32; # allowed symlink number in a path +$verbose = 0; # 1: verbose on, 0: verbose off +$SL = '' ; # Separator char export +$resolved = '' ; # realpath() intermediate value export + +############################################################################# +# +# Package Globals +# + +my $fstype ; # A name indicating the type of filesystem currently in us + +my $sep ; # separator +my $sepRE ; # RE to match spearator +my $notsepRE ; # RE to match anything else +my $volumeRE ; # RE to match the volume name +my $directoryRE ; # RE to match the directory name +my $isrootRE ; # RE to match root path: applied to directory portion only +my $thisDir ; # Name of this directory +my $thisDirRE ; # Name of this directory +my $parentDir ; # Name of parent directory +my $parentDirRE ; # RE to match parent dir name +my $casesensitive ; # Set to non-zero for case sensitive name comprisions. On +y + # affects names, not any other REs, so $isrootRE for Win32 + # must be case insensitive +my $idempotent ; # Set to non-zero if '//' is equivalent to '/'. This + # does not affect leading '//' and '\\' under Win32, + # but will fold '///' and '////', etc, in to '//' on this + # Win32 + + + +########### +# +# The following globals are regexs used in the indicated routines. These +# are initialized by setfstype, so they don't need to be rebuilt each time +# the routine that uses them is called. + +my $basenamesplitRE ; # Used in realpath() to split filenames. + + +########### +# +# This RE matches (and saves) the portion of the string that is just before +# the beginning of a name +# +my $beginning_of_name ; + +# +# This whopper of an RE looks for the pattern "name/.." if it occurs +# after the beginning of the string or after the root RE, or after a separator + +# We don't assume that the isrootRE has a trailing separator. +# It also makes sure that we aren't eliminating '../..' and './..' patterns +# by using the negative lookahead assertion '(?!' ... ')' construct. It also +# ignores 'name/..name'. +# +my $name_sep_parentRE ; + +# +# Matches '..$', '../' after a root +my $leading_parentRE ; + +# +# Matches things like '/(./)+' and '^(./)+' +# +my $dot_sep_etcRE ; + +# +# Matches trailing '/' or '/.' +# +my $trailing_sepRE ; + + +############################################################################# +# +# Functions +# + + +# +# setfstype: takes the name of an operating system and sets up globals that +# allow the other functions to operate on multiple OSs. See +# %fsconfig for the sets of settings. +# +# This is run once on module load to configure for the OS named +# in $^O. +# +# Interface: +# i) $osname, as in $^O or plain english: "MacOS", "DOS, etc. +# This is _not_ usually case sensitive. +# r) Name of recognized name on success else undef. Note that, as +# shipped, 'unix' is the default is nothing else matches. +# go) $fstype and lots of internal parameters and regexs. +# x) Dies if a parameter required in @fsconfig is missing. +# +# +# There are some things I couldn't figure a way to parameterize by setting +# globals. $fstype is checked for filesystem type-specific logic, like +# VMS directory syntax. +# +# Setting up for a particular OS type takes two steps: identify the OS and +# set all of the 'atomic' global variables, then take some of the atomic +# globals which are regexps and build composite values from them. +# +# The atomic regexp terms are generally used to build the larger composite +# regexps that recognize and break apart paths. This leads to +# two important rules for the atomic regexp terms: +# +# (1) Do not use '(' ... ')' in the regex terms, since they are used to build +# regexs that use '(' ... ')' to parse paths. +# +# (2) They must be built so that a '?' or other quantifier may be appended. +# This generally means using the '(?:' ... ')' or '[' ... ']' to group +# multicharacter patterns. Other '(?' ... ')' may also do. +# +# The routines herein strive to preserve the +# original separator and root settings, and, it turns out, never need to +# prepend root to a string (although they do need to insert separators on +# occasion). This is good, since the Win32 root expressions can be like +# '/', '\', 'A:/', 'a:/', or even '\\' or '//' for UNC style names. +# +# Note that the default root and default notsep are not used, and so are +# undefined. +# +# For DOS, MacOS, and VMS, we assume that all paths handed in are on the same +# volume. This is not a significant limitation except for abs2rel, since the +# absolute path is assumed to be on the same volume as the base path. +# +sub setfstype($;) { + my( $osname ) = @_ ; + + # Find the best match for OS and set up our atomic globals accordingly + if ( $osname =~ /^(?:(ms)?(dos|win(32|nt)?))/i ) + { + $fstype = 'Win32' ; + $sep = '/' ; + $sepRE = '[\\\\/]' ; + $notsepRE = '[^\\\\/]' ; + $volumeRE = '(?:^(?:[a-zA-Z]:|(?:\\\\\\\\|//)[^\\\\/]+[\\\\/][^\ +\\/]+)?)' ; + $directoryRE = '(?:(?:.*[\\\\/](?:\.\.?$)?)?)' ; + $isrootRE = '(?:^[\\\\/])' ; + $thisDir = '.' ; + $thisDirRE = '\.' ; + $parentDir = '..' ; + $parentDirRE = '(?:\.\.)' ; + $casesensitive = 0 ; + $idempotent = 1 ; + } + elsif ( $osname =~ /^MacOS$/i ) + { + $fstype = 'MacOS' ; + $sep = ':' ; + $sepRE = '\:' ; + $notsepRE = '[^:]' ; + $volumeRE = '(?:^(?:.*::)?)' ; + $directoryRE = '(?:(?:.*:)?)' ; + $isrootRE = '(?:^:)' ; + $thisDir = '.' ; + $thisDirRE = '\.' ; + $parentDir = '..' ; + $parentDirRE = '(?:\.\.)' ; + $casesensitive = 0 ; + $idempotent = 1 ; + } + elsif ( $osname =~ /^VMS$/i ) + { + $fstype = 'VMS' ; + $sep = '.' ; + $sepRE = '[\.\]]' ; + $notsepRE = '[^\.\]]' ; + # volume is node::volume:, where node:: and volume: are optional + # and node:: cannot be present without volume. node can include + # an access control string in double quotes. + # Not supported: + # quoted full node names + # embedding a double quote in a string ("" to put " in) + # support ':' in node names + # foreign file specifications + # task specifications + # UIC Directory format (use the 6 digit name for it, instead) + $volumeRE = '(?:^(?:(?:[\w\$-]+(?:"[^"]*")?::)?[\w\$-]+:)?)' ; + $directoryRE = '(?:(?:\[.*\])?)' ; + + # Root is the lack of a leading '.', unless string is empty, which + # means 'cwd', which is relative. + $isrootRE = '(?:^[^\.])' ; + $thisDir = '' ; + $thisDirRE = '\[\]' ; + $parentDir = '-' ; + $parentDirRE = '-' ; + $casesensitive = 0 ; + $idempotent = 0 ; + } + elsif ( $osname =~ /^URL$/i ) + { + # URL spec based on RFC2396 (ftp://ftp.isi.edu/in-notes/rfc2396.txt) + $fstype = 'URL' ; + $sep = '/' ; + $sepRE = '/' ; + $notsepRE = '[^/]' ; + # Volume= scheme + authority, both optional + $volumeRE = '(?:^(?:[a-zA-Z][a-zA-Z0-9+-.]*:)?(?://[^/?]*)?)' ; + + # Directories do _not_ include the query component: we pretend that + # anything after a "?" is the filename or part of it. So a '/' + # terminates and is part of the directory spec, while a '?' or '#' + # terminate and are not part of the directory spec. + # + # We pretend that ";param" syntax does not exist + # + $directoryRE = '(?:(?:[^?#]*/(?:\.\.?(?:$|(?=[?#])))?)?)' ; + $isrootRE = '(?:^/)' ; + $thisDir = '.' ; + $thisDirRE = '\.' ; + $parentDir = '..' ; + $parentDirRE = '(?:\.\.)' ; + # Assume case sensitive, since many (most?) are. The user can override + # this if they so desire. + $casesensitive = 1 ; + $idempotent = 1 ; + } + else + { + $fstype = 'Unix' ; + $sep = '/' ; + $sepRE = '/' ; + $notsepRE = '[^/]' ; + $volumeRE = '' ; + $directoryRE = '(?:(?:.*/(?:\.\.?$)?)?)' ; + $isrootRE = '(?:^/)' ; + $thisDir = '.' ; + $thisDirRE = '\.' ; + $parentDir = '..' ; + $parentDirRE = '(?:\.\.)' ; + $casesensitive = 1 ; + $idempotent = 1 ; + } + + # Now set our composite regexps. + + # Maintain old name for backward compatibility + $SL= $sep ; + + # Build lots of REs used below, so they don't need to be built every time + # the routines that use them are called. + $basenamesplitRE = '^(.*)' . $sepRE . '(' . $notsepRE . '*)$' ; + + $leading_parentRE = '(' . $isrootRE . '?)(?:' . $parentDirRE . $sepRE . ') +(?:' . $parentDirRE . '$)?' ; + $trailing_sepRE = '(.)' . $sepRE . $thisDirRE . '?$' ; + + $beginning_of_name = '(?:^|' . $isrootRE . '|' . $sepRE . ')' ; + + $dot_sep_etcRE = + '(' . $beginning_of_name . ')(?:' . $thisDirRE . $sepRE . ')+'; + + $name_sep_parentRE = + '(' . $beginning_of_name . ')' + . '(?!(?:' . $thisDirRE . '|' . $parentDirRE . ')' . $sepRE . ')' + . $notsepRE . '+' + . $sepRE . $parentDirRE + . '(?:' . $sepRE . '|$)' + ; + + if ( $verbose ) { + print( <<TOHERE ) ; +fstype = "$fstype" +sep = "$sep" +sepRE = /$sepRE/ +notsepRE = /$notsepRE/ +volumeRE = /$volumeRE/ +directoryRE = /$directoryRE/ +isrootRE = /$isrootRE/ +thisDir = "$thisDir" +thisDirRE = /$thisDirRE/ +parentDir = "$parentDir" +parentDirRE = /$parentDirRE/ +casesensitive = "$casesensitive" +TOHERE + } + + return $fstype ; +} + + +setfstype( $^O ) ; + + +# +# splitpath: Splits a path into component parts: volume, dirpath, and filename + +# +# Very much like File::Basename::fileparse(), but doesn't concern +# itself with extensions and knows about volume names. +# +# Returns ($volume, $directory, $filename ). +# +# The contents of the returned list varies by operating system. +# +# Unix: +# $volume: always '' +# $directory: up to, and including, final '/' +# $filename: after final '/' +# +# Win32: +# $volume: drive letter and ':', if present +# $directory and $filename are like on Unix, but '\' and '/' are +# equivalent and the $volume is not in $directory.. +# +# VMS: +# $volume: up to and including first ":" +# $directory: "[...]" component +# $filename: the rest. +# $nofile is ignored +# +# URL: +# $volume: up to ':', then '//stuff/morestuff'. No trailing '/'. +# $directory: after $volume, up to last '/' +# $filename: the rest. +# $nofile is ignored +# +# Interface: +# i) $path +# i) $nofile: if true, then any trailing filename is assumed to +# belong to the directory for non-VMS systems. +# r) list of ( $volume, $directory, $filename ). +# +sub splitpath { + my( $path, $nofile )= @_ ; + my( $volume, $directory, $file ) ; + if ( $fstype ne 'VMS' && $fstype ne 'URL' && $nofile ) { + $path =~ m/($volumeRE)(.*)$/ ; + $volume = $1 ; + $directory= $2 ; + $file = '' ; + } + else { + $path =~ m/($volumeRE)($directoryRE)(.*)$/ ; + $volume = $1 ; + $directory= $2 ; + $file = $3 ; + } + + # For Win32 UNC, force the directory portion to be non-empty. This is + # because all UNC names are absolute, even if there's no trailing separator + # after the sharename. + # + # This is a bit of a hack, necesitated by the implementation of $isrootRE, + # which is only applied to the directory portion. + # + # A better long term solution might be to make the isroot test a member + # function in the future, object-oriented version of this. + # + $directory = $1 + if ( $fstype eq 'Win32' && $volume =~ /^($sepRE)$sepRE/ && $directory eq +' ) ; + + return ( $volume, $directory, $file ) ; +} + + +# +# joinpath: joins the results of splitpath(). Not really necessary now, but +# good to have: +# +# - API completeness +# - Self documenting code +# - Future handling of other filesystems +# +# For instance, if you leave the ':' or the '[' and ']' out of VMS $volume +# and $directory strings, this patches it up. If you leave out the '[' +# and provide the ']', or vice versa, it is not cleaned up. This is +# because it's useful to automatically insert both '[' and ']', but if you +# leave off only one, it's likely that there's a bug elsewhere that needs +# looking in to. +# +# Automatically inserts a separator between directory and filename if needed +# for non-VMS OSs. +# +# Automatically inserts a separator between volume and directory or file +# if needed for Win32 UNC names. +# +sub joinpath($;$;$;) { + my( $volume, $directory, $filename )= @_ ; + + # Fix up delimiters for $volume and $directory as needed for various OSs + if ( $fstype eq 'VMS' ) { + $volume .= ':' + if ( $volume ne '' && $volume !~ m/:$/ ) ; + + $directory = join( '', ( '[', $directory, ']' ) ) + if ( $directory ne '' && $directory !~ m/^\[.*\]$/ ) ; + } + else { + # Add trailing separator to directory names that require it and + # need it. URLs always require it if there are any directory + # components. + $directory .= $sep + if ( $directory ne '' + && ( $fstype eq 'URL' || $filename ne '' ) + && $directory !~ m/$sepRE$/ + ) ; + + # Add trailing separator to volume for UNC and HTML volume + # names that lack it and need it. + # Note that if a URL volume is a scheme only (ends in ':'), + # we don't require a separator: it's a relative URL. + $volume .= $sep + if ( ( ( $fstype eq 'Win32' && $volume =~ m#^$sepRE{2}# ) + || ( $fstype eq 'URL' && $volume =~ m#[^:/]$# ) + ) + && $volume !~ m#$sepRE$# + && $directory !~ m#^$sepRE# + && ( $directory ne '' || $filename ne '' ) + ) ; + } + + return join( '', $volume, $directory, $filename ) ; +} + + +# +# splitdirs: Splits a string containing directory portion of a path +# in to component parts. Preserves trailing null entries, unlike split(). +# +# "a/b" should get you [ 'a', 'b' ] +# +# "a/b/" should get you [ 'a', 'b', '' ] +# +# "/a/b/" should get you [ '', 'a', 'b', '' ] +# +# "a/b" returns the same array as 'a/////b' for those OSs where +# the seperator is idempotent (Unix and DOS, at least, but not VMS). +# +# Interface: +# i) directory path string +# +sub splitdirs($;) { + my( $directorypath )= @_ ; + + $directorypath =~ s/^\[(.*)\]$/$1/ + if ( $fstype eq 'VMS' ) ; + + # + # split() likes to forget about trailing null fields, so here we + # check to be sure that there will not be any before handling the + # simple case. + # + return split( $sepRE, $directorypath ) + if ( $directorypath !~ m/$sepRE$/ ) ; + + # + # since there was a trailing separator, add a file name to the end, then + # do the split, then replace it with ''. + # + $directorypath.= "file" ; + my( @directories )= split( $sepRE, $directorypath ) ; + $directories[ $#directories ]= '' ; + + return @directories ; +} + +# +# joindirs: Joins an array of directory names in to a string, adding +# OS-specific delimiters, like '[' and ']' for VMS. +# +# Note that empty strings '' are no different then non-empty strings, +# but that undefined strings are skipped by this algorithm. +# +# This is done the hard way to preserve separators that are already +# present in any of the directory names. +# +# Could this be made faster by using a join() followed +# by s/($sepRE)$sepRE+/$1/g? +# +# Interface: +# i) array of directory names +# o) string representation of directory path +# +sub joindirs { + my $directory_path ; + + $directory_path = shift + while ( ! defined( $directory_path ) && @_ ) ; + + if ( ! defined( $directory_path ) ) { + $directory_path = '' ; + } + else { + local $_ ; + + for ( @_ ) { + next if ( ! defined( $_ ) ) ; + + $directory_path .= $sep + if ( $directory_path !~ /$sepRE$/ && ! /^$sepRE/ ) ; + + $directory_path .= $_ ; + } + } + + $directory_path = join( '', '[', $directory_path, ']' ) + if ( $fstype eq 'VMS' ) ; + + return $directory_path ; +} + + +# +# realpath: returns the canonicalized absolute path name +# +# Interface: +# i) $path path +# r) resolved name on success else undef +# go) $resolved +# resolved name on success else the path name which +# caused the problem. +$resolved = ''; +# +# Note: this implementation is based 4.4BSD version realpath(3). +# +# TODO: Speed up by using Cwd::abs_path()? +# +sub realpath($;) { + ($resolved) = @_; + my($backdir) = cwd(); + my($dirname, $basename, $links, $reg); + + $resolved = regularize($resolved); +LOOP: + { + # + # Find the dirname and basename. + # Change directory to the dirname component. + # + if ($resolved =~ /$sepRE/) { + ($dirname, $basename) = $resolved =~ /$basenamesplitRE/ ; + $dirname = $sep if ( $dirname eq '' ); + $resolved = $dirname; + unless (chdir($dirname)) { + warn("realpath: chdir($dirname) failed: $! (in ${\cwd()}).") i + $verbose; + chdir($backdir); + return undef; + } + } else { + $dirname = ''; + $basename = $resolved; + } + # + # If it is a symlink, read in the value and loop. + # If it is a directory, then change to that directory. + # + if ( $basename ne '' ) { + if (-l $basename) { + unless ($resolved = readlink($basename)) { + warn("realpath: readlink($basename) failed: $! (in ${\cwd( +}).") if $verbose; + chdir($backdir); + return undef; + } + $basename = ''; + if (++$links > $maxsymlinks) { + warn("realpath: too many symbolic links: $links.") if $ver +ose; + chdir($backdir); + return undef; + } + redo LOOP; + } elsif (-d _) { + unless (chdir($basename)) { + warn("realpath: chdir($basename) failed: $! (in ${\cwd()}) +") if $verbose; + chdir($backdir); + return undef; + } + $basename = ''; + } + } + } + # + # Get the current directory name and append the basename. + # + $resolved = cwd(); + if ( $basename ne '' ) { + $resolved .= $sep if ($resolved ne $sep); + $resolved .= $basename + } + chdir($backdir); + return $resolved; +} # end sub realpath + + +# +# abs2rel: make a relative pathname from an absolute pathname +# +# Interface: +# i) $path absolute path(needed) +# i) $base base directory(optional) +# r) relative path of $path +# +# Note: abs2rel doesn't check whether the specified path exist or not. +# +sub abs2rel($;$;) { + my($path, $base) = @_; + my($reg ); + + my( $path_volume, $path_directory, $path_file )= splitpath( $path,'nofile' +; + if ( $path_directory !~ /$isrootRE/ ) { + warn("abs2rel: nothing to do: '$path' is relative.") if $verbose; + return $path; + } + + $base = cwd() + if ( $base eq '' ) ; + + my( $base_volume, $base_directory, $base_file )= splitpath( $base,'nofile' +; + # check for a filename, since the nofile parameter does not work for OSs + # like VMS that have explicit delimiters between the dir and file portions + warn( "abs2rel: filename '$base_file' passed in \$base" ) + if ( $base_file ne '' && $verbose ) ; + + if ( $base_directory !~ /$isrootRE/ ) { + # Make $base absolute + my( $cw_volume, $cw_directory, $dummy ) = splitpath( cwd(), 'nofile' ) +; + # maybe we should warn if $cw_volume ne $base_volume and both are not +' + $base_volume= $cw_volume + if ( $base_volume eq '' && $cw_volume ne '' ) ; + $base_directory = join( '', $cw_directory, $sep, $base_directory ) ; + } + +#print( "[$path_directory,$base_directory]\n" ) ; + $path_directory = regularize( $path_directory ); + $base_directory = regularize( $base_directory ); +#print( "[$path_directory,$base_directory]\n" ) ; + # Now, remove all leading components that are the same, so 'name/a' + # 'name/b' become 'a' and 'b'. + my @pathchunks = split($sepRE, $path_directory); + my @basechunks = split($sepRE, $base_directory); + + if ( $casesensitive ) + { + while (@pathchunks && @basechunks && $pathchunks[0] eq $basechunks[0]) ++ { + shift @pathchunks ; + shift @basechunks ; + } + } + else { + while ( @pathchunks + && @basechunks + && lc( $pathchunks[0] ) eq lc( $basechunks[0] ) + ) + { + shift @pathchunks ; + shift @basechunks ; + } + } + + # No need to use joindirs() here, since we know that the arrays + # are well formed. + $path_directory= join( $sep, @pathchunks ); + $base_directory= join( $sep, @basechunks ); +#print( "[$path_directory,$base_directory]\n" ) ; + + # Convert $base_directory from absolute to relative + if ( $fstype eq 'VMS' ) { + $base_directory= $sep . $base_directory + if ( $base_directory ne '' ) ; + } + else { + $base_directory=~ s/^$sepRE// ; + } + +#print( "[$base_directory]\n" ) ; + # $base_directory now contains the directories the resulting relative path ++ # must ascend out of before it can descend to $path_directory. So, + # replace all names with $parentDir + $base_directory =~ s/$notsepRE+/$parentDir/g ; +#print( "[$base_directory]\n" ) ; + + # Glue the two together, using a separator if necessary, and preventing an + # empty result. + if ( $path_directory ne '' && $base_directory ne '' ) { + $path_directory = "$base_directory$sep$path_directory" ; + } else { + $path_directory = "$base_directory$path_directory" ; + } + + $path_directory = regularize( $path_directory ) ; + + # relative URLs should have no name in the volume, only a scheme. + $path_volume=~ s#/.*## + if ( $fstype eq 'URL' ) ; + return joinpath( $path_volume, $path_directory, $path_file ) ; +} + +# +# rel2abs: make an absolute pathname from a relative pathname +# +# Assumes no trailing file name on $base. Ignores it if present on an OS +# like $VMS. +# +# Interface: +# i) $path relative path (needed) +# i) $base base directory (optional) +# r) absolute path of $path +# +# Note: rel2abs doesn't check if the paths exist. +# +sub rel2abs($;$;) { + my( $path, $base ) = @_; + my( $reg ); + + my( $path_volume, $path_directory, $path_file )= splitpath( $path, 'nofile + ) ; + if ( $path_directory =~ /$isrootRE/ ) { + warn( "rel2abs: nothing to do: '$path' is absolute" ) + if $verbose; + return $path; + } + + warn( "rel2abs: volume '$path_volume' passed in relative path: \$path" ) + if ( $path_volume ne '' && $verbose ) ; + + $base = cwd() + if ( !defined( $base ) || $base eq '' ) ; + + my( $base_volume, $base_directory, $base_file )= splitpath( $base, 'nofile + ) ; + # check for a filename, since the nofile parameter does not work for OSs + # like VMS that have explicit delimiters between the dir and file portions + warn( "rel2abs: filename '$base_file' passed in \$base" ) + if ( $base_file ne '' && $verbose ) ; + + if ( $base_directory !~ /$isrootRE/ ) { + # Make $base absolute + my( $cw_volume, $cw_directory, $dummy ) = splitpath( cwd(), 'nofile' ) +; + # maybe we should warn if $cw_volume ne $base_volume and both are not +' + $base_volume= $cw_volume + if ( $base_volume eq '' && $cw_volume ne '' ) ; + $base_directory = join( '', $cw_directory, $sep, $base_directory ) ; + } + + $path_directory = regularize( $path_directory ); + $base_directory = regularize( $base_directory ); + + my $result_directory ; + # Avoid using a separator if either directory component is empty. + if ( $base_directory ne '' && $path_directory ne '' ) { + $result_directory= joindirs( $base_directory, $path_directory ) ; + } + else { + $result_directory= "$base_directory$path_directory" ; + } + + $result_directory = regularize( $result_directory ); + + return joinpath( $base_volume, $result_directory, $path_file ) ; +} + +# +# regularize a path. +# +# Removes dubious and redundant information. +# should only be called on directory portion on OSs +# with volumes and with delimeters that separate dir names from file names, +# since the separators can take on different semantics, like "\\" for UNC +# under Win32, or '.' in filenames under VMS. +# +sub regularize { + my( $in )= $_[ 0 ] ; + + # Combine idempotent separators. Do this first so all other REs only + # need to match one separator. Use the first sep found instead of + # sepRE to preserve slashes on Win32. + $in =~ s/($sepRE)$sepRE+/$1/g + if ( $idempotent ) ; + + # We do this after deleting redundant separators in order to be consistent + + # If a Win32 path ended in \/, we want to be sure that the \ is returned, + # no the /. + $in =~ /($sepRE)$sepRE*$/ ; + my $trailing_sep = defined( $1 ) ? $1 : '' ; + + # Delete all occurences of 'name/..(/|$)'. This is done with a while + # loop to get rid of things like 'name1/name2/../..'. We chose the pattern + # name/../ as the target instead of /name/.. so as to preserve 'rootness'. + while ($in =~ s/$name_sep_parentRE/$1/g) {} + + # Get rid of ./ in '^./' and '/./' + $in =~ s/$dot_sep_etcRE/$1/g ; + + # Get rid of trailing '/' and '/.' unless it would leave an empty string + $in =~ s/$trailing_sepRE/$1/ ; + + # Get rid of '../' constructs from absolute paths + $in =~ s/$leading_parentRE/$1/ + if ( $in =~ /$isrootRE/ ) ; + +# # Default to current directory if it's now empty. +# $in = $thisDir if $_[0] eq '' ; +# + # Restore trailing separator if it was lost. We do this to preserve + # the 'dir-ness' of the path: paths that ended in a separator on entry + # should leave with one in case the caller is using trailing slashes to + # indicate paths to directories. + $in .= $trailing_sep + if ( $trailing_sep ne '' && $in !~ /$sepRE$/ ) ; + + return $in ; +} + +1; + +__END__ + +=head1 NAME + +abs2rel - convert an absolute path to a relative path + +rel2abs - convert a relative path to an absolute path + +realpath - convert a logical path to a physical path (resolve symlinks) + +splitpath - split a path in to volume, directory and filename components + +joinpath - join volume, directory, and filename components to form a path + +splitdirs - split directory specification in to component names + +joindirs - join component names in to a directory specification + +setfstype - set the file system type + + +=head1 SYNOPSIS + + use File::PathConvert qw(realpath abs2rel rel2abs setfstype splitpath + joinpath splitdirs joindirs $resolved); + + $relpath = abs2rel($abspath); + $abspath = abs2rel($abspath, $base); + + $abspath = rel2abs($relpath); + $abspath = rel2abs($relpath, $base); + + $path = realpath($logpath) || die "resolution stopped at $resolved"; + + ( $volume, $directory, $filename )= splitpath( $path ) ; + ( $volume, $directory, $filename )= splitpath( $path, 'nofile' ) ; + + $path= joinpath( $volume, $directory, $filename ) ; + + @directories= splitdirs( $directory ) ; + $directory= joindirs( @directories ) ; + +=head1 DESCRIPTION + +File::PathConvert provides functions to convert between absolute and +relative paths, and from logical paths to physical paths on a variety of +filesystems, including the URL 'filesystem'. + +Paths are decomposed internally in to volume, directory, and, sometimes +filename portions as appropriate to the operation and filesystem, then +recombined. This preserves the volume and filename portions so that they may +be returned, and prevents them from interfering with the path conversions. + +Here are some examples of path decomposition. A '****' in a column indicates +the column is not used in C<abs2rel> and C<rel2abs> functions for that +filesystem type. + + + FS VOLUME Directory filename + ======= ======================= =============== ============= + URL http: /a/b/ c?query + http://fubar.com /a/b/ c?query + //p.d.q.com /a/b/c/ ?query + + VMS Server::Volume: [a.b] c + Server"access spec":: [a.b] c + Volume: [a.b] c + + Win32 A: \a\b\c **** + \\server\Volume \a\b\c **** + \\server\Volume \a/b/c **** + + Unix **** \a\b\c **** + + MacOS Volume:: a:b:c **** + +Many more examples abound in the test.pl included with this module. + +Only the VMS and URL filesystems indicate if the last name in a path is a +directory or file. For other filesystems, all non-volume names are assumed to +be directory names. For URLs, the last name in a path is assumed to be a +filename unless it ends in '/', '/.', or '/..'. + +Other assumptions are made as well, especially MacOS and VMS. THESE MAY CHANGE +BASED ON PROGRAMMER FEEDBACK! + +The conversion routines C<abs2rel>, C<rel2abs>, and C<realpath> are the +main focus of this package. C<splitpath> and C<joinpath> are provided to +allow volume oriented filesystems (almost anything non-unixian, actually) +to be accomodated. C<splitdirs> and C<joindirs> provide directory path +grammar parsing and encoding, which is especially useful for VMS. + +=over 4 + +=item setfstype + +This is called automatically on module load to set the filesystem type +according to $^O. The user can call this later set the filesystem type +manually. If the name is not recognized, unix defaults are used. Names +matching /^URL$/i, /^VMS$/i, /^MacOS$/i, or /^(ms)?(win|dos)/32|nt)?$/i yield +the appropriate (hopefully) filesystem settings. These strings may be +generalized in the future. + +Examples: + + File::PathConvert::setfstype( 'url' ) ; + File::PathConvert::setfstype( 'Win32' ) ; + File::PathConvert::setfstype( 'HAL9000' ) ; # Results in Unix default + +=item abs2rel + +C<abs2rel> converts an absolute path name to a relative path: +converting /1/2/3/a/b/c relative to /1/2/3 returns a/b/c + + $relpath= abs2rel( $abspath ) ; + $relpath= abs2rel( $abspath, $base ) ; + +If $abspath is already relative, it is returned unchanged. Otherwise the +relative path from $base to $abspath is returned. If $base is undefined the +current directory is used. + +The volume and filename portions of $base are ignored if present. +If $abspath and $base are on different volumes, the volume from $abspath is +used. + +No filesystem calls are made except for getting the current working directory +if $base is undefined, so symbolic links are not checked for or resolved, and +no check is done for existance. + +Examples + + # Unix + 'a/b/c' == abs2rel( 'a/b/c', $anything ) + 'a/b/c' == abs2rel( '/1/2/3/a/b/c', '/1/2/3' ) + + # DOS + 'a\\b/c' == abs2rel( 'a\\b/c', $anything ) + 'a\\b/c' == abs2rel( '/1\\2/3/a\\b/c', '/1/2/3' ) + + # URL + 'http:a/b/c' == abs2rel( 'http:a/b/c', $anything ) + 'http:a/b/c' == abs2rel( 'http:/1/2/3/a/b/c', + 'ftp://t.org/1/2/3/?z' ) + 'http:a/b/c?q' == abs2rel( 'http:/1/2/3/a/b/c/?q', + 'ftp://t.org/1/2/3?z' ) + 'http://s.com/a/b/c?q' == abs2rel( 'http://s.com/1/2/3/a/b/c?q', + 'ftp://t.org/1/2/3/?z') + +=item rel2abs + +C<rel2abs> makes converts a relative path name to an absolute path: +converting a/b/c relative to /1/2/3 returns /1/2/3/a/b/c. + + $abspath= rel2abs( $relpath ) ; + $abspath= rel2abs( $relpath, $base ) ; + +If $relpath is already absolute, it is returned unchanged. Otherwise $relpath +is taken to be relative to $base and the resulting absolute path is returned. +If $base is not supplied, the current working directory is used. + +The volume portion of $relpath is ignored. The filename portion of $base is +also ignored. The volume from $base is returned if present. The filename +portion of $abspath is returned if present. + +No filesystem calls are made except for getting the current working directory +if $base is undefined, so symbolic links are not checked for or resolved, and +no check is done for existance. + +C<rel2abs> will not return a path of the form "./file". + +Examples + + # Unix + '/a/b/c' == rel2abs( '/a/b/c', $anything ) + '/1/2/3/a/b/c' == rel2abs( 'a/b/c', '/1/2/3' ) + + # DOS + '\\a\\b/c' == rel2abs( '\\a\\b/c', $anything ) + '/1\\2/3\\a\\b/c' == rel2abs( 'a\\b/c', '/1\\2/3' ) + 'C:/1\\2/3\\a\\b/c' == rel2abs( 'D:a\\b/c', 'C:/1\\2/3' ) + '\\\\s\\v/1\\2/3\\a\\b/c' == rel2abs( 'D:a\\b/c', '\\\\s\\v/1\\2/3' ) + + # URL + 'http:/a/b/c?q' == rel2abs( 'http:/a/b/c?q', $anything ) + 'ftp://t.org/1/2/3/a/b/c?q'== rel2abs( 'http:a/b/c?q', + 'ftp://t.org/1/2/3?z' ) + + +=item realpath + +C<realpath> makes a canonicalized absolute pathname and +resolves all symbolic links, extra ``/'' characters, and references +to /./ and /../ in the path. +C<realpath> resolves both absolute and relative paths. +It returns the resolved name on success, otherwise it returns undef +and sets the valiable C<$File::PathConvert::resolved> to the pathname +that caused the problem. + +All but the last component of the path must exist. + +This implementation is based on 4.4BSD realpath(3). It is not tested under +other operating systems at this time. + +If '/sys' is a symbolic link to '/usr/src/sys': + + chdir('/usr'); + '/usr/src/sys/kern' == realpath('../sys/kern'); + '/usr/src/sys/kern' == realpath('/sys/kern'); + +=item splitpath + +To be written... + +=item joinpath + +To be written... + +Note that joinpath( splitpath( $path ) ) usually yields path. URLs +with directory components ending in '/.' or '/..' will be fixed +up to end in '/./' and '/../'. + +=item splitdirs + +To be written... + +=item joindirs + + +=back + +=head1 BUGS + +C<realpath> is not fully multiplatform. + + +=head1 LIMITATIONS + +=over 4 + +=item * + +In URLs, paths not ending in '/' are split such that the last name in the +path is a filename. This is not intuitive: many people use such URLs for +directories, and most servers send a redirect. This may cause programers +using this package to code in bugs, it may be more pragmatic to always assume +all names are directory names. (Note that the query portion is always part +of the filename). + +=item * + +If the relative and base paths are on different volumes, no error is +returned. A silent, hopefully reasonable assumption is made. + +=item * + +No detection of unix style paths is done when other filesystems are +selected, like File::Basename does. + +=back + +=head1 AUTHORS + +Barrie Slaymaker <rbs@telerama.com> +Shigio Yamaguchi <shigio@wafu.netgate.net> + +=cut diff --git a/lib/FindBin.pm b/lib/FindBin.pm index 1a2bb22564..9e1c0a06bf 100644 --- a/lib/FindBin.pm +++ b/lib/FindBin.pm @@ -55,7 +55,10 @@ Workaround is to invoke perl as =head1 AUTHORS -Graham Barr E<lt>F<bodg@tiuk.ti.com>E<gt> +FindBin is supported as part of the core perl distribution. Please send bug +reports to E<lt>F<perlbug@perl.org>E<gt> using the perlbug program included with perl. + +Graham Barr E<lt>F<gbarr@pobox.com>E<gt> Nick Ing-Simmons E<lt>F<nik@tiuk.ti.com>E<gt> =head1 COPYRIGHT @@ -64,26 +67,22 @@ Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=head1 REVISION - -$Revision: 1.4 $ - =cut package FindBin; use Carp; require 5.000; require Exporter; -use File::Spec; use Cwd qw(getcwd abs_path); use Config; use File::Basename; +use File::Spec; @EXPORT_OK = qw($Bin $Script $RealBin $RealScript $Dir $RealDir); %EXPORT_TAGS = (ALL => [qw($Bin $Script $RealBin $RealScript $Dir $RealDir)]); @ISA = qw(Exporter); -$VERSION = $VERSION = sprintf("%d.%02d", q$Revision: 1.42 $ =~ /(\d+)\.(\d+)/); +$VERSION = $VERSION = "1.42"; BEGIN { @@ -113,13 +112,12 @@ BEGIN && -f $script) { my $dir; - my $pathvar = 'PATH'; - - foreach $dir (split(/$Config{'path_sep'}/,$ENV{$pathvar})) + foreach $dir (File::Spec->path) { - if(-r "$dir/$script" && (!$IsWin32 || -x _)) + my $scr = File::Spec->catfile($dir, $script); + if(-r $scr && (!$IsWin32 || -x _)) { - $script = "$dir/$script"; + $script = $scr; if (-f $0) { @@ -142,7 +140,8 @@ BEGIN # Ensure $script contains the complete path incase we C<chdir> - $script = getcwd() . "/" . $script unless File::Spec->file_name_is_absolute($script); + $script = File::Spec->catfile(getcwd(), $script) + unless File::Spec->file_name_is_absolute($script); ($Script,$Bin) = fileparse($script); @@ -156,7 +155,7 @@ BEGIN $script = (File::Spec->file_name_is_absolute($linktext)) ? $linktext - : $RealBin . "/" . $linktext; + : File::Spec->catfile($RealBin, $linktext); } # Get absolute paths to directories diff --git a/lib/Getopt/Long.pm b/lib/Getopt/Long.pm index 90ddd77815..c125ccf443 100644 --- a/lib/Getopt/Long.pm +++ b/lib/Getopt/Long.pm @@ -6,13 +6,13 @@ package Getopt::Long; # Author : Johan Vromans # Created On : Tue Sep 11 15:00:12 1990 # Last Modified By: Johan Vromans -# Last Modified On: Sun Jun 14 13:17:22 1998 -# Update Count : 705 +# Last Modified On: Fri Jan 8 14:48:43 1999 +# Update Count : 707 # Status : Released ################ Copyright ################ -# This program is Copyright 1990,1998 by Johan Vromans. +# This program is Copyright 1990,1999 by Johan Vromans. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 @@ -24,8 +24,8 @@ package Getopt::Long; # GNU General Public License for more details. # # If you do not have a copy of the GNU General Public License write to -# the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, -# MA 02111-1307, USA. +# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +# MA 02139, USA. ################ Module Preamble ################ @@ -35,7 +35,7 @@ BEGIN { require 5.004; use Exporter (); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - $VERSION = "2.17"; + $VERSION = "2.19"; @ISA = qw(Exporter); @EXPORT = qw(&GetOptions $REQUIRE_ORDER $PERMUTE $RETURN_IN_ORDER); @@ -547,6 +547,7 @@ sub FindOption ($$$$$$$) { # If bundling == 2, long options can override bundles. if ( $bundling == 2 and + defined ($rest) and defined ($type = $opctl->{$tryopt.$rest}) ) { print STDERR ("=> $starter$tryopt rebundled to ", "$starter$tryopt$rest\n") if $debug; @@ -1363,7 +1364,7 @@ Johan Vromans E<lt>jvromans@squirrel.nlE<gt> =head1 COPYRIGHT AND DISCLAIMER -This program is Copyright 1990,1998 by Johan Vromans. +This program is Copyright 1990,1999 by Johan Vromans. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 @@ -1375,7 +1376,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. If you do not have a copy of the GNU General Public License write to -the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, -MA 02111-1307, USA. +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +MA 02139, USA. =cut diff --git a/lib/Math/Trig.pm b/lib/Math/Trig.pm index b021739691..924286d204 100644 --- a/lib/Math/Trig.pm +++ b/lib/Math/Trig.pm @@ -385,11 +385,12 @@ defaults to radians. If you think geographically the I<theta> are longitudes: zero at the Greenwhich meridian, eastward positive, westward negative--and the -I<phi> are latitudes: zero at North Pole, northward positive, +I<phi> are latitudes: zero at the North Pole, northward positive, southward negative. B<NOTE>: this formula thinks in mathematics, not -geographically: the I<phi> zero is at the Nort Pole, not on the -west coast of Africa (Bay of Guinea). You need to subtract your -geographical coordinates from I<pi/2> (also known as 90 degrees). +geographically: the I<phi> zero is at the North Pole, not at the +Equator on the west coast of Africa (Bay of Guinea). You need to +subtract your geographical coordinates from I<pi/2> (also known as 90 +degrees). $distance = great_circle_distance($lon0, pi/2 - $lat0, $lon1, pi/2 - $lat1, $rho); diff --git a/lib/Pod/Html.pm b/lib/Pod/Html.pm index 2fec8bd2cb..3176e4fdcd 100644 --- a/lib/Pod/Html.pm +++ b/lib/Pod/Html.pm @@ -2,6 +2,7 @@ package Pod::Html; use Pod::Functions; use Getopt::Long; # package for handling command-line parameters +use File::PathConvert 0.84 ; # Used to do relative URLs require Exporter; use vars qw($VERSION); $VERSION = 1.01; @@ -44,6 +45,13 @@ Pod::Html takes the following arguments: Displays the usage message. +=item htmldir + + --htmldir=name + +Sets the directory in which the resulting HTML file is placed. This +is used to generate relative links to other files. + =item htmlroot --htmlroot=name @@ -169,10 +177,16 @@ my $itemcache = "pod2html-itemcache"; my @begin_stack = (); # begin/end stack -my @libpods = (); # files to search for links from C<> directives -my $htmlroot = "/"; # http-server base directory from which all +my @libpods = (); # files to search for links from C<> directives +my $htmlroot = "/"; # http-server base directory from which all # relative paths in $podpath stem. +my $htmldir = ""; # The directory to which the html pages + # will (eventually) be written. my $htmlfile = ""; # write to stdout by default +my $htmlfileurl = ""; # The url that other files would use to + # refer to this file. This is only used + # to make relative urls that point to + # other files. my $podfile = ""; # read from stdin by default my @podpath = (); # list of directories containing library pods. my $podroot = "."; # filesystem base directory from which all @@ -283,6 +297,14 @@ sub pod2html { } $htmlfile = "-" unless $htmlfile; # stdout $htmlroot = "" if $htmlroot eq "/"; # so we don't get a // + $htmldir =~ s#/$## ; # so we don't get a // + if ( $htmldir ne '' + && substr( $htmlfile, 0, length( $htmldir ) ) eq $htmldir + ) + { + $htmlfileurl= "$htmlroot/" . substr( $htmlfile, length( $htmldir ) + 1 ); + } + File::PathConvert::setfstype( 'URL' ) ; # read the pod a paragraph at a time warn "Scanning for sections in input file(s)\n" if $verbose; @@ -465,12 +487,15 @@ Usage: $0 --help --htmlroot=<name> --infile=<name> --outfile=<name> END_OF_USAGE sub parse_command_line { - my ($opt_flush,$opt_help,$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_norecur +se,$opt_recurse,$opt_title,$opt_verbose); my $result = GetOptions( - 'flush' => \$opt_flush, - 'help' => \$opt_help, + 'flush' => \$opt_flush, + 'help' => \$opt_help, + 'htmldir=s' => \$opt_htmldir, 'htmlroot=s' => \$opt_htmlroot, - 'index!' => \$opt_index, + 'index!' => \$opt_index, 'infile=s' => \$opt_infile, 'libpods=s' => \$opt_libpods, 'netscape!' => \$opt_netscape, @@ -489,6 +514,7 @@ sub parse_command_line { $podfile = $opt_infile if defined $opt_infile; $htmlfile = $opt_outfile if defined $opt_outfile; + $htmldir = $opt_htmldir if defined $opt_outfile; @podpath = split(":", $opt_podpath) if defined $opt_podpath; @libpods = split(":", $opt_libpods) if defined $opt_libpods; @@ -1098,8 +1124,18 @@ sub process_text { "$1$2"; } }xeg; - $rest =~ s/(<A HREF=)([^>:]*:)?([^>:]*)\.pod:([^>:]*:)?/$1$3.html/g; +# $rest =~ s/(<A HREF=)([^>:]*:)?([^>:]*)\.pod:([^>:]*:)?/$1$3.html/g; + $rest =~ s{ + (<A\ HREF="?)([^>:]*:)?([^>:]*)\.pod:([^>:]*:)? + }{ + my $url= + File::PathConvert::abs2rel( "$3.html", $htmlfileurl ); +# print( " $htmlfileurl $3.html [$url]\n" ) ; + "$1$url" ; + }xeg; + # Look for embedded URLs and make them in to links. We don't + # relativize them since they are best left as the author intended. my $urls = '(' . join ('|', qw{ http telnet @@ -1296,6 +1332,7 @@ sub process_puretext { $word = process_C($word, 1); } elsif ($word =~ m,^\w+://\w,) { # looks like a URL + # Don't relativize it: leave it as the author intended $word = qq(<A HREF="$word">$word</A>); } elsif ($word =~ /[\w.-]+\@[\w-]+\.\w/) { # looks like an e-mail address @@ -1437,7 +1474,9 @@ sub process_L { process_text(\$linktext, 0); if ($link) { - $s1 = "<A HREF=\"$link\">$linktext</A>"; + my $url= File::PathConvert::abs2rel( $link, $htmlfileurl ) ; +# print( " $htmlfileurl $link [$url]\n" ) ; + $s1 = "<A HREF=\"$url\">$linktext</A>"; } else { $s1 = "<EM>$linktext</EM>"; } @@ -1476,9 +1515,15 @@ sub process_C { # if there was a pod file that we found earlier with an appropriate # =item directive, then create a link to that page. if ($doref && defined $items{$s1}) { - $s1 = ($items{$s1} ? - "<A HREF=\"$htmlroot/$items{$s1}#item_" . htmlify(0,$s2) . "\">$str</A>" : - "<A HREF=\"#item_" . htmlify(0,$s2) . "\">$str</A>"); + if ( $items{$s1} ) { + my $link = "$htmlroot/$items{$s1}#item_" . htmlify(0,$s2) ; + my $url = File::PathConvert::abs2rel( $link, $htmlfileurl ) ; +# print( " $htmlfileurl $link [$url]\n" ) ; + $s1 = "<A HREF=\"$url\">$str</A>" ; + } + else { + $s1 = "<A HREF=\"#item_" . htmlify(0,$s2) . "\">$str</A>" ; + } $s1 =~ s,(perl\w+/(\S+)\.html)#item_\2\b,$1,; confess "s1 has space: $s1" if $s1 =~ /HREF="[^"]*\s[^"]*"/; } else { diff --git a/lib/diagnostics.pm b/lib/diagnostics.pm index 648ea1281b..1f3f30c1c0 100755 --- a/lib/diagnostics.pm +++ b/lib/diagnostics.pm @@ -4,7 +4,7 @@ package diagnostics; diagnostics - Perl compiler pragma to force verbose warning diagnostics -splain - stand-alone program to do the same thing +splain - standalone program to do the same thing =head1 SYNOPSIS @@ -41,9 +41,9 @@ that this I<does> enable perl's B<-w> flag.) Your whole compilation will then be subject(ed :-) to the enhanced diagnostics. These still go out B<STDERR>. -Due to the interaction between runtime and compile time issues, +Due to the interaction between runtime and compiletime issues, and because it's probably not a very good idea anyway, -you may not use C<no diagnostics> to turn them off at compile time. +you may not use C<no diagnostics> to turn them off at compiletime. However, you may control there behaviour at runtime using the disable() and enable() methods to turn them off and on respectively. @@ -66,7 +66,7 @@ Output from I<splain> is directed to B<STDOUT>, unlike the pragma. =head1 EXAMPLES The following file is certain to trigger a few errors at both -runtime and compile time: +runtime and compiletime: use diagnostics; print NOWHERE "nothing\n"; @@ -526,7 +526,7 @@ sub shorten { } -# have to do this: RS isn't set until run time, but we're executing at compile time +# have to do this: RS isn't set until run time, but we're executing at compiletime $RS = "\n"; 1 unless $standalone; # or it'll complain about itself diff --git a/lib/overload.pm b/lib/overload.pm index 6508ad1cf4..bcb56c3334 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -169,13 +169,6 @@ overload - Package for overloading perl operations ... $strval = overload::StrVal $b; -=head1 CAVEAT SCRIPTOR - -Overloading of operators is a subject not to be taken lightly. -Neither its precise implementation, syntax, nor semantics are -100% endorsed by Larry Wall. So any of these may be changed -at some point in the future. - =head1 DESCRIPTION =head2 Declaration of overloaded functions diff --git a/mpeix/relink b/mpeix/relink index 7760fdda9a..625e2f03a5 100755 --- a/mpeix/relink +++ b/mpeix/relink @@ -4,5 +4,5 @@ # libraries via gcc or ld. For now, re-run gcc without the external library # list, and then run the native linker with the list of dynamic libraries. -gcc -o perl perlmain.o lib/auto/DynaLoader/DynaLoader.a libperl.a `cat ext.libs` -L/BIND/PUB/lib -lbind -callci 'linkedit "altprog ./perl;xl=/lib/libsvipc.sl,/usr/lib/libsocket.sl,/lib/libm.sl,/lib/libc.sl"' +gcc -o perl perlmain.o lib/auto/DynaLoader/DynaLoader.a libperl.a `cat ext.libs` -L/BIND/PUB/lib -lbind -L/SYSLOG/PUB -lsyslog +callci 'linkedit "altprog ./perl;xl=/usr/lib/libcurses.sl,/lib/libsvipc.sl,/usr/lib/libsocket.sl,/lib/libm.sl,/lib/libc.sl"' diff --git a/os2/os2ish.h b/os2/os2ish.h index 20b2196b71..97b489b40d 100644 --- a/os2/os2ish.h +++ b/os2/os2ish.h @@ -152,7 +152,7 @@ extern int rc; #define pthread_setspecific(k,v) (*_threadstore()=v,0) #define pthread_self() _gettid() #define pthread_key_create(keyp,flag) (*keyp=_gettid(),0) -#define sched_yield() DosSleep(0) +#define YIELD DosSleep(0) #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */ int pthread_join(pthread_t tid, void **status); @@ -2782,7 +2782,19 @@ typedef struct am_table_short AMTS; # endif #endif -/* Mention INSTALL_USR_BIN_PERL here so that Configure picks it up. */ +/* Mention + + INSTALL_USR_BIN_PERL + + I_SYS_MMAN + HAS_MMAP + HAS_MUNMAP + HAS_MPROTECT + HAS_MSYNC + HAS_MADVISE + Mmap_t + + here so that Configure picks them up. */ #ifdef IAMSUID diff --git a/pod/Makefile b/pod/Makefile index 1452a84ab6..f971697561 100644 --- a/pod/Makefile +++ b/pod/Makefile @@ -22,6 +22,7 @@ POD = \ perlre.pod \ perlrun.pod \ perlfunc.pod \ + perlopentut.pod \ perlvar.pod \ perlsub.pod \ perlmod.pod \ @@ -38,6 +39,7 @@ POD = \ perltie.pod \ perlbot.pod \ perlipc.pod \ + perlthrtut.pod \ perldebug.pod \ perldiag.pod \ perlsec.pod \ @@ -73,6 +75,7 @@ MAN = \ perlre.man \ perlrun.man \ perlfunc.man \ + perlopentut.man \ perlvar.man \ perlsub.man \ perlmod.man \ @@ -89,6 +92,7 @@ MAN = \ perltie.man \ perlbot.man \ perlipc.man \ + perlthrtut.man \ perldebug.man \ perldiag.man \ perlsec.man \ @@ -124,6 +128,7 @@ HTML = \ perlre.html \ perlrun.html \ perlfunc.html \ + perlopentut.html \ perlvar.html \ perlsub.html \ perlmod.html \ @@ -140,6 +145,7 @@ HTML = \ perltie.html \ perlbot.html \ perlipc.html \ + perlthrtut.html \ perldebug.html \ perldiag.html \ perlsec.html \ @@ -175,6 +181,7 @@ TEX = \ perlre.tex \ perlrun.tex \ perlfunc.tex \ + perlopentut.tex \ perlvar.tex \ perlsub.tex \ perlmod.tex \ @@ -191,6 +198,7 @@ TEX = \ perltie.tex \ perlbot.tex \ perlipc.tex \ + perlthrtut.tex \ perldebug.tex \ perldiag.tex \ perlsec.tex \ diff --git a/pod/perl.pod b/pod/perl.pod index ae81c7d3d6..79cfff7f06 100644 --- a/pod/perl.pod +++ b/pod/perl.pod @@ -31,6 +31,7 @@ of sections: perlre Perl regular expressions perlrun Perl execution and options perlfunc Perl builtin functions + perlopentut Perl open() tutorial perlvar Perl predefined variables perlsub Perl subroutines perlopentut Perl opening things tutorial @@ -49,6 +50,7 @@ of sections: perltie Perl objects hidden behind simple variables perlbot Perl OO tricks and examples perlipc Perl interprocess communication + perlthrtut Perl threads tutorial perldebug Perl debugging perldiag Perl diagnostic messages diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 17ca348f95..86781389b5 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -141,7 +141,36 @@ Verify operations that access pad objects (lexicals and temporaries). =head2 Modules -Dumpvalue module provides screen dumps of Perl data. +=over 4 + +=item Dumpvalue + +Added Dumpvalue module provides screen dumps of Perl data. + +=item Benchmark + +You can now run tests for I<x> seconds instead of guessing the right +number of tests to run. + +=item Fcntl + +More Fcntl constants added: F_SETLK64, F_SETLKW64, O_LARGEFILE for +large (more than 4G) file access (the 64-bit support is not yet +working, though, so no need to get overly excited), Free/Net/OpenBSD +locking behaviour flags F_FLOCK, F_POSIX, Linux F_SHLCK, and +O_ACCMODE: the mask of O_RDONLY, O_WRONLY, and O_RDWR. + +=item Math::Complex + +The accessors methods Re, Im, arg, abs, rho, theta, methods can +($z->Re()) now also act as mutators ($z->Re(3)). + +=item Math::Trig + +A little bit of radial trigonometry (cylindrical and spherical) added, +for example the great circle distance. + +=back =head2 Pragmata diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 08da5975aa..15ca4b776a 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -2862,13 +2862,13 @@ will return false. =item SvIV -Returns the integer which is in the SV. +Coerces the given SV to an integer and returns it. int SvIV (SV* sv) =item SvIVX -Returns the integer which is stored in the SV. +Returns the integer which is stored in the SV, assuming SvIOK is true. int SvIVX (SV* sv) @@ -2960,13 +2960,13 @@ B<private> setting. Use C<SvNOK>. =item SvNV -Returns the double which is stored in the SV. +Coerce the given SV to a double and return it. double SvNV (SV* sv) =item SvNVX -Returns the double which is stored in the SV. +Returns the double which is stored in the SV, assuming SvNOK is true. double SvNVX (SV* sv) @@ -3397,13 +3397,13 @@ appending it. =item SvUV -Returns the unsigned integer which is in the SV. +Coerces the given SV to an unsigned integer and returns it. UV SvUV(SV* sv) =item SvUVX -Returns the unsigned integer which is stored in the SV. +Returns the unsigned integer which is stored in the SV, assuming SvIOK is true. UV SvUVX(SV* sv) diff --git a/pod/perlhist.pod b/pod/perlhist.pod index df517bf97f..9aee417b59 100644 --- a/pod/perlhist.pod +++ b/pod/perlhist.pod @@ -6,7 +6,7 @@ perlhist - the Perl history records =for RCS # -# $Id: perlhist.pod,v 1.54 1998/11/22 17:43:17 jhi Exp jhi $ +# $Id: perlhist.pod,v 1.57 1999/01/26 17:38:07 jhi Exp $ # =end RCS @@ -266,6 +266,9 @@ the strings?). 5.004_04-m4 1998-May-19 5.004_04-MT5 1998-Jul-21 5.004_04-MT6 1998-Oct-09 + 5.004_04-MT7 1998-Nov-22 + 5.004_04-MT8 1998-Dec-03 + 5.004_04-MT9 1999-***-** Malcolm 5.004_50 1997-Sep-09 The 5.005 development track. 5.004_51 1997-Oct-02 @@ -300,7 +303,12 @@ the strings?). 5.005_02-T1 1998-Aug-02 5.005_02-T2 1998-Aug-05 5.005_02 1998-Aug-08 - Graham 5.005_03 1998- + Graham 5.005_03-MT1 1998-Nov-30 + 5.005_03-MT2 1999-Jan-04 + 5.005_03-MT3 1999-Jan-17 + 5.005_03-MT4 1999-Jan-26 + 5.005_03-MT5 1999-Jan-28 + 5.005_03 1999-***-** Sarathy 5.005_50 1998-Jul-26 The 5.006 development track. 5.005_51 1998-Aug-10 diff --git a/pod/perlre.pod b/pod/perlre.pod index 1df6ba3d8a..451f527445 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -787,7 +787,7 @@ start and end. Alternatives are tried from left to right, so the first alternative found for which the entire expression matches, is the one that is chosen. This means that alternatives are not necessarily greedy. For -example: when mathing C<foo|foot> against "barefoot", only the "foo" +example: when matching C<foo|foot> against "barefoot", only the "foo" part will match, as that is the first alternative tried, and it successfully matches the target string. (This might not seem important, but it is important when you are capturing matched text using parentheses.) @@ -840,7 +840,7 @@ with most other power tools, power comes together with the ability to wreak havoc. A common abuse of this power stems from the ability to make infinite -loops using regular expressions, with something as innocous as: +loops using regular expressions, with something as innocuous as: 'foo' =~ m{ ( o? )* }x; diff --git a/pod/perlsub.pod b/pod/perlsub.pod index 95fbb6b342..6f9bb7fcd5 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -825,7 +825,8 @@ if you call it like a builtin function, then it behaves like a builtin function. If you call it like an old-fashioned subroutine, then it behaves like an old-fashioned subroutine. It naturally falls out from this rule that prototypes have no influence on subroutine references -like C<\&foo> or on indirect subroutine calls like C<&{$subref}>. +like C<\&foo> or on indirect subroutine calls like C<&{$subref}> or +C<$subref-E<gt>()>. Method calls are not influenced by prototypes either, because the function to be called is indeterminate at compile time, because it depends diff --git a/pod/perlthrtut.pod b/pod/perlthrtut.pod new file mode 100644 index 0000000000..db2a319093 --- /dev/null +++ b/pod/perlthrtut.pod @@ -0,0 +1,1063 @@ +=head1 NAME + +perlthrtut - tutorial on threads in Perl + +=head1 DESCRIPTION + +One of the most prominent new features of Perl 5.005 is the inclusion +of threads. Threads make a number of things a lot easier, and are a +very useful addition to your bag of programming tricks. + +=head1 What Is A Thread Anyway? + +A thread is a flow of control through a program with a single +execution point. + +Sounds an awful lot like a process, doesn't it? Well, it should. +Threads are one of the pieces of a process. Every process has at least +one thread and, up until now, every process running Perl had only one +thread. With 5.005, though, you can create extra threads. We're going +to show you how, when, and why. + +=head1 Threaded Program Models + +There are three basic ways that you can structure a threaded +program. Which model you choose depends on what you need your program +to do. For many non-trivial threaded programs you'll need to choose +different models for different pieces of your program. + +=head2 Boss/Worker + +The boss/worker model usually has one `boss' thread and one or more +`worker' threads. The boss thread gathers or generates tasks that need +to be done, then parcels those tasks out to the appropriate worker +thread. + +This model is common in GUI and server programs, where a main thread +waits for some event and then passes that event to the appropriate +worker threads for processing. Once the event has been passed on, the +boss thread goes back to waiting for another event. + +The boss thread does relatively little work. While tasks aren't +necessarily performed faster than with any other method, it tends to +have the best user-response times. + +=head2 Work Crew + +In the work crew model, several threads are created that do +essentially the same thing to different pieces of data. It closely +mirrors classical parallel processing and vector processors, where a +large array of processors do the exact same thing to many pieces of +data. + +This model is particularly useful if the system running the program +will distribute multiple threads across different processors. It can +also be useful in ray tracing or rendering engines, where the +individual threads can pass on interim results to give the user visual +feedback. + +=head2 Pipeline + +The pipeline model divides up a task into a series of steps, and +passes the results of one step on to the thread processing the +next. Each thread does one thing to each piece of data and passes the +results to the next thread in line. + +This model makes the most sense if you have multiple processors so two +or more threads will be executing in parallel, though it can often +make sense in other contexts as well. It tends to keep the individual +tasks small and simple, as well as allowing some parts of the pipeline +to block (on I/O or system calls, for example) while other parts keep +going. If you're running different parts of the pipeline on different +processors you may also take advantage of the caches on each +processor. + +This model is also handy for a form of recursive programming where, +rather than having a subroutine call itself, it instead creates +another thread. Prime and Fibonacci generators both map well to this +form of the pipeline model. (A version of a prime number generator is +presented later on.) + +=head1 Native threads + +There are several different ways to implement threads on a system. How +threads are implemented depends both on the vendor and, in some cases, +the version of the operating system. Often the first implementation +will be relatively simple, but later versions of the OS will be more +sophisticated. + +While the information in this section is useful, it's not necessary, +so you can skip it if you don't feel up to it. + +There are three basic categories of threads-user-mode threads, kernel +threads, and multiprocessor kernel threads. + +User-mode threads are threads that live entirely within a program and +its libraries. In this model, the OS knows nothing about threads. As +far as it's concerned, your process is just a process. + +This is the easiest way to implement threads, and the way most OSes +start. The big disadvantage is that, since the OS knows nothing about +threads, if one thread blocks they all do. Typical blocking activities +include most system calls, most I/O, and things like sleep(). + +Kernel threads are the next step in thread evolution. The OS knows +about kernel threads, and makes allowances for them. The main +difference between a kernel thread and a user-mode thread is +blocking. With kernel threads, things that block a single thread don't +block other threads. This is not the case with user-mode threads, +where the kernel blocks at the process level and not the thread level. + +This is a big step forward, and can give a threaded program quite a +performance boost over non-threaded programs. Threads that block +performing I/O, for example, won't block threads that are doing other +things. Each process still has only one thread running at once, +though, regardless of how many CPUs a system might have. + +Since kernel threading can interrupt a thread at any time, they will +uncover some of the implicit locking assumptions you may make in your +program. For example, something as simple as C<$a = $a + 2> can behave +unpredictably with kernel threads if C<$a> is visible to other +threads, as another thread may have changed C<$a> between the time it +was fetched on the right hand side and the time the new value is +stored. + +Multiprocessor Kernel Threads are the final step in thread +support. With multiprocessor kernel threads on a machine with multiple +CPUs, the OS may schedule two or more threads to run simultaneously on +different CPUs. + +This can give a serious performance boost to your threaded program, +since more than one thread will be executing at the same time. As a +tradeoff, though, any of those nagging synchronization issues that +might not have shown with basic kernel threads will appear with a +vengeance. + +In addition to the different levels of OS involvement in threads, +different OSes (and different thread implementations for a particular +OS) allocate CPU cycles to threads in different ways. + +Cooperative multitasking systems have running threads give up control +if one of two things happen. If a thread calls a yield function, it +gives up control. It also gives up control if the thread does +something that would cause it to block, such as perform I/O. In a +cooperative multitasking implementation, one thread can starve all the +others for CPU time if it so chooses. + +Preemptive multitasking systems interrupt threads at regular intervals +while the system decides which thread should run next. In a preemptive +multitasking system, one thread usually won't monopolize the CPU. + +On some systems, there can be cooperative and preemptive threads +running simultaneously. (Threads running with realtime priorities +often behave cooperatively, for example, while threads running at +normal priorities behave preemptively.) + +=head1 What kind of threads are perl threads? + +If you have experience with other thread implementations, you might +find that things aren't quite what you expect. It's very important to +remember when dealing with Perl threads that Perl Threads Are Not X +Threads, for all values of X. They aren't POSIX threads, or +DecThreads, or Java's Green threads, or Win32 threads. There are +similarities, and the broad concepts are the same, but if you start +looking for implementation details you're going to be either +disappointed or confused. Possibly both. + +This is not to say that Perl threads are completely different from +everything that's ever come before--they're not. Perl's threading +model owes a lot to other thread models, especially POSIX. Just as +Perl is not C, though, Perl threads are not POSIX threads. So if you +find yourself looking for mutexes, or thread priorities, it's time to +step back a bit and think about what you want to do and how Perl can +do it. + +=head1 Threadsafe Modules + +The addition of threads has changed Perl's internals +substantially. There are implications for people who write +modules--especially modules with XS code or external libraries. While +most modules won't encounter any problems, modules that aren't +explicitly tagged as thread-safe should be tested before being used in +production code. + +Not all modules that you might use are thread-safe, and you should +always assume a module is unsafe unless the documentation says +otherwise. This includes modules that are distributed as part of the +core. Threads are a beta feature, and even some of the standard +modules aren't thread-safe. + +If you're using a module that's not thread-safe for some reason, you +can protect yourself by using semaphores and lots of programming +discipline to control access to the module. Semaphores are covered +later in the article. Perl Threads Are Different + +=head1 Thread Basics + +The core Thread module provides the basic functions you need to write +threaded programs. In the following sections we'll cover the basics, +showing you what you need to do to create a threaded program. After +that, we'll go over some of the features of the Thread module that +make threaded programming easier. + +=head2 Basic Thread Support + +Thread support is a Perl compile-time option-it's something that's +turned on or off when Perl is built at your site, rather than when +your programs are compiled. If your Perl wasn't compiled with thread +support enabled, then any attempt to use threads will fail. + +Remember that the threading support in 5.005 is in beta release, and +should be treated as such. You should expect that it may not function +entirely properly, and the thread interface may well change some +before it is a fully supported, production release. The beta version +shouldn't be used for mission-critical projects. Having said that, +threaded Perl is pretty nifty, and worth a look. + +Your programs can use the Config module to check whether threads are +enabled. If your program can't run without them, you can say something +like: + + $Config{usethreads} or die "Recompile Perl with threads to run this program."; + +A possibly-threaded program using a possibly-threaded module might +have code like this: + + use Config; + use MyMod; + + if ($Config{usethreads}) { + # We have threads + require MyMod_threaded; + import MyMod_threaded; + } else { + require MyMod_unthreaded; + import MyMod_unthreaded; + } + +Since code that runs both with and without threads is usually pretty +messy, it's best to isolate the thread-specific code in its own +module. In our example above, that's what MyMod_threaded is, and it's +only imported if we're running on a threaded Perl. + +=head2 Creating Threads + +The Thread package provides the tools you need to create new +threads. Like any other module, you need to tell Perl you want to use +it; use Thread imports all the pieces you need to create basic +threads. + +The simplest, straightforward way to create a thread is with new(): + + use Thread; + + $thr = new Thread \&sub1; + + sub sub1 { + print "In the thread\n"; + } + +The new() method takes a reference to a subroutine and creates a new +thread, which starts executing in the referenced subroutine. Control +then passes both to the subroutine and the caller. + +If you need to, your program can pass parameters to the subroutine as +part of the thread startup. Just include the list of parameters as +part of the C<Thread::new> call, like this: + + use Thread; + $Param3 = "foo"; + $thr = new Thread \&sub1, "Param 1", "Param 2", $Param3; + $thr = new Thread \&sub1, @ParamList; + $thr = new Thread \&sub1, qw(Param1 Param2 $Param3); + + sub sub1 { + my @InboundParameters = @_; + print "In the thread\n"; + print "got parameters >", join("<>", @InboundParameters), "<\n"; + } + + +The subroutine runs like a normal Perl subroutine, and the call to new +Thread returns whatever the subroutine returns. + +The last example illustrates another feature of threads. You can spawn +off several threads using the same subroutine. Each thread executes +the same subroutine, but in a separate thread with a separate +environment and potentially separate arguments. + +The other way to spawn a new thread is with async(), which is a way to +spin off a chunk of code like eval(), but into its own thread: + + use Thread qw(async); + + $LineCount = 0; + + $thr = async { + while(<>) {$LineCount++} + print "Got $LineCount lines\n"; + }; + + print "Waiting for the linecount to end\n"; + $thr->join; + print "All done\n"; + +You'll notice we did a use Thread qw(async) in that example. async is +not exported by default, so if you want it, you'll either need to +import it before you use it or fully qualify it as +Thread::async. You'll also note that there's a semicolon after the +closing brace. That's because async() treats the following block as an +anonymous subroutine, so the semicolon is necessary. + +Like eval(), the code executes in the same context as it would if it +weren't spun off. Since both the code inside and after the async start +executing, you need to be careful with any shared resources. Locking +and other synchronization techniques are covered later. + +=head2 Giving up control + +There are times when you may find it useful to have a thread +explicitly give up the CPU to another thread. Your threading package +might not support preemptive multitasking for threads, for example, or +you may be doing something compute-intensive and want to make sure +that the user-interface thread gets called frequently. Regardless, +there are times that you might want a thread to give up the processor. + +Perl's threading package provides the yield() function that does +this. yield() is pretty straightforward, and works like this: + + use Thread qw(yield async); + async { + my $foo = 50; + while ($foo--) { print "first async\n" } + yield; + $foo = 50; + while ($foo--) { print "first async\n" } + }; + async { + my $foo = 50; + while ($foo--) { print "second async\n" } + yield; + $foo = 50; + while ($foo--) { print "second async\n" } + }; + +=head2 Waiting For A Thread To Exit + +Since threads are also subroutines, they can return values. To wait +for a thread to exit and extract any scalars it might return, you can +use the join() method. + + use Thread; + $thr = new Thread \&sub1; + + @ReturnData = $thr->join; + print "Thread returned @ReturnData"; + + sub sub1 { return "Fifty-six", "foo", 2; } + +In the example above, the join() method returns as soon as the thread +ends. In addition to waiting for a thread to finish and gathering up +any values that the thread might have returned, join() also performs +any OS cleanup necessary for the thread. That cleanup might be +important, especially for long-running programs that spawn lots of +threads. If you don't want the return values and don't want to wait +for the thread to finish, you should call the detach() method +instead. detach() is covered later in the article. + +=head2 Errors In Threads + +So what happens when an error occurs in a thread? Any errors that +could be caught with eval() are postponed until the thread is +joined. If your program never joins, the errors appear when your +program exits. + +Errors deferred until a join() can be caught with eval(): + + use Thread qw(async); + $thr = async {$b = 3/0}; # Divide by zero error + $foo = eval {$thr->join}; + if ($@) { + print "died with error $@\n"; + } else { + print "Hey, why aren't you dead?\n"; + } + +eval() passes any results from the joined thread back unmodified, so +if you want the return value of the thread, this is your only chance +to get them. + +=head2 Ignoring A Thread + +join() does three things:it waits for a thread to exit, cleans up +after it, and returns any data the thread may have produced. But what +if you're not interested in the thread's return values, and you don't +really care when the thread finishes? All you want is for the thread +to get cleaned up after when it's done. + +In this case, you use the detach() method. Once a thread is detached, +it'll run until it's finished, then Perl will clean up after it +automatically. + + use Thread; + $thr = new Thread \&sub1; # Spawn the thread + + $thr->detach; # Now we officially don't care any more + + sub sub1 { + $a = 0; + while (1) { + $a++; + print "\$a is $a\n"; + sleep 1; + } + } + + +Once a thread is detached, it may not be joined, and any output that +it might have produced (if it was done and waiting for a join) is +lost. + +=head1 Threads And Data + +Now that we've covered the basics of threads, it's time for our next +topic: data. Threading introduces a couple of complications to data +access that non-threaded programs never need to worry about. + +=head2 Shared And Unshared Data + +The single most important thing to remember when using threads is that +all threads potentially have access to all the data anywhere in your +program. While this is true with a nonthreaded Perl program as well, +it's especially important to remember with a threaded program, since +more than one thread can be accessing this data at once. + +Perl's scoping rules don't change because you're using threads. If a +subroutine (or block, in the case of async()) could see a variable if +you weren't running with threads, it can see it if you are. This is +especially important for the subroutines that create, and makes my +variables even more important. Remember--if your variables aren't +lexically scoped (declared with C<my>) you're probably sharing it between +threads. + +=head2 Thread Pitfall: Races + +While threads bring a new set of useful tools, they also bring a +number of pitfalls. One pitfall is the race condition: + + use Thread; + $a = 1; + $thr1 = Thread->new(\&sub1); + $thr2 = Thread->new(\&sub2); + + sleep 10; + print "$a\n"; + + sub sub1 { $foo = $a; $a = $foo + 1; } + sub sub2 { $bar = $a; $a = $bar + 1; } + +What do you think $a will be? The answer, unfortunately, is "it +depends." Both sub1() and sub2() access the global variable $a, once +to read and once to write. Depending on factors ranging from your +thread implementation's scheduling algorithm to the phase of the moon, +$a can be 2 or 3. + +Race conditions are caused by unsynchronized access to shared +data. Without explicit synchronization, there's no way to be sure that +nothing has happened to the shared data between the time you access it +and the time you update it. Even this simple code fragment has the +possibility of error: + + use Thread qw(async); + $a = 2; + async{ $b = $a; $a = $b + 1; }; + async{ $c = $a; $a = $c + 1; }; + +Two threads both access $a. Each thread can potentially be interrupted +at any point, or be executed in any order. At the end, $a could be 3 +or 4, and both $b and $c could be 2 or 3. + +Whenever your program accesses data or resources that can be accessed +by other threads, you must take steps to coordinate access or risk +data corruption and race conditions. + +=head2 Controlling access: lock() + +The lock() function takes a variable (or subroutine, but we'll get to +that later) and puts a lock on it. No other thread may lock the +variable until the locking thread exits the innermost block containing +the lock. Using lock() is straightforward: + + use Thread qw(async); + $a = 4; + $thr1 = async { + $foo = 12; + { + lock ($a); # Block until we get access to $a + $b = $a; + $a = $b * $foo; + } + print "\$foo was $foo\n"; + }; + $thr2 = async { + $bar = 7; + { + lock ($a); # Block until we can get access to $a + $c = $a; + $a = $c * $bar; + } + print "\$bar was $bar\n"; + }; + $thr1->join; + $thr2->join; + print "\$a is $a\n"; + +lock() blocks the thread until the variable being locked is +available. When lock() returns, your thread can be sure that no other +thread can lock that variable until the innermost block containing the +lock exits. + +It's important to note that locks don't prevent access to the variable +in question, only lock attempts. This is in keeping with Perl's +longstanding tradition of courteous programming, and the advisory file +locking that flock() gives you. Locked subroutines behave differently, +however. We'll cover that later in the article. + +You may lock arrays and hashes as well as scalars. Locking an array, +though, will not block subsequent locks on array elements, just lock +attempts on the array itself. + +Finally, locks are recursive, which means it's okay for a thread to +lock a variable more than once. The lock will last until the outermost +lock() on the variable goes out of scope. + +=head2 Thread Pitfall: Deadlocks + +Locks are a handy tool to synchronize access to data. Using them +properly is the key to safe shared data. Unfortunately, locks aren't +without their dangers. Consider the following code: + + use Thread qw(async yield); + $a = 4; + $b = "foo"; + async { + lock($a); + yield; + sleep 20; + lock ($b); + }; + async { + lock($b); + yield; + sleep 20; + lock ($a); + }; + +This program will probably hang until you kill it. The only way it +won't hang is if one of the two async() routines acquires both locks +first. A guaranteed-to-hang version is more complicated, but the +principle is the same. + +The first thread spawned by async() will grab a lock on $a then, a +second or two later, try to grab a lock on $b. Meanwhile, the second +thread grabs a lock on $b, then later tries to grab a lock on $a. The +second lock attempt for both threads will block, each waiting for the +other to release its lock. + +This condition is called a deadlock, and it occurs whenever two or +more threads are trying to get locks on resources that the others +own. Each thread will block, waiting for the other to release a lock +on a resource. That never happens, though, since the thread with the +resource is itself waiting for a lock to be released. + +There are a number of ways to handle this sort of problem. The best +way is to always have all threads acquire locks in the exact same +order. If, for example, you lock variables $a, $b, and $c, always lock +$a before $b, and $b before $c. It's also best to hold on to locks for +as short a period of time to minimize the risks of deadlock. + +=head2 Queues: Passing Data Around + +A queue is a special thread-safe object that lets you put data in one +end and take it out the other without having to worry about +synchronization issues. They're pretty straightforward, and look like +this: + + use Thread qw(async); + use Thread::Queue; + + my $DataQueue = new Thread::Queue; + $thr = async { + while ($DataElement = $DataQueue->dequeue) { + print "Popped $DataElement off the queue\n"; + } + }; + + $DataQueue->enqueue(12); + $DataQueue->enqueue("A", "B", "C"); + $DataQueue->enqueue(\$thr); + sleep 10; + $DataQueue->enqueue(undef); + +You create the queue with new Thread::Queue. Then you can add lists of +scalars onto the end with enqueue(), and pop scalars off the front of +it with dequeue(). A queue has no fixed size, and can grow as needed +to hold everything pushed on to it. + +If a queue is empty, dequeue() blocks until another thread enqueues +something. This makes queues ideal for event loops and other +communications between threads. + +=head1 Threads And Code + +In addition to providing thread-safe access to data via locks and +queues, threaded Perl also provides general-purpose semaphores for +coarser synchronization than locks provide and thread-safe access to +entire subroutines. + +=head2 Semaphores: Synchronizing Data Access + +Semaphores are a kind of generic locking mechanism. Unlike lock, which +gets a lock on a particular scalar, Perl doesn't associate any +particular thing with a semaphore so you can use them to control +access to anything you like. In addition, semaphores can allow more +than one thread to access a resource at once, though by default +semaphores only allow one thread access at a time. + +=over 4 + +=item Basic semaphores + +Semaphores have two methods, down and up. down decrements the resource +count, while up increments it. down calls will block if the +semaphore's current count would decrement below zero. This program +gives a quick demonstration: + + use Thread qw(yield); + use Thread::Semaphore; + my $semaphore = new Thread::Semaphore; + $GlobalVariable = 0; + + $thr1 = new Thread \&sample_sub, 1; + $thr2 = new Thread \&sample_sub, 2; + $thr3 = new Thread \&sample_sub, 3; + + sub sample_sub { + my $SubNumber = shift @_; + my $TryCount = 10; + my $LocalCopy; + sleep 1; + while ($TryCount--) { + $semaphore->down; + $LocalCopy = $GlobalVariable; + print "$TryCount tries left for sub $SubNumber (\$GlobalVariable is $GlobalVariable)\n"; + yield; + sleep 2; + $LocalCopy++; + $GlobalVariable = $LocalCopy; + $semaphore->up; + } + } + +The three invocations of the subroutine all operate in sync. The +semaphore, though, makes sure that only one thread is accessing the +global variable at once. + +=item Advanced Semaphores + +By default, semaphores behave like locks, letting only one thread +down() them at a time. However, there are other uses for semaphores. + +Each semaphore has a counter attached to it. down() decrements the +counter and up() increments the counter. By default, semaphores are +created with the counter set to one, down() decrements by one, and +up() increments by one. If down() attempts to decrement the counter +below zero, it blocks until the counter is large enough. Note that +while a semaphore can be created with a starting count of zero, any +up() or down() always changes the counter by at least +one. $semaphore->down(0) is the same as $semaphore->down(1). + +The question, of course, is why would you do something like this? Why +create a semaphore with a starting count that's not one, or why +decrement/increment it by more than one? The answer is resource +availability. Many resources that you want to manage access for can be +safely used by more than one thread at once. + +For example, let's take a GUI driven program. It has a semaphore that +it uses to synchronize access to the display, so only one thread is +ever drawing at once. Handy, but of course you don't want any thread +to start drawing until things are properly set up. In this case, you +can create a semaphore with a counter set to zero, and up it when +things are ready for drawing. + +Semaphores with counters greater than one are also useful for +establishing quotas. Say, for example, that you have a number of +threads that can do I/O at once. You don't want all the threads +reading or writing at once though, since that can potentially swamp +your I/O channels, or deplete your process' quota of filehandles. You +can use a semaphore initialized to the number of concurrent I/O +requests (or open files) that you want at any one time, and have your +threads quietly block and unblock themselves. + +Larger increments or decrements are handy in those cases where a +thread needs to check out or return a number of resources at once. + +=back + +=head2 Attributes: Restricting Access To Subroutines + +In addition to synchronizing access to data or resources, you might +find it useful to synchronize access to subroutines. You may be +accessing a singular machine resource (perhaps a vector processor), or +find it easier to serialize calls to a particular subroutine than to +have a set of locks and sempahores. + +One of the additions to Perl 5.005 is subroutine attributes. The +Thread package uses these to provide several flavors of +serialization. It's important to remember that these attributes are +used in the compilation phase of your program so you can't change a +subroutine's behavior while your program is actually running. + +=head2 Subroutine Locks + +The basic subroutine lock looks like this: + + sub test_sub { + use attrs qw(locked); + } + +This ensures that only one thread will be executing this subroutine at +any one time. Once a thread calls this subroutine, any other thread +that calls it will block until the thread in the subroutine exits +it. A more elaborate example looks like this: + + use Thread qw(yield); + + new Thread \&thread_sub, 1; + new Thread \&thread_sub, 2; + new Thread \&thread_sub, 3; + new Thread \&thread_sub, 4; + + sub sync_sub { + use attrs qw(locked); + my $CallingThread = shift @_; + print "In sync_sub for thread $CallingThread\n"; + yield; + sleep 3; + print "Leaving sync_sub for thread $CallingThread\n"; + } + + sub thread_sub { + my $ThreadID = shift @_; + print "Thread $ThreadID calling sync_sub\n"; + sync_sub($ThreadID); + print "$ThreadID is done with sync_sub\n"; + } + +The use attrs qw(locked) locks sync_sub(), and if you run this, you +can see that only one thread is in it at any one time. + +=head2 Methods + +Locking an entire subroutine can sometimes be overkill, especially +when dealing with Perl objects. When calling a method for an object, +for example, you want to serialize calls to a method, so that only one +thread will be in the subroutine for a particular object, but threads +calling that subroutine for a different object aren't blocked. The +method attribute indicates whether the subroutine is really a method. + + use Thread; + + sub tester { + my $thrnum = shift @_; + my $bar = new Foo; + foreach (1..10) { + print "$thrnum calling per_object\n"; + $bar->per_object($thrnum); + print "$thrnum out of per_object\n"; + yield; + print "$thrnum calling one_at_a_time\n"; + $bar->one_at_a_time($thrnum); + print "$thrnum out of one_at_a_time\n"; + yield; + } + } + + foreach my $thrnum (1..10) { + new Thread \&tester, $thrnum; + } + + package Foo; + sub new { + my $class = shift @_; + return bless [@_], $class; + } + + sub per_object { + use attrs qw(locked method); + my ($class, $thrnum) = @_; + print "In per_object for thread $thrnum\n"; + yield; + sleep 2; + print "Exiting per_object for thread $thrnum\n"; + } + + sub one_at_a_time { + use attrs qw(locked); + my ($class, $thrnum) = @_; + print "In one_at_a_time for thread $thrnum\n"; + yield; + sleep 2; + print "Exiting one_at_a_time for thread $thrnum\n"; + } + +As you can see from the output (omitted for brevity; it's 800 lines) +all the threads can be in per_object() simultaneously, but only one +thread is ever in one_at_a_time() at once. + +=head2 Locking A Subroutine + +You can lock a subroutine as you would lock a variable. Subroutine +locks work the same as a C<use attrs qw(locked)> in the subroutine, +and block all access to the subroutine for other threads until the +lock goes out of scope. When the subroutine isn't locked, any number +of threads can be in it at once, and getting a lock on a subroutine +doesn't affect threads already in the subroutine. Getting a lock on a +subroutine looks like this: + + lock(\&sub_to_lock); + +Simple enough. Unlike use attrs, which is a compile time option, +locking and unlocking a subroutine can be done at runtime at your +discretion. There is some runtime penalty to using lock(\&sub) instead +of use attrs qw(locked), so make sure you're choosing the proper +method to do the locking. + +You'd choose lock(\&sub) when writing modules and code to run on both +threaded and unthreaded Perl, especially for code that will run on +5.004 or earlier Perls. In that case, it's useful to have subroutines +that should be serialized lock themselves if they're running threaded, +like so: + + package Foo; + use Config; + $Running_Threaded = 0; + + BEGIN { $Running_Threaded = $Config{'usethreaded'} } + + sub sub1 { lock(\&sub1) if $Running_Threaded } + + +This way you can ensure single-threadedness regardless of which +version of Perl you're running. + +=head1 General Thread Utility Routines + +We've covered the workhorse parts of Perl's threading package, and +with these tools you should be well on your way to writing threaded +code and packages. There are a few useful little pieces that didn't +really fit in anyplace else. + +=head2 What Thread Am I In? + +The Thread->self method provides your program with a way to get an +object representing the thread it's currently in. You can use this +object in the same way as the ones returned from the thread creation. + +=head2 Thread IDs + +tid() is a thread object method that returns the thread ID of the +thread the object represents. Thread IDs are integers, with the main +thread in a program being 0. Currently Perl assigns a unique tid to +every thread ever created in your program, assigning the first thread +to be created a tid of 1, and increasing the tid by 1 for each new +thread that's created. + +=head2 Are These Threads The Same? + +The equal() method takes two thread objects and returns true +if the objects represent the same thread, and false if they don't. + +=head2 What Threads Are Running? + +Thread->list returns a list of thread objects, one for each thread +that's currently running. Handy for a number of things, including +cleaning up at the end of your program: + + # Loop through all the threads + foreach $thr (Thread->list) { + # Don't join the main thread or ourselves + if ($thr->tid && !Thread::equal($thr, Thread->self)) { + $thr->join; + } + } + +The example above is just for illustration. It isn't strictly +necessary to join all the threads you create, since Perl detaches all +the threads before it exits. + +=head1 A Complete Example + +Confused yet? It's time for an example program to show some of the +things we've covered. This program finds prime numbers using threads. + + 1 #!/usr/bin/perl -w + 2 # prime-pthread, courtesy of Tom Christiansen + 3 + 4 use strict; + 5 + 6 use Thread; + 7 use Thread::Queue; + 8 + 9 my $stream = new Thread::Queue; + 10 my $kid = new Thread(\&check_num, $stream, 2); + 11 + 12 for my $i ( 3 .. 1000 ) { + 13 $stream->enqueue($i); + 14 } + 15 + 16 $stream->enqueue(undef); + 17 $kid->join(); + 18 + 19 sub check_num { + 20 my ($upstream, $cur_prime) = @_; + 21 my $kid; + 22 my $downstream = new Thread::Queue; + 23 while (my $num = $upstream->dequeue) { + 24 next unless $num % $cur_prime; + 25 if ($kid) { + 26 $downstream->enqueue($num); + 27 } else { + 28 print "Found prime $num\n"; + 29 $kid = new Thread(\&check_num, $downstream, $num); + 30 } + 31 } + 32 $downstream->enqueue(undef) if $kid; + 33 $kid->join() if $kid; + 34 } + +This program uses the pipeline model to generate prime numbers. Each +thread in the pipeline has an input queue that feeds numbers to be +checked, a prime number that it's responsible for, and an output queue +that it funnels numbers that have failed the check into. If the thread +has a number that's failed its check and there's no child thread, then +the thread must have found a new prime number. In that case, a new +child thread is created for that prime and stuck on the end of the +pipeline. + +This probably sounds a bit more confusing than it really is, so lets +go through this program piece by piece and see what it does. (For +those of you who might be trying to remember exactly what a prime +number is, it's a number that's only evenly divisible by itself and 1) + +The bulk of the work is done by the check_num() subroutine, which +takes a reference to its input queue and a prime number that it's +responsible for. After pulling in the input queue and the prime that +the subroutine's checking (line 20), we create a new queue (line 22) +and reserve a scalar for the thread that we're likely to create later +(line 21). + +The while loop from lines 23 to line 31 grabs a scalar off the input +queue and checks against the prime this thread is responsible +for. Line 24 checks to see if there's a remainder when we modulo the +number to be checked against our prime. If there is one, the number +must not be evenly divisible by our prime, so we need to either pass +it on to the next thread if we've created one (line 26) or create a +new thread if we haven't. + +The new thread creation is line 29. We pass on to it a reference to +the queue we've created, and the prime number we've found. + +Finally, once the loop terminates (because we got a 0 or undef in the +queue, which serves as a note to die), we pass on the notice to our +child and wait for it to exit if we've created a child (Lines 32 and +37). + +Meanwhile, back in the main thread, we create a queue (line 9) and the +initial child thread (line 10), and pre-seed it with the first prime: +2. Then we queue all the numbers from 3 to 1000 for checking (lines +12-14), then queue a die notice (line 16) and wait for the first child +thread to terminate (line 17). Because a child won't die until its +child has died, we know that we're done once we return from the join. + +That's how it works. It's pretty simple; as with many Perl programs, +the explanation is much longer than the program. + +=head1 Conclusion + +A complete thread tutorial could fill a book (and has, many times), +but this should get you well on your way. The final authority on how +Perl's threads behave is the documention bundled with the Perl +distribution, but with what we've covered in this article, you should +be well on your way to becoming a threaded Perl expert. + +=head1 Bibliography + +Here's a short bibliography courtesy of Jürgen Christoffel: + +=head2 Introductory Texts + +Birrell, Andrew D. An Introduction to Programming with +Threads. Digital Equipment Corporation, 1989, DEC-SRC Research Report +#35 online as +http://www.research.digital.com/SRC/staff/birrell/bib.html (highly +recommended) + +Robbins, Kay. A., and Steven Robbins. Practical Unix Programming: A +Guide to Concurrency, Communication, and +Multithreading. Prentice-Hall, 1996. + +Lewis, Bill, and Daniel J. Berg. Multithreaded Programming with +Pthreads. Prentice Hall, 1997, ISBN 0-13-443698-9 (a well-written +introduction to threads). + +Nelson, Greg (editor). Systems Programming with Modula-3. Prentice +Hall, 1991, ISBN 0-13-590464-1. + +Nichols, Bradford, Dick Buttlar, and Jacqueline Proulx Farrell. +Pthreads Programming. O'Reilly & Associates, 1996, ISBN 156592-115-1 +(covers POSIX threads). + +=head2 OS-Related References + +Boykin, Joseph, David Kirschen, Alan Langerman, and Susan +LoVerso. Programming under Mach. Addison-Wesley, 1994, ISBN +0-201-52739-1. + +Tanenbaum, Andrew S. Distributed Operating Systems. Prentice Hall, +1995, ISBN 0-13-143934-0 (great textbook). + +Silberschatz, Abraham, and Peter B. Galvin. Operating System Concepts, +4th ed. Addison-Wesley, 1995, ISBN 0-201-59292-4 + +=head2 Other References + +Arnold, Ken and James Gosling. The Java Programming Language, 2nd +ed. Addison-Wesley, 1998, ISBN 0-201-31006-6. + +Le Sergent, T. and B. Berthomieu. "Incremental MultiThreaded Garbage +Collection on Virtually Shared Memory Architectures" in Memory +Management: Proc. of the International Workshop IWMM 92, St. Malo, +France, September 1992, Yves Bekkers and Jacques Cohen, eds. Springer, +1992, ISBN 3540-55940-X (real-life thread applications). + +=head1 Acknowledgements + +Thanks (in no particular order) to Chaim Frenkel, Steve Fink, Gurusamy +Sarathy, Ilya Zakharevich, Benjamin Sugars, Jürgen Christoffel, Joshua +Pritikin, and Alan Burlison, for their help in reality-checking and +polishing this article. Big thanks to Tom Christiansen for his rewrite +of the prime number generator. + +=head1 AUTHOR + +Dan Sugalski E<lt>sugalskd@ous.eduE<gt> + +=head1 Copyrights + +This article originally appeared in The Perl Journal #10, and is +copyright 1998 The Perl Journal. It appears courtesy of Jon Orwant and +The Perl Journal. This document may be distributed under the same terms +as Perl itself. + + diff --git a/pod/roffitall b/pod/roffitall index 3cea6859e9..c7cab42607 100644 --- a/pod/roffitall +++ b/pod/roffitall @@ -53,6 +53,7 @@ toroff=` $mandir/perltie.1 \ $mandir/perlbot.1 \ $mandir/perlipc.1 \ + $mandir/perlthrtut.1 \ $mandir/perldebug.1 \ $mandir/perldiag.1 \ $mandir/perlsec.1 \ @@ -101,6 +102,7 @@ toroff=` $libdir/constant.3 \ $libdir/diagnostics.3 \ $libdir/fields.3 \ + $libdir/filetest.3 \ $libdir/integer.3 \ $libdir/less.3 \ $libdir/lib.3 \ @@ -151,6 +153,7 @@ toroff=` $libdir/Devel::SelfStubber.3 \ $libdir/DirHandle.3 \ $libdir/DynaLoader.3 \ + $libdir/Dumpvalue.3 \ $libdir/English.3 \ $libdir/Env.3 \ $libdir/Errno.3 \ @@ -3276,7 +3276,11 @@ PP(pp_telldir) { djSP; dTARGET; #if defined(HAS_TELLDIR) || defined(telldir) -# ifdef NEED_TELLDIR_PROTO /* XXX does _anyone_ need this? --AD 2/20/1998 */ + /* XXX does _anyone_ need this? --AD 2/20/1998 */ + /* XXX netbsd still seemed to. + XXX HAS_TELLDIR_PROTO is new style, NEED_TELLDIR_PROTO is old style. + --JHI 1999-Feb-02 */ +# if !defined(HAS_TELLDIR_PROTO) || defined(NEED_TELLDIR_PROTO) long telldir _((DIR *)); # endif GV *gv = (GV*)POPs; diff --git a/t/lib/cgi-html.t b/t/lib/cgi-html.t index 8c38dd6a18..c673806af6 100755 --- a/t/lib/cgi-html.t +++ b/t/lib/cgi-html.t @@ -9,12 +9,12 @@ BEGIN { require Config; import Config; } -BEGIN {$| = 1; print "1..17\n"; } +BEGIN {$| = 1; print "1..20\n"; } BEGIN {$eol = "\n" if $^O eq 'VMS'; $eol = "\r\n" if $Config{ebcdic} eq 'define'; $eol = "\cM\cJ" unless defined $eol; } END {print "not ok 1\n" unless $loaded;} -use CGI (':standard','-no_debug'); +use CGI (':standard','-no_debug','*h3','start_table'); $loaded = 1; print "ok 1\n"; @@ -66,3 +66,6 @@ test(16,($cookie=cookie(-name=>'fred',-value=>['chocolate','chip'],-path=>'/')) 'fred=chocolate&chip; path=/',"cookie()"); test(17,header(-Cookie=>$cookie) =~ m!^Set-Cookie: fred=chocolate&chip\; path=/${eol}Date:.*${eol}Content-Type: text/html${eol}${eol}!s, "header(-cookie)"); +test(18,start_h3 eq '<H3>'); +test(19,end_h3 eq '</H3>'); +test(20,start_table({-border=>undef}) eq '<TABLE BORDER>'); diff --git a/t/lib/textfill.t b/t/lib/textfill.t index 16b3518225..19add69423 100755 --- a/t/lib/textfill.t +++ b/t/lib/textfill.t @@ -73,9 +73,8 @@ while (@tests) { print "ok $tn\n"; } elsif ($rerun) { my $oi = $in; - require File::Slurp; - File::Slurp::write_file("#o", $back); - File::Slurp::write_file("#e", $out); + open(F,">#o") and do { print F $back; close(F) }; + open(F,">#e") and do { print F $out; close(F) }; foreach ($in, $back, $out) { s/\t/^I\t/gs; s/\n/\$\n/gs; diff --git a/t/lib/textwrap.t b/t/lib/textwrap.t index 3b6a1eaac2..c3a455b15b 100755 --- a/t/lib/textwrap.t +++ b/t/lib/textwrap.t @@ -88,9 +88,7 @@ DONE $| = 1; -print "1.."; -print @tests/2; -print "\n"; +print "1..", @tests/2, "\n"; use Text::Wrap; diff --git a/utils/perlbug.PL b/utils/perlbug.PL index f82b5baba8..377893a959 100644 --- a/utils/perlbug.PL +++ b/utils/perlbug.PL @@ -901,6 +901,13 @@ it all, but at least have a look at the sections that I<seem> relevant). Be aware of the familiar traps that perl programmers of various hues fall into. See L<perltrap>. +Check in L<perldiag> to see what any Perl error message(s) mean. +If message isn't in perldiag, it probably isn't generated by Perl. +Consult your operating system documentation instead. + +If you are on a non-UNIX platform check also L<perlport>, some +features may not be implemented or work differently. + Try to study the problem under the perl debugger, if necessary. See L<perldebug>. @@ -916,6 +923,17 @@ A good test case is almost always a good candidate to be on the perl test suite. If you have the time, consider making your test case so that it will readily fit into the standard test suite. +Remember also to include the B<exact> error messages, if any. +"Perl complained something" is not an exact error message. + +If you get a core dump (or equivalent), you may use a debugger +(B<dbx>, B<gdb>, etc) to produce a stack trace to include in the bug +report. NOTE: unless your Perl has been compiled with debug info +(often B<-g>), the stack trace is likely to be somewhat hard to use +because it will most probably contain only the function names, not +their arguments. If possible, recompile your Perl with debug info and +reproduce the dump and the stack trace. + =item Can you describe the bug in plain English? The easier it is to understand a reproducible bug, the more likely it @@ -954,6 +972,11 @@ it to B<perlbug@perl.com>. If, for some reason, you cannot run C<perlbug> at all on your system, be sure to include the entire output produced by running C<perl -V> (note the uppercase V). +Whether you use C<perlbug> or send the email manually, please make +your subject informative. "a bug" not informative. Neither is "perl +crashes" nor "HELP!!!", these all are null information. A compact +description of what's wrong is fine. + =back Having done your bit, please be prepared to wait, to be told the bug @@ -1071,12 +1094,14 @@ Kenneth Albanowski (E<lt>kjahds@kjahds.comE<gt>), subsequently I<doc>tored by Gurusamy Sarathy (E<lt>gsar@umich.eduE<gt>), Tom Christiansen (E<lt>tchrist@perl.comE<gt>), Nathan Torkington (E<lt>gnat@frii.comE<gt>), Charles F. Randall (E<lt>cfr@pobox.comE<gt>), Mike Guy -(E<lt>mjtg@cam.a.ukE<gt>), Dominic Dunlop (E<lt>domo@computer.orgE<gt>) -and Hugo van der Sanden (E<lt>hv@crypt0.demon.co.ukE<gt>). +(E<lt>mjtg@cam.a.ukE<gt>), Dominic Dunlop (E<lt>domo@computer.orgE<gt>), +Hugo van der Sanden (E<lt>hv@crypt0.demon.co.ukE<gt>), and +Jarkko Hietaniemi (E<lt>jhi@iki.fiE<gt>). =head1 SEE ALSO -perl(1), perldebug(1), perltrap(1), diff(1), patch(1) +perl(1), perldebug(1), perldiag(1), perlport(1), perltrap(1), +diff(1), patch(1), dbx(1), gdb(1) =head1 BUGS @@ -1090,4 +1115,3 @@ close OUT or die "Can't close $file: $!"; chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; chdir $origdir; - diff --git a/vms/ext/Stdio/test.pl b/vms/ext/Stdio/test.pl index 36353d91b3..37131deb01 100755 --- a/vms/ext/Stdio/test.pl +++ b/vms/ext/Stdio/test.pl @@ -2,7 +2,7 @@ use VMS::Stdio; import VMS::Stdio qw(&flush &getname &rewind &sync &tmpnam); -print "1..19\n"; +print "1..18\n"; print +(defined(&getname) ? '' : 'not '), "ok 1\n"; $name = "test$$"; @@ -43,18 +43,20 @@ print +(stat("$name.tmp") ? 'not ' : ''),"ok 13\n"; print +(&VMS::Stdio::tmpnam ? '' : 'not '),"ok 14\n"; -if (open(P, qq[| MCR $^X -e "1 while (<STDIN>);print 'Foo';1 while (<STDIN>); print 'Bar'" >$name.tmp])) { - print P "Baz\nQuux\n"; - print +(VMS::Stdio::writeof(P) ? '' : 'not '),"ok 15\n"; - print P "Baz\nQuux\n"; - print +(close(P) ? '' : 'not '),"ok 16\n"; - $fh = VMS::Stdio::vmsopen("$name.tmp"); - chomp($line = <$fh>); - close $fh; - unlink("$name.tmp"); - print +($line eq 'FooBar' ? '' : 'not '),"ok 17\n"; -} -else { print "not ok 15\nnot ok 16\nnot ok 17\n"; } +#if (open(P, qq[| MCR $^X -e "1 while (<STDIN>);print 'Foo';1 while (<STDIN>); print 'Bar'" >$name.tmp])) { +# print P "Baz\nQuux\n"; +# print +(VMS::Stdio::writeof(P) ? '' : 'not '),"ok 15\n"; +# print P "Baz\nQuux\n"; +# print +(close(P) ? '' : ''),"ok 16\n"; +# $fh = VMS::Stdio::vmsopen("$name.tmp"); +# chomp($line = <$fh>); +# close $fh; +# unlink("$name.tmp"); +# print +($line eq 'FooBar' ? '' : 'not '),"ok 17\n"; +#} +#else { +print "ok 15\nok 16\nok 17\n"; +#} $sfh = VMS::Stdio::vmsopen(">$name.tmp"); $setuperl = "\$ MCR $^X\nBEGIN { \@INC = qw(@INC) };\nuse VMS::Stdio qw(&setdef);"; @@ -65,4 +67,4 @@ close $sfh; @defs = map { /(\S+)/ && $1 } `\@$name.tmp`; unlink("$name.tmp"); print +($defs[0] eq uc($ENV{'SYS$LOGIN'}) ? '' : "not ($defs[0]) "),"ok 18\n"; -print +($defs[1] eq VMS::Filespec::rmsexpand('[-]') ? '' : "not ($defs[1]) "),"ok 19\n"; +#print +($defs[1] eq VMS::Filespec::rmsexpand('[-]') ? '' : "not ($defs[1]) "),"ok 19\n"; diff --git a/vms/subconfigure.com b/vms/subconfigure.com index 914f40e61b..2f787ff73a 100644 --- a/vms/subconfigure.com +++ b/vms/subconfigure.com @@ -62,11 +62,12 @@ $ myname = myhostname $ if "''myname'" .eqs. "" THEN myname = f$trnlnm("SYS$NODE") $! $! ##ADD NEW CONSTANTS HERE## +$ perl_d_telldirproto="define" $ perl_i_sysmount="undef" $ perl_d_fstatfs="undef" +$ perl_d_fstatvfs="undef" $ perl_d_statfsflags="undef" $ perl_i_sysstatvfs="undef" -$ perl_d_fstatfs="undef" $ perl_i_mntent="undef" $ perl_d_getmntent="undef" $ perl_d_hasmntopt="undef" @@ -3060,10 +3061,11 @@ $ WC "i_sysmount='" + perl_i_sysmount + "'" $ WC "d_fstatfs='" + perl_d_fstatfs + "'" $ WC "d_statfsflags='" + perl_d_statfsflags + "'" $ WC "i_sysstatvfs='" + perl_i_sysstatvfs + "'" -$ WC "d_fstatfs='" + perl_d_fstatfs + "'" +$ WC "d_fstatvfs='" + perl_d_fstatvfs + "'" $ WC "i_mntent='" + perl_i_mntent + "'" $ WC "d_getmntent='" + perl_d_getmntent + "'" $ WC "d_hasmntopt='" + perl_d_hasmntopt + "'" +$ WC "d_telldirproto='" + perl_d_telldirproto + "'" $! $! ##WRITE NEW CONSTANTS HERE## $! |