From: Uri Guttman Date: Fri, 8 May 2009 06:08:41 +0000 (-0400) Subject: edited all .t tests to not use use_ok to load File::Slurp. they now all X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=997098525898485838522aa547a080189cb7a313;p=urisagit%2FFile-Slurp.git edited all .t tests to not use use_ok to load File::Slurp. they now all load it directly with a use command. --- diff --git a/Changes b/Changes index 8728426..ebfd369 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,9 @@ Revision history for Perl extension File::FastSlurp. - Refactored the extras/slurp_bench.pl script. It has options, a key the benchmarks, help and more benchmarks. - Reordered changes so recent entries are first + - Added error check on atomic rename and test for it + Thanks to Daniel Scott Sterling + 9999.12 Thu Feb 2 02:26:31 EST 2006 - Fixed bug on windows with classic slurping and File::Slurp not diff --git a/Makefile b/Makefile index 4bb3b9b..691e427 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # This Makefile is for the File::Slurp extension to perl. # # It was generated automatically by MakeMaker version -# 6.17 (Revision: 1.133) from the contents of +# 6.42 (Revision: 41145) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! @@ -21,36 +21,37 @@ # --- MakeMaker const_config section: -# These definitions are from config.sh (via /usr/local/lib/perl5/5.8.6/sun4-solaris/Config.pm) +# These definitions are from config.sh (via /usr/lib/perl/5.10/Config.pm) # They may have been overridden via Makefile.PL or on the command line AR = ar -CC = gcc +CC = cc CCCDLFLAGS = -fPIC -CCDLFLAGS = +CCDLFLAGS = -Wl,-E DLEXT = so DLSRC = dl_dlopen.xs -LD = gcc -LDDLFLAGS = -G -L/usr/local/lib -LDFLAGS = -L/usr/local/lib -LIBC = /lib/libc.so +EXE_EXT = +FULL_AR = /usr/bin/ar +LD = cc +LDDLFLAGS = -shared -O2 -g -L/usr/local/lib +LDFLAGS = -L/usr/local/lib +LIBC = /lib/libc-2.9.so LIB_EXT = .a OBJ_EXT = .o -OSNAME = solaris -OSVERS = 2.9 +OSNAME = linux +OSVERS = 2.6.24-16-server RANLIB = : -SITELIBEXP = /usr/local/lib/perl5/site_perl/5.8.6 -SITEARCHEXP = /usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris +SITELIBEXP = /usr/local/share/perl/5.10.0 +SITEARCHEXP = /usr/local/lib/perl/5.10.0 SO = so -EXE_EXT = -FULL_AR = /usr/ccs/bin/ar -VENDORARCHEXP = -VENDORLIBEXP = +VENDORARCHEXP = /usr/lib/perl5 +VENDORLIBEXP = /usr/share/perl5 # --- MakeMaker constants section: AR_STATIC_ARGS = cr DIRFILESEP = / +DFSEP = $(DIRFILESEP) NAME = File::Slurp NAME_SYM = File_Slurp VERSION = 9999.12 @@ -66,56 +67,60 @@ INST_BIN = blib/bin INST_LIB = blib/lib INST_MAN1DIR = blib/man1 INST_MAN3DIR = blib/man3 -MAN1EXT = 1 -MAN3EXT = 3 +MAN1EXT = 1p +MAN3EXT = 3pm INSTALLDIRS = site DESTDIR = -PREFIX = -PERLPREFIX = /usr/local -SITEPREFIX = /usr/local -VENDORPREFIX = -INSTALLPRIVLIB = $(PERLPREFIX)/lib/perl5/5.8.6 +PREFIX = /usr +PERLPREFIX = $(PREFIX) +SITEPREFIX = $(PREFIX)/local +VENDORPREFIX = $(PREFIX) +INSTALLPRIVLIB = $(PERLPREFIX)/share/perl/5.10 DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) -INSTALLSITELIB = $(SITEPREFIX)/lib/perl5/site_perl/5.8.6 +INSTALLSITELIB = $(SITEPREFIX)/share/perl/5.10.0 DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) -INSTALLVENDORLIB = +INSTALLVENDORLIB = $(VENDORPREFIX)/share/perl5 DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) -INSTALLARCHLIB = $(PERLPREFIX)/lib/perl5/5.8.6/sun4-solaris +INSTALLARCHLIB = $(PERLPREFIX)/lib/perl/5.10 DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) -INSTALLSITEARCH = $(SITEPREFIX)/lib/perl5/site_perl/5.8.6/sun4-solaris +INSTALLSITEARCH = $(SITEPREFIX)/lib/perl/5.10.0 DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) -INSTALLVENDORARCH = +INSTALLVENDORARCH = $(VENDORPREFIX)/lib/perl5 DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) INSTALLBIN = $(PERLPREFIX)/bin DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) INSTALLSITEBIN = $(SITEPREFIX)/bin DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) -INSTALLVENDORBIN = +INSTALLVENDORBIN = $(VENDORPREFIX)/bin DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) INSTALLSCRIPT = $(PERLPREFIX)/bin DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) -INSTALLMAN1DIR = $(PERLPREFIX)/man/man1 +INSTALLSITESCRIPT = $(SITEPREFIX)/bin +DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT) +INSTALLVENDORSCRIPT = $(VENDORPREFIX)/bin +DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT) +INSTALLMAN1DIR = $(PERLPREFIX)/share/man/man1 DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) INSTALLSITEMAN1DIR = $(SITEPREFIX)/man/man1 DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) -INSTALLVENDORMAN1DIR = +INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/share/man/man1 DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) -INSTALLMAN3DIR = $(PERLPREFIX)/man/man3 +INSTALLMAN3DIR = $(PERLPREFIX)/share/man/man3 DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) INSTALLSITEMAN3DIR = $(SITEPREFIX)/man/man3 DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) -INSTALLVENDORMAN3DIR = +INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/share/man/man3 DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) -PERL_LIB = /usr/local/lib/perl5/5.8.6 -PERL_ARCHLIB = /usr/local/lib/perl5/5.8.6/sun4-solaris +PERL_LIB = /usr/share/perl/5.10 +PERL_ARCHLIB = /usr/lib/perl/5.10 LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile -MAKEFILE_OLD = $(FIRST_MAKEFILE).old -MAKE_APERL_FILE = $(FIRST_MAKEFILE).aperl +MAKEFILE_OLD = Makefile.old +MAKE_APERL_FILE = Makefile.aperl PERLMAINCC = $(CC) -PERL_INC = /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE -PERL = /usr/local/bin/perl -FULLPERL = /usr/local/bin/perl +PERL_INC = /usr/lib/perl/5.10/CORE +PERL = /usr/bin/perl +FULLPERL = /usr/bin/perl ABSPERL = $(PERL) PERLRUN = $(PERL) FULLPERLRUN = $(FULLPERL) @@ -127,14 +132,15 @@ PERL_CORE = 0 PERM_RW = 644 PERM_RWX = 755 -MAKEMAKER = /usr/local/lib/perl5/5.8.6/ExtUtils/MakeMaker.pm -MM_VERSION = 6.17 -MM_REVISION = 1.133 +MAKEMAKER = /usr/share/perl/5.10/ExtUtils/MakeMaker.pm +MM_VERSION = 6.42 +MM_REVISION = 41145 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. +MAKE = make FULLEXT = File/Slurp BASEEXT = Slurp PARENT_NAME = File @@ -143,6 +149,7 @@ VERSION_FROM = lib/File/Slurp.pm OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic +BOOTDEP = # Handy lists of source code files: XS_FILES = @@ -151,11 +158,10 @@ O_FILES = H_FILES = MAN1PODS = MAN3PODS = Slurp.pm \ - lib/File/Slurp.pm \ - slurp_article.pod + lib/File/Slurp.pm # Where is the Config information that we are using/depend on -CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h +CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h # Where to build things INST_LIBDIR = $(INST_LIB)/File @@ -175,40 +181,22 @@ PERL_ARCHIVE_AFTER = TO_INST_PM = Slurp.pm \ - carp.pl \ - lib/File/Slurp.pm \ - seek.pl \ - slurp_article.pod \ - slurp_bench.pl \ - split.pl \ - sysread.pl + lib/File/Slurp.pm PM_TO_BLIB = Slurp.pm \ $(INST_LIB)/File/Slurp.pm \ - carp.pl \ - $(INST_LIB)/File/carp.pl \ lib/File/Slurp.pm \ - blib/lib/File/Slurp.pm \ - seek.pl \ - $(INST_LIB)/File/seek.pl \ - split.pl \ - $(INST_LIB)/File/split.pl \ - sysread.pl \ - $(INST_LIB)/File/sysread.pl \ - slurp_article.pod \ - $(INST_LIB)/File/slurp_article.pod \ - slurp_bench.pl \ - $(INST_LIB)/File/slurp_bench.pl + blib/lib/File/Slurp.pm # --- MakeMaker platform_constants section: -MM_Unix_VERSION = 1.42 +MM_Unix_VERSION = 6.42 PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc # --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto -AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' +AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' -- @@ -228,20 +216,24 @@ TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 -MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath -EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime +MKPATH = $(ABSPERLRUN) "-MExtUtils::Command" -e mkpath +EQUALIZE_TIMESTAMP = $(ABSPERLRUN) "-MExtUtils::Command" -e eqtime ECHO = echo ECHO_N = echo -n UNINST = 0 VERBINST = 0 -MOD_INSTALL = $(PERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' -DOC_INSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install -UNINSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e uninstall -WARN_IF_OLD_PACKLIST = $(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist +MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' -- +DOC_INSTALL = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install +UNINSTALL = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall +WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist +MACROSTART = +MACROEND = +USEMAKEFILE = -f +FIXIN = $(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)" # --- MakeMaker makemakerdflt section: -makemakerdflt: all +makemakerdflt : all $(NOECHO) $(NOOP) @@ -284,19 +276,15 @@ DISTVNAME = File-Slurp-9999.12 # --- MakeMaker pasthru section: -PASTHRU = LIB="$(LIB)"\ - LIBPERL_A="$(LIBPERL_A)"\ +PASTHRU = LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ - PREFIX="$(PREFIX)"\ - OPTIMIZE="$(OPTIMIZE)"\ - PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\ - PASTHRU_INC="$(PASTHRU_INC)" + PREFIX="$(PREFIX)" # --- MakeMaker special_targets section: -.SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) +.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) -.PHONY: all config static dynamic test linkext manifest +.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir @@ -320,45 +308,61 @@ pure_all :: config pm_to_blib subdirs linkext subdirs :: $(MYEXTLIB) $(NOECHO) $(NOOP) -config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists +config :: $(FIRST_MAKEFILE) blibdirs $(NOECHO) $(NOOP) -config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) +help : + perldoc ExtUtils::MakeMaker -config :: $(INST_AUTODIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) -$(INST_AUTODIR)/.exists :: /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h - $(NOECHO) $(MKPATH) $(INST_AUTODIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h $(INST_AUTODIR)/.exists +# --- MakeMaker blibdirs section: +blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists + $(NOECHO) $(NOOP) - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_AUTODIR) +# Backwards compat with 6.18 through 6.25 +blibdirs.ts : blibdirs + $(NOECHO) $(NOOP) -$(INST_LIBDIR)/.exists :: /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h +$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_LIBDIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h $(INST_LIBDIR)/.exists + $(NOECHO) $(CHMOD) 755 $(INST_LIBDIR) + $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_LIBDIR) +$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_ARCHLIB) + $(NOECHO) $(CHMOD) 755 $(INST_ARCHLIB) + $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists -$(INST_ARCHAUTODIR)/.exists :: /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h +$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_AUTODIR) + $(NOECHO) $(CHMOD) 755 $(INST_AUTODIR) + $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists + +$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h $(INST_ARCHAUTODIR)/.exists + $(NOECHO) $(CHMOD) 755 $(INST_ARCHAUTODIR) + $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) +$(INST_BIN)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_BIN) + $(NOECHO) $(CHMOD) 755 $(INST_BIN) + $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists -config :: $(INST_MAN3DIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) +$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_SCRIPT) + $(NOECHO) $(CHMOD) 755 $(INST_SCRIPT) + $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists +$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_MAN1DIR) + $(NOECHO) $(CHMOD) 755 $(INST_MAN1DIR) + $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists -$(INST_MAN3DIR)/.exists :: /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h +$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_MAN3DIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h $(INST_MAN3DIR)/.exists - - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) + $(NOECHO) $(CHMOD) 755 $(INST_MAN3DIR) + $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists -help: - perldoc ExtUtils::MakeMaker # --- MakeMaker linkext section: @@ -403,15 +407,10 @@ POD2MAN = $(POD2MAN_EXE) manifypods : pure_all \ Slurp.pm \ - lib/File/Slurp.pm \ - slurp_article.pod \ - Slurp.pm \ - lib/File/Slurp.pm \ - slurp_article.pod - $(NOECHO) $(POD2MAN) --section=3 --perm_rw=$(PERM_RW)\ + lib/File/Slurp.pm + $(NOECHO) $(POD2MAN) --section=$(MAN3EXT) --perm_rw=$(PERM_RW) \ Slurp.pm $(INST_MAN3DIR)/File::Slurp.$(MAN3EXT) \ - lib/File/Slurp.pm $(INST_MAN3DIR)/File::Slurp.$(MAN3EXT) \ - slurp_article.pod $(INST_MAN3DIR)/File::slurp_article.$(MAN3EXT) + lib/File/Slurp.pm $(INST_MAN3DIR)/File::Slurp.$(MAN3EXT) @@ -437,8 +436,25 @@ clean_subdirs : # the Makefile here so a later make realclean still has a makefile to use. clean :: clean_subdirs - -$(RM_RF) ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all $(INST_ARCHAUTODIR)/extralibs.ld perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9][0-9] - -$(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) + - $(RM_F) \ + *$(LIB_EXT) core \ + core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \ + core.[0-9][0-9] $(BASEEXT).bso \ + pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \ + $(BASEEXT).x $(BOOTSTRAP) \ + perl$(EXE_EXT) tmon.out \ + *$(OBJ_EXT) pm_to_blib \ + $(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \ + core.[0-9][0-9][0-9][0-9][0-9] *perl.core \ + core.*perl.*.? $(MAKE_APERL_FILE) \ + perl $(BASEEXT).def \ + core.[0-9][0-9][0-9] mon.out \ + lib$(BASEEXT).def perlmain.c \ + perl.exe so_locations \ + $(BASEEXT).exp + - $(RM_RF) \ + blib + - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) # --- MakeMaker realclean_subdirs section: @@ -447,33 +463,36 @@ realclean_subdirs : # --- MakeMaker realclean section: - -# Delete temporary files (via clean) and also delete installed files +# Delete temporary files (via clean) and also delete dist files realclean purge :: clean realclean_subdirs - $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR) - $(RM_RF) $(DISTVNAME) - $(RM_F) $(INST_LIB)/File/slurp_article.pod $(INST_LIB)/File/seek.pl blib/lib/File/Slurp.pm $(MAKEFILE_OLD) $(INST_LIB)/File/split.pl $(INST_LIB)/File/slurp_bench.pl $(INST_LIB)/File/Slurp.pm - $(RM_F) $(INST_LIB)/File/sysread.pl $(FIRST_MAKEFILE) $(INST_LIB)/File/carp.pl + - $(RM_F) \ + $(MAKEFILE_OLD) $(FIRST_MAKEFILE) + - $(RM_RF) \ + $(DISTVNAME) # --- MakeMaker metafile section: -metafile : - $(NOECHO) $(ECHO) '# http://module-build.sourceforge.net/META-spec.html' > META.yml - $(NOECHO) $(ECHO) '#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#' >> META.yml - $(NOECHO) $(ECHO) 'name: File-Slurp' >> META.yml - $(NOECHO) $(ECHO) 'version: 9999.12' >> META.yml - $(NOECHO) $(ECHO) 'version_from: lib/File/Slurp.pm' >> META.yml - $(NOECHO) $(ECHO) 'installdirs: site' >> META.yml - $(NOECHO) $(ECHO) 'requires:' >> META.yml - $(NOECHO) $(ECHO) '' >> META.yml - $(NOECHO) $(ECHO) 'distribution_type: module' >> META.yml - $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.17' >> META.yml - - -# --- MakeMaker metafile_addtomanifest section: -metafile_addtomanifest: - $(NOECHO) $(PERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \ - -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' +metafile : create_distdir + $(NOECHO) $(ECHO) Generating META.yml + $(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml + $(NOECHO) $(ECHO) 'name: File-Slurp' >> META_new.yml + $(NOECHO) $(ECHO) 'version: 9999.12' >> META_new.yml + $(NOECHO) $(ECHO) 'abstract: Efficient Reading/Writing of Complete Files' >> META_new.yml + $(NOECHO) $(ECHO) 'license: ~' >> META_new.yml + $(NOECHO) $(ECHO) 'author: ' >> META_new.yml + $(NOECHO) $(ECHO) ' - Uri Guttman ' >> META_new.yml + $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.42' >> META_new.yml + $(NOECHO) $(ECHO) 'distribution_type: module' >> META_new.yml + $(NOECHO) $(ECHO) 'requires: ' >> META_new.yml + $(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml + $(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.3.html' >> META_new.yml + $(NOECHO) $(ECHO) ' version: 1.3' >> META_new.yml + -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml + + +# --- MakeMaker signature section: +signature : + cpansign -s # --- MakeMaker dist_basics section: @@ -490,15 +509,15 @@ manifest : $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest veryclean : realclean - $(RM_F) *~ *.orig */*~ */*.orig + $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old # --- MakeMaker dist_core section: dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) - $(NOECHO) $(PERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ - -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' + $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ + -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' -- tardist : $(DISTVNAME).tar$(SUFFIX) $(NOECHO) $(NOOP) @@ -531,21 +550,24 @@ shdist : distdir # --- MakeMaker distdir section: -distdir : metafile metafile_addtomanifest +create_distdir : $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" +distdir : create_distdir distmeta + $(NOECHO) $(NOOP) + # --- MakeMaker dist_test section: - disttest : distdir - cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL + cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL cd $(DISTVNAME) && $(MAKE) $(PASTHRU) cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) + # --- MakeMaker dist_ci section: ci : @@ -555,19 +577,41 @@ ci : -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" +# --- MakeMaker distmeta section: +distmeta : create_distdir metafile + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' -- + + + +# --- MakeMaker distsignature section: +distsignature : create_distdir + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' -- + $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE + cd $(DISTVNAME) && cpansign -s + + + # --- MakeMaker install section: -install :: all pure_install doc_install +install :: pure_install doc_install + $(NOECHO) $(NOOP) -install_perl :: all pure_perl_install doc_perl_install +install_perl :: pure_perl_install doc_perl_install + $(NOECHO) $(NOOP) -install_site :: all pure_site_install doc_site_install +install_site :: pure_site_install doc_site_install + $(NOECHO) $(NOOP) -install_vendor :: all pure_vendor_install doc_vendor_install +install_vendor :: pure_vendor_install doc_vendor_install + $(NOECHO) $(NOOP) pure_install :: pure_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) doc_install :: doc_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) pure__install : pure_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site @@ -575,10 +619,8 @@ pure__install : pure_site_install doc__install : doc_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site -pure_perl_install :: - $(NOECHO) $(MOD_INSTALL) \ - read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ - write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ +pure_perl_install :: all + $(NOECHO) umask 022; $(MOD_INSTALL) \ $(INST_LIB) $(DESTINSTALLPRIVLIB) \ $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ $(INST_BIN) $(DESTINSTALLBIN) \ @@ -589,79 +631,59 @@ pure_perl_install :: $(SITEARCHEXP)/auto/$(FULLEXT) -pure_site_install :: - $(NOECHO) $(MOD_INSTALL) \ +pure_site_install :: all + $(NOECHO) umask 02; $(MOD_INSTALL) \ read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(DESTINSTALLSITELIB) \ $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ $(INST_BIN) $(DESTINSTALLSITEBIN) \ - $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ $(PERL_ARCHLIB)/auto/$(FULLEXT) -pure_vendor_install :: - $(NOECHO) $(MOD_INSTALL) \ - read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ - write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ +pure_vendor_install :: all + $(NOECHO) umask 022; $(MOD_INSTALL) \ $(INST_LIB) $(DESTINSTALLVENDORLIB) \ $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ $(INST_BIN) $(DESTINSTALLVENDORBIN) \ - $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) -doc_perl_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ - "Module" "$(NAME)" \ - "installed into" "$(INSTALLPRIVLIB)" \ - LINKTYPE "$(LINKTYPE)" \ - VERSION "$(VERSION)" \ - EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod +doc_perl_install :: all -doc_site_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ +doc_site_install :: all + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLSITEARCH)/perllocal.pod + -$(NOECHO) umask 02; $(MKPATH) $(DESTINSTALLSITEARCH) + -$(NOECHO) umask 02; $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod + >> $(DESTINSTALLSITEARCH)/perllocal.pod -doc_vendor_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ - "Module" "$(NAME)" \ - "installed into" "$(INSTALLVENDORLIB)" \ - LINKTYPE "$(LINKTYPE)" \ - VERSION "$(VERSION)" \ - EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod +doc_vendor_install :: all uninstall :: uninstall_from_$(INSTALLDIRS)dirs + $(NOECHO) $(NOOP) uninstall_from_perldirs :: - $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist uninstall_from_sitedirs :: $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist uninstall_from_vendordirs :: - $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist + # --- MakeMaker force section: # Phony target to force checking subdirectories. -FORCE: +FORCE : $(NOECHO) $(NOOP) @@ -669,18 +691,17 @@ FORCE: # --- MakeMaker makefile section: - # We take a very conservative approach here, but it's worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." - $(NOECHO) $(RM_F) $(MAKEFILE_OLD) - $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) - -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP) + -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) + -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) $(PERLRUN) Makefile.PL $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" - $(NOECHO) $(ECHO) "==> Please rerun the make command. <==" + $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" false @@ -689,12 +710,12 @@ $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) # --- MakeMaker makeaperl section --- MAP_TARGET = perl -FULLPERL = /usr/local/bin/perl +FULLPERL = /usr/bin/perl $(MAP_TARGET) :: static $(MAKE_APERL_FILE) - $(MAKE) -f $(MAKE_APERL_FILE) $@ + $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ -$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) +$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR= \ @@ -712,7 +733,11 @@ TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) -test :: $(TEST_TYPE) +test :: $(TEST_TYPE) subdirs-test + +subdirs-test :: + $(NOECHO) $(NOOP) + test_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) @@ -728,14 +753,14 @@ testdb_static :: testdb_dynamic # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. -ppd: +ppd : $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd $(NOECHO) $(ECHO) ' $(DISTNAME)' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' Efficient Reading/Writing of Complete Files' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' Uri Guttman <uri@stemsystems.com>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd @@ -743,17 +768,12 @@ ppd: # --- MakeMaker pm_to_blib section: -pm_to_blib: $(TO_INST_PM) - $(NOECHO) $(PERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')'\ +pm_to_blib : $(TO_INST_PM) + $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')' -- \ Slurp.pm $(INST_LIB)/File/Slurp.pm \ - carp.pl $(INST_LIB)/File/carp.pl \ - lib/File/Slurp.pm blib/lib/File/Slurp.pm \ - seek.pl $(INST_LIB)/File/seek.pl \ - split.pl $(INST_LIB)/File/split.pl \ - sysread.pl $(INST_LIB)/File/sysread.pl \ - slurp_article.pod $(INST_LIB)/File/slurp_article.pod \ - slurp_bench.pl $(INST_LIB)/File/slurp_bench.pl - $(NOECHO) $(TOUCH) $@ + lib/File/Slurp.pm blib/lib/File/Slurp.pm + $(NOECHO) $(TOUCH) pm_to_blib + # --- MakeMaker selfdocument section: diff --git a/Makefile.old b/Makefile.old index 811e0f6..691e427 100644 --- a/Makefile.old +++ b/Makefile.old @@ -1,97 +1,146 @@ # This Makefile is for the File::Slurp extension to perl. # # It was generated automatically by MakeMaker version -# 5.45 (Revision: 1.222) from the contents of +# 6.42 (Revision: 41145) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # -# ANY CHANGES MADE HERE WILL BE LOST! +# ANY CHANGES MADE HERE WILL BE LOST! # # MakeMaker ARGV: () # # MakeMaker Parameters: -# ABSTRACT_FROM => q[lib/File/Slurp.pm] -# AUTHOR => q[Uri Guttman ] -# NAME => q[File::Slurp] -# PREREQ_PM => { } -# VERSION_FROM => q[lib/File/Slurp.pm] +# ABSTRACT_FROM => q[lib/File/Slurp.pm] +# AUTHOR => q[Uri Guttman ] +# NAME => q[File::Slurp] +# PREREQ_PM => { } +# VERSION_FROM => q[lib/File/Slurp.pm] # --- MakeMaker post_initialize section: # --- MakeMaker const_config section: -# These definitions are from config.sh (via /usr/local/lib/perl5/5.6.1/sun4-solaris/Config.pm) +# These definitions are from config.sh (via /usr/lib/perl/5.10/Config.pm) # They may have been overridden via Makefile.PL or on the command line AR = ar -CC = gcc +CC = cc CCCDLFLAGS = -fPIC -CCDLFLAGS = +CCDLFLAGS = -Wl,-E DLEXT = so DLSRC = dl_dlopen.xs -LD = gcc -LDDLFLAGS = -G -L/usr/local/lib -LDFLAGS = -L/usr/local/lib -LIBC = /lib/libc.so +EXE_EXT = +FULL_AR = /usr/bin/ar +LD = cc +LDDLFLAGS = -shared -O2 -g -L/usr/local/lib +LDFLAGS = -L/usr/local/lib +LIBC = /lib/libc-2.9.so LIB_EXT = .a OBJ_EXT = .o -OSNAME = solaris -OSVERS = 2.7 +OSNAME = linux +OSVERS = 2.6.24-16-server RANLIB = : +SITELIBEXP = /usr/local/share/perl/5.10.0 +SITEARCHEXP = /usr/local/lib/perl/5.10.0 SO = so -EXE_EXT = -FULL_AR = /usr/ccs/bin/ar +VENDORARCHEXP = /usr/lib/perl5 +VENDORLIBEXP = /usr/share/perl5 # --- MakeMaker constants section: AR_STATIC_ARGS = cr +DIRFILESEP = / +DFSEP = $(DIRFILESEP) NAME = File::Slurp -DISTNAME = File-Slurp NAME_SYM = File_Slurp -VERSION = 9999.03 -VERSION_SYM = 9999_03 -XS_VERSION = 9999.03 -INST_BIN = blib/bin -INST_EXE = blib/script -INST_LIB = blib/lib +VERSION = 9999.12 +VERSION_MACRO = VERSION +VERSION_SYM = 9999_12 +DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" +XS_VERSION = 9999.12 +XS_VERSION_MACRO = XS_VERSION +XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" INST_ARCHLIB = blib/arch INST_SCRIPT = blib/script -PREFIX = /usr/local +INST_BIN = blib/bin +INST_LIB = blib/lib +INST_MAN1DIR = blib/man1 +INST_MAN3DIR = blib/man3 +MAN1EXT = 1p +MAN3EXT = 3pm INSTALLDIRS = site -INSTALLPRIVLIB = $(PREFIX)/lib/perl5/5.6.1 -INSTALLARCHLIB = $(PREFIX)/lib/perl5/5.6.1/sun4-solaris -INSTALLSITELIB = $(PREFIX)/lib/perl5/site_perl/5.6.1 -INSTALLSITEARCH = $(PREFIX)/lib/perl5/site_perl/5.6.1/sun4-solaris -INSTALLBIN = $(PREFIX)/bin -INSTALLSCRIPT = $(PREFIX)/bin -PERL_LIB = /usr/local/lib/perl5/5.6.1 -PERL_ARCHLIB = /usr/local/lib/perl5/5.6.1/sun4-solaris -SITELIBEXP = /usr/local/lib/perl5/site_perl/5.6.1 -SITEARCHEXP = /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris +DESTDIR = +PREFIX = /usr +PERLPREFIX = $(PREFIX) +SITEPREFIX = $(PREFIX)/local +VENDORPREFIX = $(PREFIX) +INSTALLPRIVLIB = $(PERLPREFIX)/share/perl/5.10 +DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) +INSTALLSITELIB = $(SITEPREFIX)/share/perl/5.10.0 +DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) +INSTALLVENDORLIB = $(VENDORPREFIX)/share/perl5 +DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) +INSTALLARCHLIB = $(PERLPREFIX)/lib/perl/5.10 +DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) +INSTALLSITEARCH = $(SITEPREFIX)/lib/perl/5.10.0 +DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) +INSTALLVENDORARCH = $(VENDORPREFIX)/lib/perl5 +DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) +INSTALLBIN = $(PERLPREFIX)/bin +DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) +INSTALLSITEBIN = $(SITEPREFIX)/bin +DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) +INSTALLVENDORBIN = $(VENDORPREFIX)/bin +DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) +INSTALLSCRIPT = $(PERLPREFIX)/bin +DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) +INSTALLSITESCRIPT = $(SITEPREFIX)/bin +DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT) +INSTALLVENDORSCRIPT = $(VENDORPREFIX)/bin +DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT) +INSTALLMAN1DIR = $(PERLPREFIX)/share/man/man1 +DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) +INSTALLSITEMAN1DIR = $(SITEPREFIX)/man/man1 +DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) +INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/share/man/man1 +DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) +INSTALLMAN3DIR = $(PERLPREFIX)/share/man/man3 +DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) +INSTALLSITEMAN3DIR = $(SITEPREFIX)/man/man3 +DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) +INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/share/man/man3 +DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) +PERL_LIB = /usr/share/perl/5.10 +PERL_ARCHLIB = /usr/lib/perl/5.10 LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile +MAKEFILE_OLD = Makefile.old MAKE_APERL_FILE = Makefile.aperl PERLMAINCC = $(CC) -PERL_INC = /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE -PERL = /usr/local/bin/perl -FULLPERL = /usr/local/bin/perl -FULL_AR = /usr/ccs/bin/ar - -VERSION_MACRO = VERSION -DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" -XS_VERSION_MACRO = XS_VERSION -XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" -PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc +PERL_INC = /usr/lib/perl/5.10/CORE +PERL = /usr/bin/perl +FULLPERL = /usr/bin/perl +ABSPERL = $(PERL) +PERLRUN = $(PERL) +FULLPERLRUN = $(FULLPERL) +ABSPERLRUN = $(ABSPERL) +PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" +FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" +ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" +PERL_CORE = 0 +PERM_RW = 644 +PERM_RWX = 755 -MAKEMAKER = /usr/local/lib/perl5/5.6.1/ExtUtils/MakeMaker.pm -MM_VERSION = 5.45 +MAKEMAKER = /usr/share/perl/5.10/ExtUtils/MakeMaker.pm +MM_VERSION = 6.42 +MM_REVISION = 41145 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) -# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!! # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. +MAKE = make FULLEXT = File/Slurp BASEEXT = Slurp PARENT_NAME = File @@ -100,160 +149,111 @@ VERSION_FROM = lib/File/Slurp.pm OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic +BOOTDEP = # Handy lists of source code files: -XS_FILES= -C_FILES = -O_FILES = -H_FILES = -HTMLLIBPODS = -HTMLSCRIPTPODS = +XS_FILES = +C_FILES = +O_FILES = +H_FILES = MAN1PODS = -MAN3PODS = lib/File/Slurp.pm \ - slurp_article.pod -HTMLEXT = html -INST_MAN1DIR = blib/man1 -INSTALLMAN1DIR = $(PREFIX)/man/man1 -MAN1EXT = 1 -INST_MAN3DIR = blib/man3 -INSTALLMAN3DIR = $(PREFIX)/man/man3 -MAN3EXT = 3 -PERM_RW = 644 -PERM_RWX = 755 - -# work around a famous dec-osf make(1) feature(?): -makemakerdflt: all - -.SUFFIXES: .xs .c .C .cpp .cxx .cc $(OBJ_EXT) - -# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that -# some make implementations will delete the Makefile when we rebuild it. Because -# we call false(1) when we rebuild it. So make(1) is not completely wrong when it -# does so. Our milage may vary. -# .PRECIOUS: Makefile # seems to be not necessary anymore - -.PHONY: all config static dynamic test linkext manifest +MAN3PODS = Slurp.pm \ + lib/File/Slurp.pm # Where is the Config information that we are using/depend on -CONFIGDEP = $(PERL_ARCHLIB)/Config.pm $(PERL_INC)/config.h +CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h -# Where to put things: +# Where to build things INST_LIBDIR = $(INST_LIB)/File INST_ARCHLIBDIR = $(INST_ARCHLIB)/File INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) -INST_STATIC = -INST_DYNAMIC = -INST_BOOT = +INST_STATIC = +INST_DYNAMIC = +INST_BOOT = -EXPORT_LIST = +# Extra linker info +EXPORT_LIST = +PERL_ARCHIVE = +PERL_ARCHIVE_AFTER = -PERL_ARCHIVE = -PERL_ARCHIVE_AFTER = +TO_INST_PM = Slurp.pm \ + lib/File/Slurp.pm -TO_INST_PM = carp.pl \ - lib/File/Slurp.pm \ - lib/File/Slurp.pm.~1.15.~ \ - slurp_article.pod \ - slurp_bench.pl \ - split.pl \ - sysread.pl - -PM_TO_BLIB = slurp_article.pod \ - $(INST_LIBDIR)/slurp_article.pod \ - carp.pl \ - $(INST_LIBDIR)/carp.pl \ - lib/File/Slurp.pm.~1.15.~ \ - $(INST_LIB)/File/Slurp.pm.~1.15.~ \ - split.pl \ - $(INST_LIBDIR)/split.pl \ - sysread.pl \ - $(INST_LIBDIR)/sysread.pl \ - lib/File/Slurp.pm \ +PM_TO_BLIB = Slurp.pm \ $(INST_LIB)/File/Slurp.pm \ - slurp_bench.pl \ - $(INST_LIBDIR)/slurp_bench.pl + lib/File/Slurp.pm \ + blib/lib/File/Slurp.pm -# --- MakeMaker tool_autosplit section: +# --- MakeMaker platform_constants section: +MM_Unix_VERSION = 6.42 +PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc + +# --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto -AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;' +AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' -- + # --- MakeMaker tool_xsubpp section: # --- MakeMaker tools_other section: - SHELL = /bin/sh CHMOD = chmod CP = cp -LD = gcc MV = mv NOOP = $(SHELL) -c true +NOECHO = @ RM_F = rm -f RM_RF = rm -rf TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 - -# The following is a portable way to say mkdir -p -# To see which directories are created, change the if 0 to if 1 -MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath - -# This helps us to minimize the effect of the .exists files A yet -# better solution would be to have a stable file in the perl -# distribution with a timestamp of zero. But this solution doesn't -# need any changes to the core distribution and works with older perls -EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime - -# Here we warn users that an old packlist file was found somewhere, -# and that they should call some uninstall routine -WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \ --e 'print "WARNING: I have found an old package in\n";' \ --e 'print "\t$$ARGV[0].\n";' \ --e 'print "Please make sure the two installations are not conflicting\n";' - -UNINST=0 -VERBINST=0 - -MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \ --e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');" - -DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \ --e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", $$arg=shift, "|", $$arg, ">";' \ --e 'print "=over 4";' \ --e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \ --e 'print "=back";' - -UNINSTALL = $(PERL) -MExtUtils::Install \ --e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \ --e 'print " packlist above carefully.\n There may be errors. Remove the";' \ --e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"' +MKPATH = $(ABSPERLRUN) "-MExtUtils::Command" -e mkpath +EQUALIZE_TIMESTAMP = $(ABSPERLRUN) "-MExtUtils::Command" -e eqtime +ECHO = echo +ECHO_N = echo -n +UNINST = 0 +VERBINST = 0 +MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' -- +DOC_INSTALL = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install +UNINSTALL = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall +WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist +MACROSTART = +MACROEND = +USEMAKEFILE = -f +FIXIN = $(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)" + + +# --- MakeMaker makemakerdflt section: +makemakerdflt : all + $(NOECHO) $(NOOP) # --- MakeMaker dist section: - -DISTVNAME = $(DISTNAME)-$(VERSION) -TAR = tar +TAR = tar TARFLAGS = cvf -ZIP = zip +ZIP = zip ZIPFLAGS = -r COMPRESS = gzip --best SUFFIX = .gz SHAR = shar -PREOP = @$(NOOP) -POSTOP = @$(NOOP) -TO_UNIX = @$(NOOP) +PREOP = $(NOECHO) $(NOOP) +POSTOP = $(NOECHO) $(NOOP) +TO_UNIX = $(NOECHO) $(NOOP) CI = ci -u RCS_LABEL = rcs -Nv$(VERSION_SYM): -q DIST_CP = best DIST_DEFAULT = tardist +DISTNAME = File-Slurp +DISTVNAME = File-Slurp-9999.12 # --- MakeMaker macro section: @@ -276,11 +276,16 @@ DIST_DEFAULT = tardist # --- MakeMaker pasthru section: -PASTHRU = LIB="$(LIB)"\ - LIBPERL_A="$(LIBPERL_A)"\ +PASTHRU = LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ - PREFIX="$(PREFIX)"\ - OPTIMIZE="$(OPTIMIZE)" + PREFIX="$(PREFIX)" + + +# --- MakeMaker special_targets section: +.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) + +.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir + # --- MakeMaker c_o section: @@ -293,68 +298,77 @@ PASTHRU = LIB="$(LIB)"\ # --- MakeMaker top_targets section: +all :: pure_all manifypods + $(NOECHO) $(NOOP) -#all :: config $(INST_PM) subdirs linkext manifypods - -all :: pure_all htmlifypods manifypods - @$(NOOP) pure_all :: config pm_to_blib subdirs linkext - @$(NOOP) + $(NOECHO) $(NOOP) subdirs :: $(MYEXTLIB) - @$(NOOP) - -config :: Makefile $(INST_LIBDIR)/.exists - @$(NOOP) + $(NOECHO) $(NOOP) -config :: $(INST_ARCHAUTODIR)/.exists - @$(NOOP) +config :: $(FIRST_MAKEFILE) blibdirs + $(NOECHO) $(NOOP) -config :: $(INST_AUTODIR)/.exists - @$(NOOP) +help : + perldoc ExtUtils::MakeMaker -$(INST_AUTODIR)/.exists :: /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE/perl.h - @$(MKPATH) $(INST_AUTODIR) - @$(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE/perl.h $(INST_AUTODIR)/.exists - -@$(CHMOD) $(PERM_RWX) $(INST_AUTODIR) +# --- MakeMaker blibdirs section: +blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists + $(NOECHO) $(NOOP) -$(INST_LIBDIR)/.exists :: /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE/perl.h - @$(MKPATH) $(INST_LIBDIR) - @$(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE/perl.h $(INST_LIBDIR)/.exists +# Backwards compat with 6.18 through 6.25 +blibdirs.ts : blibdirs + $(NOECHO) $(NOOP) - -@$(CHMOD) $(PERM_RWX) $(INST_LIBDIR) +$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_LIBDIR) + $(NOECHO) $(CHMOD) 755 $(INST_LIBDIR) + $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists -$(INST_ARCHAUTODIR)/.exists :: /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE/perl.h - @$(MKPATH) $(INST_ARCHAUTODIR) - @$(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE/perl.h $(INST_ARCHAUTODIR)/.exists +$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_ARCHLIB) + $(NOECHO) $(CHMOD) 755 $(INST_ARCHLIB) + $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists - -@$(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) +$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_AUTODIR) + $(NOECHO) $(CHMOD) 755 $(INST_AUTODIR) + $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists -config :: $(INST_MAN3DIR)/.exists - @$(NOOP) +$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) + $(NOECHO) $(CHMOD) 755 $(INST_ARCHAUTODIR) + $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists +$(INST_BIN)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_BIN) + $(NOECHO) $(CHMOD) 755 $(INST_BIN) + $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists -$(INST_MAN3DIR)/.exists :: /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE/perl.h - @$(MKPATH) $(INST_MAN3DIR) - @$(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.6.1/sun4-solaris/CORE/perl.h $(INST_MAN3DIR)/.exists +$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_SCRIPT) + $(NOECHO) $(CHMOD) 755 $(INST_SCRIPT) + $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists - -@$(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) +$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_MAN1DIR) + $(NOECHO) $(CHMOD) 755 $(INST_MAN1DIR) + $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists -help: - perldoc ExtUtils::MakeMaker +$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_MAN3DIR) + $(NOECHO) $(CHMOD) 755 $(INST_MAN3DIR) + $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists -Version_check: - @$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ - -MExtUtils::MakeMaker=Version_check \ - -e "Version_check('$(MM_VERSION)')" # --- MakeMaker linkext section: linkext :: $(LINKTYPE) - @$(NOOP) + $(NOECHO) $(NOOP) # --- MakeMaker dlsyms section: @@ -362,11 +376,8 @@ linkext :: $(LINKTYPE) # --- MakeMaker dynamic section: -## $(INST_PM) has been moved to the all: target. -## It remains here for awhile to allow for old usage: "make dynamic" -#dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM) -dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) - @$(NOOP) +dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) + $(NOECHO) $(NOOP) # --- MakeMaker dynamic_bs section: @@ -381,35 +392,28 @@ BOOTSTRAP = ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make static" -#static :: Makefile $(INST_STATIC) $(INST_PM) -static :: Makefile $(INST_STATIC) - @$(NOOP) +static :: $(FIRST_MAKEFILE) $(INST_STATIC) + $(NOECHO) $(NOOP) # --- MakeMaker static_lib section: -# --- MakeMaker htmlifypods section: +# --- MakeMaker manifypods section: -htmlifypods : pure_all - @$(NOOP) +POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" +POD2MAN = $(POD2MAN_EXE) -# --- MakeMaker manifypods section: -POD2MAN_EXE = /usr/local/bin/pod2man -POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \ --e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "Makefile";' \ --e 'print "Manifying $$m{$$_}\n";' \ --e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\047t install $$m{$$_}\n";' \ --e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}' - -manifypods : pure_all slurp_article.pod \ +manifypods : pure_all \ + Slurp.pm \ lib/File/Slurp.pm - @$(POD2MAN) \ - slurp_article.pod \ - $(INST_MAN3DIR)/File::slurp_article.$(MAN3EXT) \ - lib/File/Slurp.pm \ - $(INST_MAN3DIR)/File::Slurp.$(MAN3EXT) + $(NOECHO) $(POD2MAN) --section=$(MAN3EXT) --perm_rw=$(PERM_RW) \ + Slurp.pm $(INST_MAN3DIR)/File::Slurp.$(MAN3EXT) \ + lib/File/Slurp.pm $(INST_MAN3DIR)/File::Slurp.$(MAN3EXT) + + + # --- MakeMaker processPL section: @@ -421,56 +425,105 @@ manifypods : pure_all slurp_article.pod \ # none +# --- MakeMaker clean_subdirs section: +clean_subdirs : + $(NOECHO) $(NOOP) + + # --- MakeMaker clean section: # Delete temporary files but do not touch installed files. We don't delete # the Makefile here so a later make realclean still has a makefile to use. -clean :: - -rm -rf ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c mon.out core core.*perl.*.? *perl.core so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def $(BASEEXT).exp - -mv Makefile Makefile.old $(DEV_NULL) +clean :: clean_subdirs + - $(RM_F) \ + *$(LIB_EXT) core \ + core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \ + core.[0-9][0-9] $(BASEEXT).bso \ + pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \ + $(BASEEXT).x $(BOOTSTRAP) \ + perl$(EXE_EXT) tmon.out \ + *$(OBJ_EXT) pm_to_blib \ + $(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \ + core.[0-9][0-9][0-9][0-9][0-9] *perl.core \ + core.*perl.*.? $(MAKE_APERL_FILE) \ + perl $(BASEEXT).def \ + core.[0-9][0-9][0-9] mon.out \ + lib$(BASEEXT).def perlmain.c \ + perl.exe so_locations \ + $(BASEEXT).exp + - $(RM_RF) \ + blib + - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) + + +# --- MakeMaker realclean_subdirs section: +realclean_subdirs : + $(NOECHO) $(NOOP) # --- MakeMaker realclean section: - -# Delete temporary files (via clean) and also delete installed files -realclean purge :: clean - rm -rf $(INST_AUTODIR) $(INST_ARCHAUTODIR) - rm -f $(INST_LIBDIR)/slurp_article.pod $(INST_LIBDIR)/carp.pl - rm -f $(INST_LIB)/File/Slurp.pm.~1.15.~ $(INST_LIBDIR)/split.pl - rm -f $(INST_LIBDIR)/sysread.pl $(INST_LIB)/File/Slurp.pm $(INST_LIBDIR)/slurp_bench.pl - rm -rf Makefile Makefile.old +# Delete temporary files (via clean) and also delete dist files +realclean purge :: clean realclean_subdirs + - $(RM_F) \ + $(MAKEFILE_OLD) $(FIRST_MAKEFILE) + - $(RM_RF) \ + $(DISTVNAME) + + +# --- MakeMaker metafile section: +metafile : create_distdir + $(NOECHO) $(ECHO) Generating META.yml + $(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml + $(NOECHO) $(ECHO) 'name: File-Slurp' >> META_new.yml + $(NOECHO) $(ECHO) 'version: 9999.12' >> META_new.yml + $(NOECHO) $(ECHO) 'abstract: Efficient Reading/Writing of Complete Files' >> META_new.yml + $(NOECHO) $(ECHO) 'license: ~' >> META_new.yml + $(NOECHO) $(ECHO) 'author: ' >> META_new.yml + $(NOECHO) $(ECHO) ' - Uri Guttman ' >> META_new.yml + $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.42' >> META_new.yml + $(NOECHO) $(ECHO) 'distribution_type: module' >> META_new.yml + $(NOECHO) $(ECHO) 'requires: ' >> META_new.yml + $(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml + $(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.3.html' >> META_new.yml + $(NOECHO) $(ECHO) ' version: 1.3' >> META_new.yml + -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml + + +# --- MakeMaker signature section: +signature : + cpansign -s # --- MakeMaker dist_basics section: - distclean :: realclean distcheck + $(NOECHO) $(NOOP) distcheck : - $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=fullcheck \ - -e fullcheck + $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck skipcheck : - $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=skipcheck \ - -e skipcheck + $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck manifest : - $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=mkmanifest \ - -e mkmanifest + $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest veryclean : realclean - $(RM_F) *~ *.orig */*~ */*.orig + $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old + # --- MakeMaker dist_core section: -dist : $(DIST_DEFAULT) - @$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \ - -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "Makefile";' +dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) + $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ + -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' -- tardist : $(DISTVNAME).tar$(SUFFIX) + $(NOECHO) $(NOOP) -zipdist : $(DISTVNAME).zip +uutardist : $(DISTVNAME).tar$(SUFFIX) + uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) @@ -480,17 +533,15 @@ $(DISTVNAME).tar$(SUFFIX) : distdir $(COMPRESS) $(DISTVNAME).tar $(POSTOP) +zipdist : $(DISTVNAME).zip + $(NOECHO) $(NOOP) + $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(POSTOP) -uutardist : $(DISTVNAME).tar$(SUFFIX) - uuencode $(DISTVNAME).tar$(SUFFIX) \ - $(DISTVNAME).tar$(SUFFIX) > \ - $(DISTVNAME).tar$(SUFFIX)_uu - shdist : distdir $(PREOP) $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar @@ -498,156 +549,175 @@ shdist : distdir $(POSTOP) -# --- MakeMaker dist_dir section: - -distdir : +# --- MakeMaker distdir section: +create_distdir : $(RM_RF) $(DISTVNAME) - $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=manicopy,maniread \ + $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" +distdir : create_distdir distmeta + $(NOECHO) $(NOOP) -# --- MakeMaker dist_test section: + +# --- MakeMaker dist_test section: disttest : distdir - cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL - cd $(DISTVNAME) && $(MAKE) - cd $(DISTVNAME) && $(MAKE) test + cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL + cd $(DISTVNAME) && $(MAKE) $(PASTHRU) + cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) + # --- MakeMaker dist_ci section: ci : - $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \ - -e "@all = keys %{ maniread() };" \ - -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \ - -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");' + $(PERLRUN) "-MExtUtils::Manifest=maniread" \ + -e "@all = keys %{ maniread() };" \ + -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ + -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" + + +# --- MakeMaker distmeta section: +distmeta : create_distdir metafile + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' -- + + + +# --- MakeMaker distsignature section: +distsignature : create_distdir + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' -- + $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE + cd $(DISTVNAME) && cpansign -s + # --- MakeMaker install section: -install :: all pure_install doc_install +install :: pure_install doc_install + $(NOECHO) $(NOOP) -install_perl :: all pure_perl_install doc_perl_install +install_perl :: pure_perl_install doc_perl_install + $(NOECHO) $(NOOP) -install_site :: all pure_site_install doc_site_install +install_site :: pure_site_install doc_site_install + $(NOECHO) $(NOOP) -install_ :: install_site - @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site +install_vendor :: pure_vendor_install doc_vendor_install + $(NOECHO) $(NOOP) pure_install :: pure_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) doc_install :: doc_$(INSTALLDIRS)_install - @echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod + $(NOECHO) $(NOOP) pure__install : pure_site_install - @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site doc__install : doc_site_install - @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site - -pure_perl_install :: - @$(MOD_INSTALL) \ - read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ - write $(INSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ - $(INST_LIB) $(INSTALLPRIVLIB) \ - $(INST_ARCHLIB) $(INSTALLARCHLIB) \ - $(INST_BIN) $(INSTALLBIN) \ - $(INST_SCRIPT) $(INSTALLSCRIPT) \ - $(INST_HTMLLIBDIR) $(INSTALLHTMLPRIVLIBDIR) \ - $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \ - $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ - $(INST_MAN3DIR) $(INSTALLMAN3DIR) - @$(WARN_IF_OLD_PACKLIST) \ + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +pure_perl_install :: all + $(NOECHO) umask 022; $(MOD_INSTALL) \ + $(INST_LIB) $(DESTINSTALLPRIVLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ + $(INST_BIN) $(DESTINSTALLBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ $(SITEARCHEXP)/auto/$(FULLEXT) -pure_site_install :: - @$(MOD_INSTALL) \ +pure_site_install :: all + $(NOECHO) umask 02; $(MOD_INSTALL) \ read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ - write $(INSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ - $(INST_LIB) $(INSTALLSITELIB) \ - $(INST_ARCHLIB) $(INSTALLSITEARCH) \ - $(INST_BIN) $(INSTALLBIN) \ - $(INST_SCRIPT) $(INSTALLSCRIPT) \ - $(INST_HTMLLIBDIR) $(INSTALLHTMLSITELIBDIR) \ - $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \ - $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ - $(INST_MAN3DIR) $(INSTALLMAN3DIR) - @$(WARN_IF_OLD_PACKLIST) \ + write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLSITELIB) \ + $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ + $(INST_BIN) $(DESTINSTALLSITEBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ $(PERL_ARCHLIB)/auto/$(FULLEXT) -doc_perl_install :: - -@$(MKPATH) $(INSTALLARCHLIB) - -@$(DOC_INSTALL) \ - "Module" "$(NAME)" \ - "installed into" "$(INSTALLPRIVLIB)" \ - LINKTYPE "$(LINKTYPE)" \ - VERSION "$(VERSION)" \ - EXE_FILES "$(EXE_FILES)" \ - >> $(INSTALLARCHLIB)/perllocal.pod - -doc_site_install :: - -@$(MKPATH) $(INSTALLARCHLIB) - -@$(DOC_INSTALL) \ +pure_vendor_install :: all + $(NOECHO) umask 022; $(MOD_INSTALL) \ + $(INST_LIB) $(DESTINSTALLVENDORLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ + $(INST_BIN) $(DESTINSTALLVENDORBIN) \ + $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) + +doc_perl_install :: all + +doc_site_install :: all + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLSITEARCH)/perllocal.pod + -$(NOECHO) umask 02; $(MKPATH) $(DESTINSTALLSITEARCH) + -$(NOECHO) umask 02; $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ - >> $(INSTALLARCHLIB)/perllocal.pod + >> $(DESTINSTALLSITEARCH)/perllocal.pod + +doc_vendor_install :: all uninstall :: uninstall_from_$(INSTALLDIRS)dirs + $(NOECHO) $(NOOP) uninstall_from_perldirs :: - @$(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist uninstall_from_sitedirs :: - @$(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist + $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist + +uninstall_from_vendordirs :: + # --- MakeMaker force section: # Phony target to force checking subdirectories. -FORCE: - @$(NOOP) +FORCE : + $(NOECHO) $(NOOP) # --- MakeMaker perldepend section: # --- MakeMaker makefile section: - -# We take a very conservative approach here, but it\'s worth it. +# We take a very conservative approach here, but it's worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. -Makefile : Makefile.PL $(CONFIGDEP) - @echo "Makefile out-of-date with respect to $?" - @echo "Cleaning current config before rebuilding Makefile..." - -@$(RM_F) Makefile.old - -@$(MV) Makefile Makefile.old - -$(MAKE) -f Makefile.old clean $(DEV_NULL) || $(NOOP) - $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL - @echo "==> Your Makefile has been rebuilt. <==" - @echo "==> Please rerun the make command. <==" +$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) + $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" + $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." + -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) + -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) + $(PERLRUN) Makefile.PL + $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" + $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" false -# To change behavior to :: would be nice, but would break Tk b9.02 -# so you find such a warning below the dist target. -#Makefile :: $(VERSION_FROM) -# @echo "Warning: Makefile possibly out of date with $(VERSION_FROM)" # --- MakeMaker staticmake section: # --- MakeMaker makeaperl section --- MAP_TARGET = perl -FULLPERL = /usr/local/bin/perl +FULLPERL = /usr/bin/perl $(MAP_TARGET) :: static $(MAKE_APERL_FILE) - $(MAKE) -f $(MAKE_APERL_FILE) $@ + $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ -$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) - @echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) - @$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ +$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib + $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) + $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR= \ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= @@ -663,13 +733,17 @@ TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) -test :: $(TEST_TYPE) +test :: $(TEST_TYPE) subdirs-test + +subdirs-test :: + $(NOECHO) $(NOOP) + test_dynamic :: pure_all - PERL_DL_NONLAZY=1 $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' $(TEST_FILES) + PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) testdb_dynamic :: pure_all - PERL_DL_NONLAZY=1 $(FULLPERL) $(TESTDB_SW) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(TEST_FILE) + PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) test_ : test_dynamic @@ -679,16 +753,26 @@ testdb_static :: testdb_dynamic # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. -ppd: - @$(PERL) -e "print qq{\n}. qq{\tFile-Slurp\n}. qq{\tEfficient Reading/Writing of Complete Files\n}. qq{\tUri Guttman <uri\@stemsystems.com>\n}. qq{\t\n}. qq{\t\t\n}. qq{\t\t\n}. qq{\t\t\n}. qq{\t\n}. qq{\n}" > File-Slurp.ppd +ppd : + $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' $(DISTNAME)' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' Efficient Reading/Writing of Complete Files' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' Uri Guttman <uri@stemsystems.com>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd + # --- MakeMaker pm_to_blib section: -pm_to_blib: $(TO_INST_PM) - @$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \ - "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \ - -e "pm_to_blib({qw{$(PM_TO_BLIB)}},'$(INST_LIB)/auto','$(PM_FILTER)')" - @$(TOUCH) $@ +pm_to_blib : $(TO_INST_PM) + $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')' -- \ + Slurp.pm $(INST_LIB)/File/Slurp.pm \ + lib/File/Slurp.pm blib/lib/File/Slurp.pm + $(NOECHO) $(TOUCH) pm_to_blib # --- MakeMaker selfdocument section: diff --git a/Slurp.pm b/Slurp.pm deleted file mode 100755 index 74d73a7..0000000 --- a/Slurp.pm +++ /dev/null @@ -1,745 +0,0 @@ -package File::Slurp; - -use strict; - -use Carp ; -use Fcntl qw( :DEFAULT ) ; -use POSIX qw( :fcntl_h ) ; -use Symbol ; - -use base 'Exporter' ; -use vars qw( %EXPORT_TAGS @EXPORT_OK $VERSION @EXPORT ) ; - -%EXPORT_TAGS = ( 'all' => [ - qw( read_file write_file overwrite_file append_file read_dir ) ] ) ; - -@EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); -@EXPORT_OK = qw( slurp ) ; - -$VERSION = '9999.13'; - -my $is_win32 = $^O =~ /win32/i ; - -# Install subs for various constants that aren't set in older perls -# (< 5.005). Fcntl on old perls uses Exporter to define subs without a -# () prototype These can't be overridden with the constant pragma or -# we get a prototype mismatch. Hence this less than aesthetically -# appealing BEGIN block: - -BEGIN { - unless( eval { defined SEEK_SET() } ) { - *SEEK_SET = sub { 0 }; - *SEEK_CUR = sub { 1 }; - *SEEK_END = sub { 2 }; - } - - unless( eval { defined O_BINARY() } ) { - *O_BINARY = sub { 0 }; - *O_RDONLY = sub { 0 }; - *O_WRONLY = sub { 1 }; - } - - unless ( eval { defined O_APPEND() } ) { - - if ( $^O =~ /olaris/ ) { - *O_APPEND = sub { 8 }; - *O_CREAT = sub { 256 }; - *O_EXCL = sub { 1024 }; - } - elsif ( $^O =~ /inux/ ) { - *O_APPEND = sub { 1024 }; - *O_CREAT = sub { 64 }; - *O_EXCL = sub { 128 }; - } - elsif ( $^O =~ /BSD/i ) { - *O_APPEND = sub { 8 }; - *O_CREAT = sub { 512 }; - *O_EXCL = sub { 2048 }; - } - } -} - -# print "OS [$^O]\n" ; - -# print "O_BINARY = ", O_BINARY(), "\n" ; -# print "O_RDONLY = ", O_RDONLY(), "\n" ; -# print "O_WRONLY = ", O_WRONLY(), "\n" ; -# print "O_APPEND = ", O_APPEND(), "\n" ; -# print "O_CREAT ", O_CREAT(), "\n" ; -# print "O_EXCL ", O_EXCL(), "\n" ; - - -*slurp = \&read_file ; - -sub read_file { - - my( $file_name, %args ) = @_ ; - -# set the buffer to either the passed in one or ours and init it to the null -# string - - my $buf ; - my $buf_ref = $args{'buf_ref'} || \$buf ; - ${$buf_ref} = '' ; - - my( $read_fh, $size_left, $blk_size ) ; - -# check if we are reading from a handle (glob ref or IO:: object) - - if ( ref $file_name ) { - -# slurping a handle so use it and don't open anything. -# set the block size so we know it is a handle and read that amount - - $read_fh = $file_name ; - $blk_size = $args{'blk_size'} || 1024 * 1024 ; - $size_left = $blk_size ; - -# DEEP DARK MAGIC. this checks the UNTAINT IO flag of a -# glob/handle. only the DATA handle is untainted (since it is from -# trusted data in the source file). this allows us to test if this is -# the DATA handle and then to do a sysseek to make sure it gets -# slurped correctly. on some systems, the buffered i/o pointer is not -# left at the same place as the fd pointer. this sysseek makes them -# the same so slurping with sysread will work. - - eval{ require B } ; - - if ( $@ ) { - - @_ = ( \%args, <IO->IoFLAGS & 16 ) { - -# set the seek position to the current tell. - - sysseek( $read_fh, tell( $read_fh ), SEEK_SET ) || - croak "sysseek $!" ; - } - } - else { - -# a regular file. set the sysopen mode - - my $mode = O_RDONLY ; - $mode |= O_BINARY if $args{'binmode'} ; - -#printf "RD: BINARY %x MODE %x\n", O_BINARY, $mode ; - -# open the file and handle any error - - $read_fh = gensym ; - unless ( sysopen( $read_fh, $file_name, $mode ) ) { - @_ = ( \%args, "read_file '$file_name' - sysopen: $!"); - goto &_error ; - } - -# get the size of the file for use in the read loop - - $size_left = -s $read_fh ; - - unless( $size_left ) { - - $blk_size = $args{'blk_size'} || 1024 * 1024 ; - $size_left = $blk_size ; - } - } - -# infinite read loop. we exit when we are done slurping - - while( 1 ) { - -# do the read and see how much we got - - my $read_cnt = sysread( $read_fh, ${$buf_ref}, - $size_left, length ${$buf_ref} ) ; - - if ( defined $read_cnt ) { - -# good read. see if we hit EOF (nothing left to read) - - last if $read_cnt == 0 ; - -# loop if we are slurping a handle. we don't track $size_left then. - - next if $blk_size ; - -# count down how much we read and loop if we have more to read. - $size_left -= $read_cnt ; - last if $size_left <= 0 ; - next ; - } - -# handle the read error - - @_ = ( \%args, "read_file '$file_name' - sysread: $!"); - goto &_error ; - } - -# fix up cr/lf to be a newline if this is a windows text file - - ${$buf_ref} =~ s/\015\012/\n/g if $is_win32 && !$args{'binmode'} ; - -# this is the 5 returns in a row. each handles one possible -# combination of caller context and requested return type - - my $sep = $/ ; - $sep = '\n\n+' if defined $sep && $sep eq '' ; - -# caller wants to get an array ref of lines - -# this split doesn't work since it tries to use variable length lookbehind -# the m// line works. -# return [ split( m|(?<=$sep)|, ${$buf_ref} ) ] if $args{'array_ref'} ; - return [ length(${$buf_ref}) ? ${$buf_ref} =~ /(.*?$sep|.+)/sg : () ] - if $args{'array_ref'} ; - -# caller wants a list of lines (normal list context) - -# same problem with this split as before. -# return split( m|(?<=$sep)|, ${$buf_ref} ) if wantarray ; - return length(${$buf_ref}) ? ${$buf_ref} =~ /(.*?$sep|.+)/sg : () - if wantarray ; - -# caller wants a scalar ref to the slurped text - - return $buf_ref if $args{'scalar_ref'} ; - -# caller wants a scalar with the slurped text (normal scalar context) - - return ${$buf_ref} if defined wantarray ; - -# caller passed in an i/o buffer by reference (normal void context) - - return ; -} - -sub write_file { - - my $file_name = shift ; - -# get the optional argument hash ref from @_ or an empty hash ref. - - my $args = ( ref $_[0] eq 'HASH' ) ? shift : {} ; - - my( $buf_ref, $write_fh, $no_truncate, $orig_file_name, $data_is_ref ) ; - -# get the buffer ref - it depends on how the data is passed into write_file -# after this if/else $buf_ref will have a scalar ref to the data. - - if ( ref $args->{'buf_ref'} eq 'SCALAR' ) { - -# a scalar ref passed in %args has the data -# note that the data was passed by ref - - $buf_ref = $args->{'buf_ref'} ; - $data_is_ref = 1 ; - } - elsif ( ref $_[0] eq 'SCALAR' ) { - -# the first value in @_ is the scalar ref to the data -# note that the data was passed by ref - - $buf_ref = shift ; - $data_is_ref = 1 ; - } - elsif ( ref $_[0] eq 'ARRAY' ) { - -# the first value in @_ is the array ref to the data so join it. - - ${$buf_ref} = join '', @{$_[0]} ; - } - else { - -# good old @_ has all the data so join it. - - ${$buf_ref} = join '', @_ ; - } - -# see if we were passed a open handle to spew to. - - if ( ref $file_name ) { - -# we have a handle. make sure we don't call truncate on it. - - $write_fh = $file_name ; - $no_truncate = 1 ; - } - else { - -# spew to regular file. - - if ( $args->{'atomic'} ) { - -# in atomic mode, we spew to a temp file so make one and save the original -# file name. - $orig_file_name = $file_name ; - $file_name .= ".$$" ; - } - -# set the mode for the sysopen - - my $mode = O_WRONLY | O_CREAT ; - $mode |= O_BINARY if $args->{'binmode'} ; - $mode |= O_APPEND if $args->{'append'} ; - $mode |= O_EXCL if $args->{'no_clobber'} ; - -#printf "WR: BINARY %x MODE %x\n", O_BINARY, $mode ; - -# open the file and handle any error. - - $write_fh = gensym ; - unless ( sysopen( $write_fh, $file_name, $mode ) ) { - @_ = ( $args, "write_file '$file_name' - sysopen: $!"); - goto &_error ; - } - } - - sysseek( $write_fh, 0, SEEK_END ) if $args->{'append'} ; - - -#print 'WR before data ', unpack( 'H*', ${$buf_ref}), "\n" ; - -# fix up newline to write cr/lf if this is a windows text file - - if ( $is_win32 && !$args->{'binmode'} ) { - -# copy the write data if it was passed by ref so we don't clobber the -# caller's data - $buf_ref = \do{ my $copy = ${$buf_ref}; } if $data_is_ref ; - ${$buf_ref} =~ s/\n/\015\012/g ; - } - -#print 'after data ', unpack( 'H*', ${$buf_ref}), "\n" ; - -# get the size of how much we are writing and init the offset into that buffer - - my $size_left = length( ${$buf_ref} ) ; - my $offset = 0 ; - -# loop until we have no more data left to write - - do { - -# do the write and track how much we just wrote - - my $write_cnt = syswrite( $write_fh, ${$buf_ref}, - $size_left, $offset ) ; - - unless ( defined $write_cnt ) { - -# the write failed - @_ = ( $args, "write_file '$file_name' - syswrite: $!"); - goto &_error ; - } - -# track much left to write and where to write from in the buffer - - $size_left -= $write_cnt ; - $offset += $write_cnt ; - - } while( $size_left > 0 ) ; - -# we truncate regular files in case we overwrite a long file with a shorter file -# so seek to the current position to get it (same as tell()). - - truncate( $write_fh, - sysseek( $write_fh, 0, SEEK_CUR ) ) unless $no_truncate ; - - close( $write_fh ) ; - -# handle the atomic mode - move the temp file to the original filename. - - rename( $file_name, $orig_file_name ) if $args->{'atomic'} ; - - return 1 ; -} - -# this is for backwards compatibility with the previous File::Slurp module. -# write_file always overwrites an existing file - -*overwrite_file = \&write_file ; - -# the current write_file has an append mode so we use that. this -# supports the same API with an optional second argument which is a -# hash ref of options. - -sub append_file { - -# get the optional args hash ref - my $args = $_[1] ; - if ( ref $args eq 'HASH' ) { - -# we were passed an args ref so just mark the append mode - - $args->{append} = 1 ; - } - else { - -# no args hash so insert one with the append mode - - splice( @_, 1, 0, { append => 1 } ) ; - } - -# magic goto the main write_file sub. this overlays the sub without touching -# the stack or @_ - - goto &write_file -} - -# basic wrapper around opendir/readdir - -sub read_dir { - - my ($dir, %args ) = @_; - -# this handle will be destroyed upon return - - local(*DIRH); - -# open the dir and handle any errors - - unless ( opendir( DIRH, $dir ) ) { - - @_ = ( \%args, "read_dir '$dir' - opendir: $!" ) ; - goto &_error ; - } - - my @dir_entries = readdir(DIRH) ; - - @dir_entries = grep( $_ ne "." && $_ ne "..", @dir_entries ) - unless $args{'keep_dot_dot'} ; - - return @dir_entries if wantarray ; - return \@dir_entries ; -} - -# error handling section -# -# all the error handling uses magic goto so the caller will get the -# error message as if from their code and not this module. if we just -# did a call on the error code, the carp/croak would report it from -# this module since the error sub is one level down on the call stack -# from read_file/write_file/read_dir. - - -my %err_func = ( - 'carp' => \&carp, - 'croak' => \&croak, -) ; - -sub _error { - - my( $args, $err_msg ) = @_ ; - -# get the error function to use - - my $func = $err_func{ $args->{'err_mode'} || 'croak' } ; - -# if we didn't find it in our error function hash, they must have set -# it to quiet and we don't do anything. - - return unless $func ; - -# call the carp/croak function - - $func->($err_msg) ; - -# return a hard undef (in list context this will be a single value of -# undef which is not a legal in-band value) - - return undef ; -} - -1; -__END__ - -=head1 NAME - -File::Slurp - Efficient Reading/Writing of Complete Files - -=head1 SYNOPSIS - - use File::Slurp; - - my $text = read_file( 'filename' ) ; - my @lines = read_file( 'filename' ) ; - - write_file( 'filename', @lines ) ; - - use File::Slurp qw( slurp ) ; - - my $text = slurp( 'filename' ) ; - - -=head1 DESCRIPTION - -This module provides subs that allow you to read or write entire files -with one simple call. They are designed to be simple to use, have -flexible ways to pass in or get the file contents and to be very -efficient. There is also a sub to read in all the files in a -directory other than C<.> and C<..> - -These slurp/spew subs work for files, pipes and -sockets, and stdio, pseudo-files, and DATA. - -=head2 B - -This sub reads in an entire file and returns its contents to the -caller. In list context it will return a list of lines (using the -current value of $/ as the separator including support for paragraph -mode when it is set to ''). In scalar context it returns the entire -file as a single scalar. - - my $text = read_file( 'filename' ) ; - my @lines = read_file( 'filename' ) ; - -The first argument to C is the filename and the rest of the -arguments are key/value pairs which are optional and which modify the -behavior of the call. Other than binmode the options all control how -the slurped file is returned to the caller. - -If the first argument is a file handle reference or I/O object (if ref -is true), then that handle is slurped in. This mode is supported so -you slurp handles such as C, C. See the test handle.t -for an example that does C and child process spews data -to the parant which slurps it in. All of the options that control how -the data is returned to the caller still work in this case. - -NOTE: as of version 9999.06, read_file works correctly on the C -handle. It used to need a sysseek workaround but that is now handled -when needed by the module itself. - -You can optionally request that C is exported to your code. This -is an alias for read_file and is meant to be forward compatible with -Perl 6 (which will have slurp() built-in). - -The options are: - -=head3 binmode - -If you set the binmode option, then the file will be slurped in binary -mode. - - my $bin_data = read_file( $bin_file, binmode => ':raw' ) ; - -NOTE: this actually sets the O_BINARY mode flag for sysopen. It -probably should call binmode and pass its argument to support other -file modes. - -=head3 array_ref - -If this boolean option is set, the return value (only in scalar -context) will be an array reference which contains the lines of the -slurped file. The following two calls are equivalent: - - my $lines_ref = read_file( $bin_file, array_ref => 1 ) ; - my $lines_ref = [ read_file( $bin_file ) ] ; - -=head3 scalar_ref - -If this boolean option is set, the return value (only in scalar -context) will be an scalar reference to a string which is the contents -of the slurped file. This will usually be faster than returning the -plain scalar. - - my $text_ref = read_file( $bin_file, scalar_ref => 1 ) ; - -=head3 buf_ref - -You can use this option to pass in a scalar reference and the slurped -file contents will be stored in the scalar. This can be used in -conjunction with any of the other options. - - my $text_ref = read_file( $bin_file, buf_ref => \$buffer, - array_ref => 1 ) ; - my @lines = read_file( $bin_file, buf_ref => \$buffer ) ; - -=head3 blk_size - -You can use this option to set the block size used when slurping from an already open handle (like \*STDIN). It defaults to 1MB. - - my $text_ref = read_file( $bin_file, blk_size => 10_000_000, - array_ref => 1 ) ; - -=head3 err_mode - -You can use this option to control how read_file behaves when an error -occurs. This option defaults to 'croak'. You can set it to 'carp' or -to 'quiet to have no error handling. This code wants to carp and then -read abother file if it fails. - - my $text_ref = read_file( $file, err_mode => 'carp' ) ; - unless ( $text_ref ) { - - # read a different file but croak if not found - $text_ref = read_file( $another_file ) ; - } - - # process ${$text_ref} - -=head2 B - -This sub writes out an entire file in one call. - - write_file( 'filename', @data ) ; - -The first argument to C is the filename. The next argument -is an optional hash reference and it contains key/values that can -modify the behavior of C. The rest of the argument list is -the data to be written to the file. - - write_file( 'filename', {append => 1 }, @data ) ; - write_file( 'filename', {binmode => ':raw' }, $buffer ) ; - -As a shortcut if the first data argument is a scalar or array -reference, it is used as the only data to be written to the file. Any -following arguments in @_ are ignored. This is a faster way to pass in -the output to be written to the file and is equivilent to the -C option. These following pairs are equivilent but the pass -by reference call will be faster in most cases (especially with larger -files). - - write_file( 'filename', \$buffer ) ; - write_file( 'filename', $buffer ) ; - - write_file( 'filename', \@lines ) ; - write_file( 'filename', @lines ) ; - -If the first argument is a file handle reference or I/O object (if ref -is true), then that handle is slurped in. This mode is supported so -you spew to handles such as \*STDOUT. See the test handle.t for an -example that does C and child process spews data to the -parant which slurps it in. All of the options that control how the -data is passes into C still work in this case. - -C returns 1 upon successfully writing the file or undef if -it encountered an error. - -The options are: - -=head3 binmode - -If you set the binmode option, then the file will be written in binary -mode. - - write_file( $bin_file, {binmode => ':raw'}, @data ) ; - -NOTE: this actually sets the O_BINARY mode flag for sysopen. It -probably should call binmode and pass its argument to support other -file modes. - -=head3 buf_ref - -You can use this option to pass in a scalar reference which has the -data to be written. If this is set then any data arguments (including -the scalar reference shortcut) in @_ will be ignored. These are -equivilent: - - write_file( $bin_file, { buf_ref => \$buffer } ) ; - write_file( $bin_file, \$buffer ) ; - write_file( $bin_file, $buffer ) ; - -=head3 atomic - -If you set this boolean option, the file will be written to in an -atomic fashion. A temporary file name is created by appending the pid -($$) to the file name argument and that file is spewed to. After the -file is closed it is renamed to the original file name (and rename is -an atomic operation on most OS's). If the program using this were to -crash in the middle of this, then the file with the pid suffix could -be left behind. - -=head3 append - -If you set this boolean option, the data will be written at the end of -the current file. - - write_file( $file, {append => 1}, @data ) ; - -C croaks if it cannot open the file. It returns true if it -succeeded in writing out the file and undef if there was an -error. (Yes, I know if it croaks it can't return anything but that is -for when I add the options to select the error handling mode). - -=head3 no_clobber - -If you set this boolean option, an existing file will not be overwritten. - - write_file( $file, {no_clobber => 1}, @data ) ; - -=head3 err_mode - -You can use this option to control how C behaves when an -error occurs. This option defaults to 'croak'. You can set it to -'carp' or to 'quiet' to have no error handling other than the return -value. If the first call to C fails it will carp and then -write to another file. If the second call to C fails, it -will croak. - - unless ( write_file( $file, { err_mode => 'carp', \$data ) ; - - # write a different file but croak if not found - write_file( $other_file, \$data ) ; - } - -=head2 overwrite_file - -This sub is just a typeglob alias to write_file since write_file -always overwrites an existing file. This sub is supported for -backwards compatibility with the original version of this module. See -write_file for its API and behavior. - -=head2 append_file - -This sub will write its data to the end of the file. It is a wrapper -around write_file and it has the same API so see that for the full -documentation. These calls are equivilent: - - append_file( $file, @data ) ; - write_file( $file, {append => 1}, @data ) ; - -=head2 read_dir - -This sub reads all the file names from directory and returns them to -the caller but C<.> and C<..> are removed by default. - - my @files = read_dir( '/path/to/dir' ) ; - -It croaks if it cannot open the directory. - -In a list context C returns a list of the entries in the -directory. In a scalar context it returns an array reference which has -the entries. - -=head3 keep_dot_dot - -If this boolean option is set, C<.> and C<..> are not removed from the -list of files. - - my @all_files = read_dir( '/path/to/dir', keep_dot_dot => 1 ) ; - -=head2 EXPORT - - read_file write_file overwrite_file append_file read_dir - -=head2 SEE ALSO - -An article on file slurping in extras/slurp_article.pod. There is -also a benchmarking script in extras/slurp_bench.pl. - -=head2 BUGS - -If run under Perl 5.004, slurping from the DATA handle will fail as -that requires B.pm which didn't get into core until 5.005. - -=head1 AUTHOR - -Uri Guttman, Euri@stemsystems.comE - -=cut diff --git a/extras/slurp_bench.pl b/extras/slurp_bench.pl index 74725f4..52c8ec0 100755 --- a/extras/slurp_bench.pl +++ b/extras/slurp_bench.pl @@ -10,6 +10,7 @@ use FileHandle ; use Fcntl qw( :DEFAULT :seek ); use File::Slurp () ; +use FileSlurp_12 () ; my $file_name = 'slurp_data' ; my( @lines, $text ) ; @@ -52,6 +53,190 @@ sub run_benchmarks { } ########################################## +########################################## +sub bench_scalar_slurp { + + my ( $size ) = @_ ; + + print "\n\nReading (Slurp) into a scalar: Size = $size bytes\n\n" ; + + my $buffer ; + + my $result = timethese( $opts{iterations}, { + + 'FS::read_file' => + sub { my $text = File::Slurp::read_file( $file_name ) }, + + 'FS12::read_file' => + sub { my $text = FileSlurp_12::read_file( $file_name ) }, + +# 'FS::read_file_buf_ref' => +# sub { my $text ; +# File::Slurp::read_file( $file_name, buf_ref => \$text ) }, +# 'FS::read_file_buf_ref2' => +# sub { +# File::Slurp::read_file( $file_name, buf_ref => \$buffer ) }, +# 'FS::read_file_scalar_ref' => +# sub { my $text = +# File::Slurp::read_file( $file_name, scalar_ref => 1 ) }, + + old_sysread_file => + sub { my $text = old_sysread_file( $file_name ) }, + + old_read_file => + sub { my $text = old_read_file( $file_name ) }, + + orig_read_file => + sub { my $text = orig_read_file( $file_name ) }, + + orig_slurp => + sub { my $text = orig_slurp_scalar( $file_name ) }, + + file_contents => + sub { my $text = file_contents( $file_name ) }, + + file_contents_no_OO => + sub { my $text = file_contents_no_OO( $file_name ) }, + } ) ; + + cmpthese( $result ) ; +} + +########################################## + +sub bench_list_slurp { + + my ( $size ) = @_ ; + + print "\n\nReading (Slurp) into a list: Size = $size bytes\n\n" ; + + my $result = timethese( $opts{iterations}, { + + 'FS::read_file' => + sub { my @lines = File::Slurp::read_file( $file_name ) }, + + 'FS::read_file_array_ref' => + sub { my $lines_ref = + File::Slurp::read_file( $file_name, array_ref => 1 ) }, + + 'FS::read_file_scalar' => + sub { my $lines_ref = + [ File::Slurp::read_file( $file_name ) ] }, + + old_sysread_file => + sub { my @lines = old_sysread_file( $file_name ) }, + + old_read_file => + sub { my @lines = old_read_file( $file_name ) }, + + orig_read_file => + sub { my @lines = orig_read_file( $file_name ) }, + + orig_slurp_array => + sub { my @lines = orig_slurp_array( $file_name ) }, + + orig_slurp_array_ref => + sub { my $lines_ref = orig_slurp_array( $file_name ) }, + } ) ; + + cmpthese( $result ) ; +} + +###################################### +# uri's old fast slurp + +sub old_read_file { + + my( $file_name ) = shift ; + + local( *FH ) ; + open( FH, $file_name ) || carp "can't open $file_name $!" ; + + return if wantarray ; + + my $buf ; + + read( FH, $buf, -s FH ) ; + return $buf ; +} + +sub old_sysread_file { + + my( $file_name ) = shift ; + + local( *FH ) ; + open( FH, $file_name ) || carp "can't open $file_name $!" ; + + return if wantarray ; + + my $buf ; + + sysread( FH, $buf, -s FH ) ; + return $buf ; +} + +###################################### +# from File::Slurp.pm on cpan + +sub orig_read_file +{ + my ($file) = @_; + + local($/) = wantarray ? $/ : undef; + local(*F); + my $r; + my (@r); + + open(F, "<$file") || croak "open $file: $!"; + @r = ; + close(F) || croak "close $file: $!"; + + return $r[0] unless wantarray; + return @r; +} + + +###################################### +# from Slurp.pm on cpan + +sub orig_slurp { + local( $/, @ARGV ) = ( wantarray ? $/ : undef, @_ ); + return ; +} + +sub orig_slurp_array { + my @array = orig_slurp( @_ ); + return wantarray ? @array : \@array; +} + +sub orig_slurp_scalar { + my $scalar = orig_slurp( @_ ); + return $scalar; +} + +###################################### +# very slow slurp code used by a client + +sub file_contents { + my $file = shift; + my $fh = new FileHandle $file or + warn("Util::file_contents:Can't open file $file"), return ''; + return join '', <$fh>; +} + +# same code but doesn't use FileHandle.pm + +sub file_contents_no_OO { + my $file = shift; + + local( *FH ) ; + open( FH, $file ) || carp "can't open $file $!" ; + + return join '', ; +} + +########################################## +########################################## sub bench_spew_list { @@ -176,104 +361,6 @@ sub syswrite_file_ref { syswrite( FH, ${$text_ref} ) ; } -############################################# - - -# sub bench_scalar_slurp { - -# my ( $size ) = @_ ; - -# print "\n\nScalar Slurp of $size bytes\n\n" ; - -# my $buffer ; - -# my $result = timethese( $dur, { - -# new => -# sub { my $text = File::Slurp::read_file( $file_name ) }, - -# new_buf_ref => -# sub { my $text ; -# File::Slurp::read_file( $file_name, buf_ref => \$text ) }, -# new_buf_ref2 => -# sub { -# File::Slurp::read_file( $file_name, buf_ref => \$buffer ) }, -# new_scalar_ref => -# sub { my $text = -# File::Slurp::read_file( $file_name, scalar_ref => 1 ) }, - -# read_file => -# sub { my $text = read_file( $file_name ) }, - -# sysread_file => -# sub { my $text = sysread_file( $file_name ) }, - -# orig_read_file => -# sub { my $text = orig_read_file( $file_name ) }, - -# 'Slurp.pm scalar' => -# sub { my $text = slurp_scalar( $file_name ) }, - -# file_contents => -# sub { my $text = file_contents( $file_name ) }, - -# file_contents_no_OO => -# sub { my $text = file_contents_no_OO( $file_name ) }, -# } ) ; - -# cmpthese( $result ) ; -# } - -# sub bench_list_slurp { - -# my ( $size ) = @_ ; - -# print "\n\nList Slurp of $size file\n\n" ; - -# my $result = timethese( $dur, { - -# new => -# sub { my @lines = File::Slurp::read_file( $file_name ) }, - -# new_array_ref => -# sub { my $lines_ref = -# File::Slurp::read_file( $file_name, array_ref => 1 ) }, - -# new_in_anon_array => -# sub { my $lines_ref = -# [ File::Slurp::read_file( $file_name ) ] }, - -# read_file => -# sub { my @lines = read_file( $file_name ) }, - -# sysread_file => -# sub { my @lines = sysread_file( $file_name ) }, - -# orig_read_file => -# sub { my @lines = orig_read_file( $file_name ) }, - -# 'Slurp.pm to array' => -# sub { my @lines = slurp_array( $file_name ) }, - -# orig_slurp_to_array_ref => -# sub { my $lines_ref = orig_slurp_to_array( $file_name ) }, -# } ) ; - -# cmpthese( $result ) ; -# } - - -########################### -# write file benchmark subs -########################### - - - -####################### -# top level subs for script - -####################### - sub parse_options { my $result = GetOptions (\%opts, qw( @@ -377,77 +464,81 @@ sub parse_options { sub legend { die <<'LEGEND' ; +-------------------------------------------------------------------------- Legend for the Slurp Benchmark Entries In all cases below 'FS' or 'F::S' means the current File::Slurp module is being used in the benchmark. The full name and description will say which options are being used. - +-------------------------------------------------------------------------- These benchmarks write a list of lines to a file. Use the direction option of 'out' or 'both' and the context option is 'list' or 'both'. Key Description/Source - --- ------------------ + ----- -------------------------- FS::write_file Current F::S write_file FS::write_file Aref Current F::S write_file on array ref of data print Open a file and call print() on the list data - print/join Open a file and call print() on the joined - list data + print/join Open a file and call print() on the joined list + data syswrite/join Open a file, call syswrite on joined list data - sysopen/syswrite Sysopen a file, call syswrite on joined - list data + sysopen/syswrite Sysopen a file, call syswrite on joined list + data original write_file write_file code from original File::Slurp (pre-version 9999.*) - +-------------------------------------------------------------------------- These benchmarks write a scalar to a file. Use the direction option of 'out' or 'both' and the context option is 'scalar' or 'both'. Key Description/Source - --- ------------------ + ----- -------------------------- FS::write_file Current F::S write_file FS::write_file Sref Current F::S write_file of scalar ref of data print Open a file and call print() on the scalar data syswrite_file Open a file, call syswrite on scalar data - syswrite_file_ref Open a file, call syswrite on scalar ref of data + syswrite_file_ref Open a file, call syswrite on scalar ref of + data orig_write_file write_file code from original File::Slurp (pre-version 9999.*) - +-------------------------------------------------------------------------- These benchmarks slurp a file into an array. Use the direction option of 'in' or 'both' and the context option is 'list' or 'both'. -FIX THIS - - Key Description/Source - --- ------------------ - FS::write_file Current F::S write_file - FS::write_file Aref Current F::S write_file on array ref of data - print Open a file and call print() on the list data - print/join Open a file and call print() on the joined - list data - syswrite/join Open a file, call syswrite on joined list data - sysopen/syswrite Sysopen a file, call syswrite on joined - list data - original write_file write_file code from original File::Slurp - (pre-version 9999.*) - + Key Description/Source + ----- -------------------------- + FS::read_file Current F::S read_file - returns array + FS::read_file_array_ref Current F::S read_file - returns array + ref in any context + FS::read_file_scalar Current F::S read_file - returns array + ref in scalar context + old_sysread_file My old fast slurp - calls sysread + old_read_file My old fast slurp - calls read + orig_read_file Original File::Slurp on CPAN + orig_slurp_array Slurp.pm on CPAN - returns array + orig_slurp_array_ref Slurp.pm on CPAN - returns array ref +-------------------------------------------------------------------------- These benchmarks slurp a file into a scalar. Use the direction option of 'in' or 'both' and the context option is 'scalar' or 'both'. -FIX THIS - - Key Description/Source - --- ------------------ - FS::write_file Current F::S write_file - FS::write_file Aref Current F::S write_file on array ref of data - print Open a file and call print() on the list data - print/join Open a file and call print() on the joined - list data - syswrite/join Open a file, call syswrite on joined list data - sysopen/syswrite Sysopen a file, call syswrite on joined - list data - original write_file write_file code from original File::Slurp - (pre-version 9999.*) - + Key Description/Source + ----- -------------------------- + FS::read_file Current F::S read_file - returns scalar + FS12::read_file F::S .12 slower read_file - + returns scalar + FS::read_file_buf_ref Current F::S read_file - returns + via buf_ref argument - new buffer + FS::read_file_buf_ref2 Current F::S read_file - returns + via buf_ref argument - uses + existing buffer + FS::read_file_scalar_ref Current F::S read_file - returns a + scalar ref + old_sysread_file My old fast slurp - calls sysread + old_read_file My old fast slurp - calls read + orig_read_file Original File::Slurp on CPAN + orig_slurp Slurp.pm on CPAN + file_contents Very slow slurp code done by a client + file_contents_no_OO Same code but doesn't use FileHandle.pm +-------------------------------------------------------------------------- LEGEND } @@ -494,182 +585,3 @@ DIE __END__ - - -sub bench_scalar_slurp { - - my ( $size ) = @_ ; - - print "\n\nScalar Slurp of $size file\n\n" ; - - my $buffer ; - - my $result = timethese( $dur, { - - new => - sub { my $text = File::Slurp::read_file( $file_name ) }, - - new_buf_ref => - sub { my $text ; - File::Slurp::read_file( $file_name, buf_ref => \$text ) }, - new_buf_ref2 => - sub { - File::Slurp::read_file( $file_name, buf_ref => \$buffer ) }, - new_scalar_ref => - sub { my $text = - File::Slurp::read_file( $file_name, scalar_ref => 1 ) }, - - read_file => - sub { my $text = read_file( $file_name ) }, - - sysread_file => - sub { my $text = sysread_file( $file_name ) }, - - orig_read_file => - sub { my $text = orig_read_file( $file_name ) }, - - orig_slurp => - sub { my $text = orig_slurp_to_scalar( $file_name ) }, - - file_contents => - sub { my $text = file_contents( $file_name ) }, - - file_contents_no_OO => - sub { my $text = file_contents_no_OO( $file_name ) }, - } ) ; - - cmpthese( $result ) ; -} - -sub bench_list_slurp { - - my ( $size ) = @_ ; - - print "\n\nList Slurp of $size file\n\n" ; - - my $result = timethese( $dur, { - - new => - sub { my @lines = File::Slurp::read_file( $file_name ) }, - - new_array_ref => - sub { my $lines_ref = - File::Slurp::read_file( $file_name, array_ref => 1 ) }, - - new_in_anon_array => - sub { my $lines_ref = - [ File::Slurp::read_file( $file_name ) ] }, - - read_file => - sub { my @lines = read_file( $file_name ) }, - - sysread_file => - sub { my @lines = sysread_file( $file_name ) }, - - orig_read_file => - sub { my @lines = orig_read_file( $file_name ) }, - - orig_slurp_to_array => - sub { my @lines = orig_slurp_to_array( $file_name ) }, - - orig_slurp_to_array_ref => - sub { my $lines_ref = orig_slurp_to_array( $file_name ) }, - } ) ; - - cmpthese( $result ) ; -} - -###################################### -# uri's old fast slurp - -sub read_file { - - my( $file_name ) = shift ; - - local( *FH ) ; - open( FH, $file_name ) || carp "can't open $file_name $!" ; - - return if wantarray ; - - my $buf ; - - read( FH, $buf, -s FH ) ; - return $buf ; -} - -sub sysread_file { - - my( $file_name ) = shift ; - - local( *FH ) ; - open( FH, $file_name ) || carp "can't open $file_name $!" ; - - return if wantarray ; - - my $buf ; - - sysread( FH, $buf, -s FH ) ; - return $buf ; -} - -###################################### -# from File::Slurp.pm on cpan - -sub orig_read_file -{ - my ($file) = @_; - - local($/) = wantarray ? $/ : undef; - local(*F); - my $r; - my (@r); - - open(F, "<$file") || croak "open $file: $!"; - @r = ; - close(F) || croak "close $file: $!"; - - return $r[0] unless wantarray; - return @r; -} - - -###################################### -# from Slurp.pm on cpan - -sub slurp { - local( $/, @ARGV ) = ( wantarray ? $/ : undef, @_ ); - return ; -} - -sub slurp_array { - my @array = slurp( @_ ); - return wantarray ? @array : \@array; -} - -sub slurp_scalar { - my $scalar = slurp( @_ ); - return $scalar; -} - -###################################### -# very slow slurp code used by a client - -sub file_contents { - my $file = shift; - my $fh = new FileHandle $file or - warn("Util::file_contents:Can't open file $file"), return ''; - return join '', <$fh>; -} - -# same code but doesn't use FileHandle.pm - -sub file_contents_no_OO { - my $file = shift; - - local( *FH ) ; - open( FH, $file ) || carp "can't open $file $!" ; - - return join '', ; -} - -########################## diff --git a/extras/slurp_bench.pl.~1.2.~ b/extras/slurp_bench.pl.~1.2.~ deleted file mode 100755 index 376a75b..0000000 --- a/extras/slurp_bench.pl.~1.2.~ +++ /dev/null @@ -1,351 +0,0 @@ -#!/usr/local/bin/perl - -use strict ; - -use Benchmark qw( timethese cmpthese ) ; -use Carp ; -use FileHandle ; -use Fcntl qw( :DEFAULT :seek ); - -use File::Slurp () ; - -my $dur = shift || -2 ; - -my $file = 'slurp_data' ; - -my @lines = ( 'abc' x 30 . "\n") x 100 ; -my $text = join( '', @lines ) ; - -bench_list_spew( 'SHORT' ) ; -bench_scalar_spew( 'SHORT' ) ; - -File::Slurp::write_file( $file, $text ) ; - -bench_scalar_slurp( 'SHORT' ) ; -bench_list_slurp( 'SHORT' ) ; - -@lines = ( 'abc' x 40 . "\n") x 1000 ; -$text = join( '', @lines ) ; - -bench_list_spew( 'LONG' ) ; -bench_scalar_spew( 'LONG' ) ; - -File::Slurp::write_file( $file, $text ) ; - -bench_scalar_slurp( 'LONG' ) ; -bench_list_slurp( 'LONG' ) ; - -exit ; - -sub bench_list_spew { - - my ( $size ) = @_ ; - - print "\n\nList Spew of $size file\n\n" ; - - my $result = timethese( $dur, { - - new => - sub { File::Slurp::write_file( $file, @lines ) }, - - print_file => - sub { print_file( $file, @lines ) }, - - print_join_file => - sub { print_join_file( $file, @lines ) }, - - syswrite_file => - sub { syswrite_file( $file, @lines ) }, - - cpan_write_file => - sub { cpan_write_file( $file, @lines ) }, - - } ) ; - - cmpthese( $result ) ; -} - -sub bench_scalar_spew { - - my ( $size ) = @_ ; - - print "\n\nScalar Spew of $size file\n\n" ; - - my $result = timethese( $dur, { - - new => - sub { File::Slurp::write_file( $file, $text ) }, - - new_ref => - sub { File::Slurp::write_file( $file, \$text ) }, - - print_file => - sub { print_file( $file, $text ) }, - - print_join_file => - sub { print_join_file( $file, $text ) }, - - syswrite_file => - sub { syswrite_file( $file, $text ) }, - - syswrite_file2 => - sub { syswrite_file2( $file, $text ) }, - - cpan_write_file => - sub { cpan_write_file( $file, $text ) }, - - } ) ; - - cmpthese( $result ) ; -} - -sub bench_scalar_slurp { - - my ( $size ) = @_ ; - - print "\n\nScalar Slurp of $size file\n\n" ; - - my $buffer ; - - my $result = timethese( $dur, { - - new => - sub { my $text = File::Slurp::read_file( $file ) }, - - new_buf_ref => - sub { my $text ; - File::Slurp::read_file( $file, buf_ref => \$text ) }, - new_buf_ref2 => - sub { - File::Slurp::read_file( $file, buf_ref => \$buffer ) }, - new_scalar_ref => - sub { my $text = - File::Slurp::read_file( $file, scalar_ref => 1 ) }, - - read_file => - sub { my $text = read_file( $file ) }, - - sysread_file => - sub { my $text = sysread_file( $file ) }, - - cpan_read_file => - sub { my $text = cpan_read_file( $file ) }, - - cpan_slurp => - sub { my $text = cpan_slurp_to_scalar( $file ) }, - - file_contents => - sub { my $text = file_contents( $file ) }, - - file_contents_no_OO => - sub { my $text = file_contents_no_OO( $file ) }, - } ) ; - - cmpthese( $result ) ; -} - -sub bench_list_slurp { - - my ( $size ) = @_ ; - - print "\n\nList Slurp of $size file\n\n" ; - - my $result = timethese( $dur, { - - new => - sub { my @lines = File::Slurp::read_file( $file ) }, - - new_array_ref => - sub { my $lines_ref = - File::Slurp::read_file( $file, array_ref => 1 ) }, - - new_in_anon_array => - sub { my $lines_ref = - [ File::Slurp::read_file( $file ) ] }, - - read_file => - sub { my @lines = read_file( $file ) }, - - sysread_file => - sub { my @lines = sysread_file( $file ) }, - - cpan_read_file => - sub { my @lines = cpan_read_file( $file ) }, - - cpan_slurp_to_array => - sub { my @lines = cpan_slurp_to_array( $file ) }, - - cpan_slurp_to_array_ref => - sub { my $lines_ref = cpan_slurp_to_array( $file ) }, - } ) ; - - cmpthese( $result ) ; -} - -###################################### -# uri's old fast slurp - -sub read_file { - - my( $file_name ) = shift ; - - local( *FH ) ; - open( FH, $file_name ) || carp "can't open $file_name $!" ; - - return if wantarray ; - - my $buf ; - - read( FH, $buf, -s FH ) ; - return $buf ; -} - -sub sysread_file { - - my( $file_name ) = shift ; - - local( *FH ) ; - open( FH, $file_name ) || carp "can't open $file_name $!" ; - - return if wantarray ; - - my $buf ; - - sysread( FH, $buf, -s FH ) ; - return $buf ; -} - -###################################### -# from File::Slurp.pm on cpan - -sub cpan_read_file -{ - my ($file) = @_; - - local($/) = wantarray ? $/ : undef; - local(*F); - my $r; - my (@r); - - open(F, "<$file") || croak "open $file: $!"; - @r = ; - close(F) || croak "close $file: $!"; - - return $r[0] unless wantarray; - return @r; -} - -sub cpan_write_file -{ - my ($f, @data) = @_; - - local(*F); - - open(F, ">$f") || croak "open >$f: $!"; - (print F @data) || croak "write $f: $!"; - close(F) || croak "close $f: $!"; - return 1; -} - - -###################################### -# from Slurp.pm on cpan - -sub slurp { - local( $/, @ARGV ) = ( wantarray ? $/ : undef, @_ ); - return ; -} - -sub cpan_slurp_to_array { - my @array = slurp( @_ ); - return wantarray ? @array : \@array; -} - -sub cpan_slurp_to_scalar { - my $scalar = slurp( @_ ); - return $scalar; -} - -###################################### -# very slow slurp code used by a client - -sub file_contents { - my $file = shift; - my $fh = new FileHandle $file or - warn("Util::file_contents:Can't open file $file"), return ''; - return join '', <$fh>; -} - -# same code but doesn't use FileHandle.pm - -sub file_contents_no_OO { - my $file = shift; - - local( *FH ) ; - open( FH, $file ) || carp "can't open $file $!" ; - - return join '', ; -} - -########################## - -sub print_file { - - my( $file_name ) = shift ; - - local( *FH ) ; - - open( FH, ">$file_name" ) || carp "can't create $file_name $!" ; - - print FH @_ ; -} - -sub print_file2 { - - my( $file_name ) = shift ; - - local( *FH ) ; - - my $mode = ( -e $file_name ) ? '<' : '>' ; - - open( FH, "+$mode$file_name" ) || carp "can't create $file_name $!" ; - - print FH @_ ; -} - -sub print_join_file { - - my( $file_name ) = shift ; - - local( *FH ) ; - - my $mode = ( -e $file_name ) ? '<' : '>' ; - - open( FH, "+$mode$file_name" ) || carp "can't create $file_name $!" ; - - print FH join( '', @_ ) ; -} - - -sub syswrite_file { - - my( $file_name ) = shift ; - - local( *FH ) ; - - open( FH, ">$file_name" ) || carp "can't create $file_name $!" ; - - syswrite( FH, join( '', @_ ) ) ; -} - -sub syswrite_file2 { - - my( $file_name ) = shift ; - - local( *FH ) ; - - sysopen( FH, $file_name, O_WRONLY | O_CREAT ) || - carp "can't create $file_name $!" ; - - syswrite( FH, join( '', @_ ) ) ; -} diff --git a/extras/slurp_data b/extras/slurp_data deleted file mode 100644 index e69de29..0000000 diff --git a/lib/File/Slurp.pm.~1.26.~ b/lib/File/Slurp.pm.~1.26.~ deleted file mode 100755 index ce890aa..0000000 --- a/lib/File/Slurp.pm.~1.26.~ +++ /dev/null @@ -1,744 +0,0 @@ -package File::Slurp; - -use strict; - -use Carp ; -use Fcntl qw( :DEFAULT ) ; -use POSIX qw( :fcntl_h ) ; -use Symbol ; - -my $is_win32 = $^O =~ /win32/i ; - -# Install subs for various constants that aren't set in older perls -# (< 5.005). Fcntl on old perls uses Exporter to define subs without a -# () prototype These can't be overridden with the constant pragma or -# we get a prototype mismatch. Hence this less than aesthetically -# appealing BEGIN block: - -BEGIN { - unless( eval { defined SEEK_SET() } ) { - *SEEK_SET = sub { 0 }; - *SEEK_CUR = sub { 1 }; - *SEEK_END = sub { 2 }; - } - - unless( eval { defined O_BINARY() } ) { - *O_BINARY = sub { 0 }; - *O_RDONLY = sub { 0 }; - *O_WRONLY = sub { 1 }; - } - - unless ( eval { defined O_APPEND() } ) { - - if ( $^O =~ /olaris/ ) { - *O_APPEND = sub { 8 }; - *O_CREAT = sub { 256 }; - *O_EXCL = sub { 1024 }; - } - elsif ( $^O =~ /inux/ ) { - *O_APPEND = sub { 1024 }; - *O_CREAT = sub { 64 }; - *O_EXCL = sub { 128 }; - } - elsif ( $^O =~ /BSD/i ) { - *O_APPEND = sub { 8 }; - *O_CREAT = sub { 512 }; - *O_EXCL = sub { 2048 }; - } - } -} - -# print "OS [$^O]\n" ; - -# print "O_BINARY = ", O_BINARY(), "\n" ; -# print "O_RDONLY = ", O_RDONLY(), "\n" ; -# print "O_WRONLY = ", O_WRONLY(), "\n" ; -# print "O_APPEND = ", O_APPEND(), "\n" ; -# print "O_CREAT ", O_CREAT(), "\n" ; -# print "O_EXCL ", O_EXCL(), "\n" ; - -use base 'Exporter' ; -use vars qw( %EXPORT_TAGS @EXPORT_OK $VERSION @EXPORT ) ; - -%EXPORT_TAGS = ( 'all' => [ - qw( read_file write_file overwrite_file append_file read_dir ) ] ) ; - -@EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); -@EXPORT_OK = qw( slurp ) ; - -$VERSION = '9999.12'; - -*slurp = \&read_file ; - -sub read_file { - - my( $file_name, %args ) = @_ ; - -# set the buffer to either the passed in one or ours and init it to the null -# string - - my $buf ; - my $buf_ref = $args{'buf_ref'} || \$buf ; - ${$buf_ref} = '' ; - - my( $read_fh, $size_left, $blk_size ) ; - -# check if we are reading from a handle (glob ref or IO:: object) - - if ( ref $file_name ) { - -# slurping a handle so use it and don't open anything. -# set the block size so we know it is a handle and read that amount - - $read_fh = $file_name ; - $blk_size = $args{'blk_size'} || 1024 * 1024 ; - $size_left = $blk_size ; - -# DEEP DARK MAGIC. this checks the UNTAINT IO flag of a -# glob/handle. only the DATA handle is untainted (since it is from -# trusted data in the source file). this allows us to test if this is -# the DATA handle and then to do a sysseek to make sure it gets -# slurped correctly. on some systems, the buffered i/o pointer is not -# left at the same place as the fd pointer. this sysseek makes them -# the same so slurping with sysread will work. - - eval{ require B } ; - - if ( $@ ) { - - @_ = ( \%args, <IO->IoFLAGS & 16 ) { - -# set the seek position to the current tell. - - sysseek( $read_fh, tell( $read_fh ), SEEK_SET ) || - croak "sysseek $!" ; - } - } - else { - -# a regular file. set the sysopen mode - - my $mode = O_RDONLY ; - $mode |= O_BINARY if $args{'binmode'} ; - -#printf "RD: BINARY %x MODE %x\n", O_BINARY, $mode ; - -# open the file and handle any error - - $read_fh = gensym ; - unless ( sysopen( $read_fh, $file_name, $mode ) ) { - @_ = ( \%args, "read_file '$file_name' - sysopen: $!"); - goto &_error ; - } - -# get the size of the file for use in the read loop - - $size_left = -s $read_fh ; - - unless( $size_left ) { - - $blk_size = $args{'blk_size'} || 1024 * 1024 ; - $size_left = $blk_size ; - } - } - -# infinite read loop. we exit when we are done slurping - - while( 1 ) { - -# do the read and see how much we got - - my $read_cnt = sysread( $read_fh, ${$buf_ref}, - $size_left, length ${$buf_ref} ) ; - - if ( defined $read_cnt ) { - -# good read. see if we hit EOF (nothing left to read) - - last if $read_cnt == 0 ; - -# loop if we are slurping a handle. we don't track $size_left then. - - next if $blk_size ; - -# count down how much we read and loop if we have more to read. - $size_left -= $read_cnt ; - last if $size_left <= 0 ; - next ; - } - -# handle the read error - - @_ = ( \%args, "read_file '$file_name' - sysread: $!"); - goto &_error ; - } - -# fix up cr/lf to be a newline if this is a windows text file - - ${$buf_ref} =~ s/\015\012/\n/g if $is_win32 && !$args{'binmode'} ; - -# this is the 5 returns in a row. each handles one possible -# combination of caller context and requested return type - - my $sep = $/ ; - $sep = '\n\n+' if defined $sep && $sep eq '' ; - -# caller wants to get an array ref of lines - -# this split doesn't work since it tries to use variable length lookbehind -# the m// line works. -# return [ split( m|(?<=$sep)|, ${$buf_ref} ) ] if $args{'array_ref'} ; - return [ length(${$buf_ref}) ? ${$buf_ref} =~ /(.*?$sep|.+)/sg : () ] - if $args{'array_ref'} ; - -# caller wants a list of lines (normal list context) - -# same problem with this split as before. -# return split( m|(?<=$sep)|, ${$buf_ref} ) if wantarray ; - return length(${$buf_ref}) ? ${$buf_ref} =~ /(.*?$sep|.+)/sg : () - if wantarray ; - -# caller wants a scalar ref to the slurped text - - return $buf_ref if $args{'scalar_ref'} ; - -# caller wants a scalar with the slurped text (normal scalar context) - - return ${$buf_ref} if defined wantarray ; - -# caller passed in an i/o buffer by reference (normal void context) - - return ; -} - -sub write_file { - - my $file_name = shift ; - -# get the optional argument hash ref from @_ or an empty hash ref. - - my $args = ( ref $_[0] eq 'HASH' ) ? shift : {} ; - - my( $buf_ref, $write_fh, $no_truncate, $orig_file_name, $data_is_ref ) ; - -# get the buffer ref - it depends on how the data is passed into write_file -# after this if/else $buf_ref will have a scalar ref to the data. - - if ( ref $args->{'buf_ref'} eq 'SCALAR' ) { - -# a scalar ref passed in %args has the data -# note that the data was passed by ref - - $buf_ref = $args->{'buf_ref'} ; - $data_is_ref = 1 ; - } - elsif ( ref $_[0] eq 'SCALAR' ) { - -# the first value in @_ is the scalar ref to the data -# note that the data was passed by ref - - $buf_ref = shift ; - $data_is_ref = 1 ; - } - elsif ( ref $_[0] eq 'ARRAY' ) { - -# the first value in @_ is the array ref to the data so join it. - - ${$buf_ref} = join '', @{$_[0]} ; - } - else { - -# good old @_ has all the data so join it. - - ${$buf_ref} = join '', @_ ; - } - -# see if we were passed a open handle to spew to. - - if ( ref $file_name ) { - -# we have a handle. make sure we don't call truncate on it. - - $write_fh = $file_name ; - $no_truncate = 1 ; - } - else { - -# spew to regular file. - - if ( $args->{'atomic'} ) { - -# in atomic mode, we spew to a temp file so make one and save the original -# file name. - $orig_file_name = $file_name ; - $file_name .= ".$$" ; - } - -# set the mode for the sysopen - - my $mode = O_WRONLY | O_CREAT ; - $mode |= O_BINARY if $args->{'binmode'} ; - $mode |= O_APPEND if $args->{'append'} ; - $mode |= O_EXCL if $args->{'no_clobber'} ; - -#printf "WR: BINARY %x MODE %x\n", O_BINARY, $mode ; - -# open the file and handle any error. - - $write_fh = gensym ; - unless ( sysopen( $write_fh, $file_name, $mode ) ) { - @_ = ( $args, "write_file '$file_name' - sysopen: $!"); - goto &_error ; - } - } - - sysseek( $write_fh, 0, SEEK_END ) if $args->{'append'} ; - - -#print 'WR before data ', unpack( 'H*', ${$buf_ref}), "\n" ; - -# fix up newline to write cr/lf if this is a windows text file - - if ( $is_win32 && !$args->{'binmode'} ) { - -# copy the write data if it was passed by ref so we don't clobber the -# caller's data - $buf_ref = \do{ my $copy = ${$buf_ref}; } if $data_is_ref ; - ${$buf_ref} =~ s/\n/\015\012/g ; - } - -#print 'after data ', unpack( 'H*', ${$buf_ref}), "\n" ; - -# get the size of how much we are writing and init the offset into that buffer - - my $size_left = length( ${$buf_ref} ) ; - my $offset = 0 ; - -# loop until we have no more data left to write - - do { - -# do the write and track how much we just wrote - - my $write_cnt = syswrite( $write_fh, ${$buf_ref}, - $size_left, $offset ) ; - - unless ( defined $write_cnt ) { - -# the write failed - @_ = ( $args, "write_file '$file_name' - syswrite: $!"); - goto &_error ; - } - -# track much left to write and where to write from in the buffer - - $size_left -= $write_cnt ; - $offset += $write_cnt ; - - } while( $size_left > 0 ) ; - -# we truncate regular files in case we overwrite a long file with a shorter file -# so seek to the current position to get it (same as tell()). - - truncate( $write_fh, - sysseek( $write_fh, 0, SEEK_CUR ) ) unless $no_truncate ; - - close( $write_fh ) ; - -# handle the atomic mode - move the temp file to the original filename. - - rename( $file_name, $orig_file_name ) if $args->{'atomic'} ; - - return 1 ; -} - -# this is for backwards compatibility with the previous File::Slurp module. -# write_file always overwrites an existing file - -*overwrite_file = \&write_file ; - -# the current write_file has an append mode so we use that. this -# supports the same API with an optional second argument which is a -# hash ref of options. - -sub append_file { - -# get the optional args hash ref - my $args = $_[1] ; - if ( ref $args eq 'HASH' ) { - -# we were passed an args ref so just mark the append mode - - $args->{append} = 1 ; - } - else { - -# no args hash so insert one with the append mode - - splice( @_, 1, 0, { append => 1 } ) ; - } - -# magic goto the main write_file sub. this overlays the sub without touching -# the stack or @_ - - goto &write_file -} - -# basic wrapper around opendir/readdir - -sub read_dir { - - my ($dir, %args ) = @_; - -# this handle will be destroyed upon return - - local(*DIRH); - -# open the dir and handle any errors - - unless ( opendir( DIRH, $dir ) ) { - - @_ = ( \%args, "read_dir '$dir' - opendir: $!" ) ; - goto &_error ; - } - - my @dir_entries = readdir(DIRH) ; - - @dir_entries = grep( $_ ne "." && $_ ne "..", @dir_entries ) - unless $args{'keep_dot_dot'} ; - - return @dir_entries if wantarray ; - return \@dir_entries ; -} - -# error handling section -# -# all the error handling uses magic goto so the caller will get the -# error message as if from their code and not this module. if we just -# did a call on the error code, the carp/croak would report it from -# this module since the error sub is one level down on the call stack -# from read_file/write_file/read_dir. - - -my %err_func = ( - 'carp' => \&carp, - 'croak' => \&croak, -) ; - -sub _error { - - my( $args, $err_msg ) = @_ ; - -# get the error function to use - - my $func = $err_func{ $args->{'err_mode'} || 'croak' } ; - -# if we didn't find it in our error function hash, they must have set -# it to quiet and we don't do anything. - - return unless $func ; - -# call the carp/croak function - - $func->($err_msg) ; - -# return a hard undef (in list context this will be a single value of -# undef which is not a legal in-band value) - - return undef ; -} - -1; -__END__ - -=head1 NAME - -File::Slurp - Efficient Reading/Writing of Complete Files - -=head1 SYNOPSIS - - use File::Slurp; - - my $text = read_file( 'filename' ) ; - my @lines = read_file( 'filename' ) ; - - write_file( 'filename', @lines ) ; - - use File::Slurp qw( slurp ) ; - - my $text = slurp( 'filename' ) ; - - -=head1 DESCRIPTION - -This module provides subs that allow you to read or write entire files -with one simple call. They are designed to be simple to use, have -flexible ways to pass in or get the file contents and to be very -efficient. There is also a sub to read in all the files in a -directory other than C<.> and C<..> - -These slurp/spew subs work for files, pipes and -sockets, and stdio, pseudo-files, and DATA. - -=head2 B - -This sub reads in an entire file and returns its contents to the -caller. In list context it will return a list of lines (using the -current value of $/ as the separator including support for paragraph -mode when it is set to ''). In scalar context it returns the entire -file as a single scalar. - - my $text = read_file( 'filename' ) ; - my @lines = read_file( 'filename' ) ; - -The first argument to C is the filename and the rest of the -arguments are key/value pairs which are optional and which modify the -behavior of the call. Other than binmode the options all control how -the slurped file is returned to the caller. - -If the first argument is a file handle reference or I/O object (if ref -is true), then that handle is slurped in. This mode is supported so -you slurp handles such as C, C. See the test handle.t -for an example that does C and child process spews data -to the parant which slurps it in. All of the options that control how -the data is returned to the caller still work in this case. - -NOTE: as of version 9999.06, read_file works correctly on the C -handle. It used to need a sysseek workaround but that is now handled -when needed by the module itself. - -You can optionally request that C is exported to your code. This -is an alias for read_file and is meant to be forward compatible with -Perl 6 (which will have slurp() built-in). - -The options are: - -=head3 binmode - -If you set the binmode option, then the file will be slurped in binary -mode. - - my $bin_data = read_file( $bin_file, binmode => ':raw' ) ; - -NOTE: this actually sets the O_BINARY mode flag for sysopen. It -probably should call binmode and pass its argument to support other -file modes. - -=head3 array_ref - -If this boolean option is set, the return value (only in scalar -context) will be an array reference which contains the lines of the -slurped file. The following two calls are equivalent: - - my $lines_ref = read_file( $bin_file, array_ref => 1 ) ; - my $lines_ref = [ read_file( $bin_file ) ] ; - -=head3 scalar_ref - -If this boolean option is set, the return value (only in scalar -context) will be an scalar reference to a string which is the contents -of the slurped file. This will usually be faster than returning the -plain scalar. - - my $text_ref = read_file( $bin_file, scalar_ref => 1 ) ; - -=head3 buf_ref - -You can use this option to pass in a scalar reference and the slurped -file contents will be stored in the scalar. This can be used in -conjunction with any of the other options. - - my $text_ref = read_file( $bin_file, buf_ref => \$buffer, - array_ref => 1 ) ; - my @lines = read_file( $bin_file, buf_ref => \$buffer ) ; - -=head3 blk_size - -You can use this option to set the block size used when slurping from an already open handle (like \*STDIN). It defaults to 1MB. - - my $text_ref = read_file( $bin_file, blk_size => 10_000_000, - array_ref => 1 ) ; - -=head3 err_mode - -You can use this option to control how read_file behaves when an error -occurs. This option defaults to 'croak'. You can set it to 'carp' or -to 'quiet to have no error handling. This code wants to carp and then -read abother file if it fails. - - my $text_ref = read_file( $file, err_mode => 'carp' ) ; - unless ( $text_ref ) { - - # read a different file but croak if not found - $text_ref = read_file( $another_file ) ; - } - - # process ${$text_ref} - -=head2 B - -This sub writes out an entire file in one call. - - write_file( 'filename', @data ) ; - -The first argument to C is the filename. The next argument -is an optional hash reference and it contains key/values that can -modify the behavior of C. The rest of the argument list is -the data to be written to the file. - - write_file( 'filename', {append => 1 }, @data ) ; - write_file( 'filename', {binmode => ':raw' }, $buffer ) ; - -As a shortcut if the first data argument is a scalar or array -reference, it is used as the only data to be written to the file. Any -following arguments in @_ are ignored. This is a faster way to pass in -the output to be written to the file and is equivilent to the -C option. These following pairs are equivilent but the pass -by reference call will be faster in most cases (especially with larger -files). - - write_file( 'filename', \$buffer ) ; - write_file( 'filename', $buffer ) ; - - write_file( 'filename', \@lines ) ; - write_file( 'filename', @lines ) ; - -If the first argument is a file handle reference or I/O object (if ref -is true), then that handle is slurped in. This mode is supported so -you spew to handles such as \*STDOUT. See the test handle.t for an -example that does C and child process spews data to the -parant which slurps it in. All of the options that control how the -data is passes into C still work in this case. - -C returns 1 upon successfully writing the file or undef if -it encountered an error. - -The options are: - -=head3 binmode - -If you set the binmode option, then the file will be written in binary -mode. - - write_file( $bin_file, {binmode => ':raw'}, @data ) ; - -NOTE: this actually sets the O_BINARY mode flag for sysopen. It -probably should call binmode and pass its argument to support other -file modes. - -=head3 buf_ref - -You can use this option to pass in a scalar reference which has the -data to be written. If this is set then any data arguments (including -the scalar reference shortcut) in @_ will be ignored. These are -equivilent: - - write_file( $bin_file, { buf_ref => \$buffer } ) ; - write_file( $bin_file, \$buffer ) ; - write_file( $bin_file, $buffer ) ; - -=head3 atomic - -If you set this boolean option, the file will be written to in an -atomic fashion. A temporary file name is created by appending the pid -($$) to the file name argument and that file is spewed to. After the -file is closed it is renamed to the original file name (and rename is -an atomic operation on most OS's). If the program using this were to -crash in the middle of this, then the file with the pid suffix could -be left behind. - -=head3 append - -If you set this boolean option, the data will be written at the end of -the current file. - - write_file( $file, {append => 1}, @data ) ; - -C croaks if it cannot open the file. It returns true if it -succeeded in writing out the file and undef if there was an -error. (Yes, I know if it croaks it can't return anything but that is -for when I add the options to select the error handling mode). - -=head3 no_clobber - -If you set this boolean option, an existing file will not be overwritten. - - write_file( $file, {no_clobber => 1}, @data ) ; - -=head3 err_mode - -You can use this option to control how C behaves when an -error occurs. This option defaults to 'croak'. You can set it to -'carp' or to 'quiet' to have no error handling other than the return -value. If the first call to C fails it will carp and then -write to another file. If the second call to C fails, it -will croak. - - unless ( write_file( $file, { err_mode => 'carp', \$data ) ; - - # write a different file but croak if not found - write_file( $other_file, \$data ) ; - } - -=head2 overwrite_file - -This sub is just a typeglob alias to write_file since write_file -always overwrites an existing file. This sub is supported for -backwards compatibility with the original version of this module. See -write_file for its API and behavior. - -=head2 append_file - -This sub will write its data to the end of the file. It is a wrapper -around write_file and it has the same API so see that for the full -documentation. These calls are equivilent: - - append_file( $file, @data ) ; - write_file( $file, {append => 1}, @data ) ; - -=head2 read_dir - -This sub reads all the file names from directory and returns them to -the caller but C<.> and C<..> are removed by default. - - my @files = read_dir( '/path/to/dir' ) ; - -It croaks if it cannot open the directory. - -In a list context C returns a list of the entries in the -directory. In a scalar context it returns an array reference which has -the entries. - -=head3 keep_dot_dot - -If this boolean option is set, C<.> and C<..> are not removed from the -list of files. - - my @all_files = read_dir( '/path/to/dir', keep_dot_dot => 1 ) ; - -=head2 EXPORT - - read_file write_file overwrite_file append_file read_dir - -=head2 SEE ALSO - -An article on file slurping in extras/slurp_article.pod. There is -also a benchmarking script in extras/slurp_bench.pl. - -=head2 BUGS - -If run under Perl 5.004, slurping from the DATA handle will fail as -that requires B.pm which didn't get into core until 5.005. - -=head1 AUTHOR - -Uri Guttman, Euri@stemsystems.comE - -=cut diff --git a/t/append_null.t b/t/append_null.t index 1a3a5e4..3c8b924 100644 --- a/t/append_null.t +++ b/t/append_null.t @@ -1,12 +1,9 @@ #!/usr/local/bin/perl -w use strict ; +use File::Slurp ; -use Test::More tests => 2 ; - -BEGIN{ - use_ok( 'File::Slurp', qw( read_file write_file append_file ) ) ; -} +use Test::More tests => 1 ; my $data = < 2 ; +use Test::More tests => 1 ; # in case SEEK_SET isn't defined in older perls. it seems to always be 0 BEGIN { - *SEEK_SET = sub { 0 } unless eval { SEEK_SET() } ; -} - -BEGIN{ - use_ok( 'File::Slurp', ) ; + *SEEK_SET = sub { 0 } unless defined \&SEEK_SET ; } SKIP: { diff --git a/t/data_scalar.t b/t/data_scalar.t index 0a841ed..eb24337 100644 --- a/t/data_scalar.t +++ b/t/data_scalar.t @@ -1,20 +1,17 @@ #!/usr/local/bin/perl -w use strict ; +use File::Slurp ; use Carp ; use POSIX qw( :fcntl_h ) ; -use Test::More tests => 2 ; +use Test::More tests => 1 ; # in case SEEK_SET isn't defined in older perls. it seems to always be 0 BEGIN { - *SEEK_SET = sub { 0 } unless eval { SEEK_SET() } ; -} - -BEGIN{ - use_ok( 'File::Slurp', ) ; + *SEEK_SET = sub { 0 } unless defined \&SEEK_SET ; } eval { require B } ; diff --git a/t/handle.t b/t/handle.t index 8987375..5e1cd15 100644 --- a/t/handle.t +++ b/t/handle.t @@ -1,6 +1,7 @@ #!/usr/local/bin/perl -w use strict ; +use File::Slurp ; use Carp ; use POSIX qw( :fcntl_h ) ; @@ -11,7 +12,7 @@ use Test::More ; # in case SEEK_SET isn't defined in older perls. it seems to always be 0 BEGIN { - *SEEK_SET = sub { 0 } unless eval { SEEK_SET() } ; + *SEEK_SET = sub() { 0 } unless defined \&SEEK_SET ; } my @pipe_data = ( @@ -21,14 +22,8 @@ my @pipe_data = ( 'abc' x 1_000_000, ) ; -#plan( tests => 2 + @pipe_data ) ; plan( tests => scalar @pipe_data ) ; - -BEGIN{ - use_ok( 'File::Slurp', ) ; -} - #test_data_slurp() ; #test_fork_pipe_slurp() ; diff --git a/t/inode.t b/t/inode.t index 878e841..377b32c 100644 --- a/t/inode.t +++ b/t/inode.t @@ -2,11 +2,14 @@ use strict ; +use File::Slurp ; + use Carp ; use Socket ; use Symbol ; use Test::More ; + BEGIN{ if( $^O =~ '32' ) { @@ -14,10 +17,8 @@ BEGIN{ exit ; } else { - plan tests => 3 ; + plan tests => 2 ; } - - use_ok( 'File::Slurp', ) ; } my $data = < 2 + 2 ; +use Test::More tests => 2 ; use strict; - -BEGIN { - require_ok( 'File::Slurp' ) ; - use_ok('File::Slurp', qw(write_file read_file) ) ; -} - +use File::Slurp ; my $data = "\r\n\r\n\r\n" ; my $file_name = 'newline.txt' ; diff --git a/t/no_clobber.t b/t/no_clobber.t index 4941fea..0251a1c 100644 --- a/t/no_clobber.t +++ b/t/no_clobber.t @@ -1,12 +1,10 @@ #!/usr/local/bin/perl -w use strict ; +use File::Slurp ; -use Test::More tests => 3 ; +use Test::More tests => 2 ; -BEGIN{ - use_ok( 'File::Slurp', qw( write_file ) ) ; -} my $data = < 1 ) ; my $proc_file = "/proc/$$/auxv" ; -BEGIN{ - use_ok( 'File::Slurp' ) ; -} - SKIP: { unless ( -r $proc_file ) { diff --git a/t/slurp.t b/t/slurp.t index 2d4f741..7a28e5b 100644 --- a/t/slurp.t +++ b/t/slurp.t @@ -1,12 +1,9 @@ #!/usr/local/bin/perl -w use strict ; +use File::Slurp qw( write_file slurp ) ; -use Test::More tests => 2 ; - -BEGIN{ - use_ok( 'File::Slurp', qw( write_file slurp ) ) ; -} +use Test::More tests => 1 ; my $data = < 7 ; - -BEGIN{ - use_ok( 'File::Slurp', ) ; -} +use Test::More tests => 6 ; my $data = < 2 + 1; use strict; -BEGIN { $^W = 1 } +use File::Slurp ; -BEGIN { - require_ok('File::Slurp'); - use_ok('File::Slurp', 'write_file'); -} +use Test::More tests => 1; +BEGIN { $^W = 1 } sub simple_write_file { open my $fh, '>', $_[0] or die "Couldn't open $_[0] for write: $!";