Integrate perlio:
Jarkko Hietaniemi [Sat, 7 Apr 2001 14:43:59 +0000 (14:43 +0000)]
[  9604]
Split out extension finding code from buildext.pl into FindExt.pm
Use it to get Config.pm's idea of available extensions in line
with what is built.

[  9603]
Cleanup correction for failed :Via() layer, also set an error code.

[  9602]
Digests in lib/md5-file.t are for text files _without_ CRLF i.e. UNIX
style. So don't use binmode() on the handles so that Win32 etc. see
same sequence and produce same digests.

[  9601]
Allow PerlIOBase_pushed to ignore prefix on mode (e.g. sysopen's "#r")
Else it complains and so crlf layer (say) does not get pushed.

[  9599]
Quote $VERSION in Encode.pm.
regen_config_h as requested.

p4raw-link: @9604 on //depot/perlio: 8e2329934bcca9c59680f6d478c3c2bc3ef7c649
p4raw-link: @9603 on //depot/perlio: 267cbce72d0da7af102852e6d7e0bb5c1ce41da6
p4raw-link: @9602 on //depot/perlio: 9070af9fb87632d66faa82c00ab8b5cf20323a2b
p4raw-link: @9601 on //depot/perlio: c5af4229019b04c7fa4be99300f8d9883c0bdf73
p4raw-link: @9599 on //depot/perlio: b8a524e96d5b75be96d6a98368b9c29153780cfe

p4raw-id: //depot/perl@9606

MANIFEST
ext/PerlIO/Via/Via.xs
perlio.c
t/lib/md5-file.t
win32/FindExt.pm [new file with mode: 0644]
win32/buildext.pl
win32/config_sh.PL
win32/makefile.mk

index 23f39bf..b425a12 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1881,6 +1881,7 @@ win32/config_sh.PL        Perl code to update Win32 config.sh from Makefile
 win32/des_fcrypt.patch Win32 port
 win32/distclean.bat    Remove _ALL_ files not listed here in MANIFEST
 win32/dl_win32.xs      Win32 port
+win32/FindExt.pm       Scan for extensions
 win32/genmk95.pl        Perl code to generate command.com-usable makefile.95
 win32/include/arpa/inet.h      Win32 port
 win32/include/dirent.h         Win32 port
index 0abcece..cb3f328 100644 (file)
@@ -126,7 +126,7 @@ PerlIOVia_pushed(PerlIO *f, const char *mode, SV *arg)
     {
      STRLEN pkglen = 0;
      char *pkg = SvPV(arg,pkglen);
-     s->obj = arg;
+     s->obj = SvREFCNT_inc(arg);
      s->stash  = gv_stashpvn(pkg, pkglen, FALSE);
      if (s->stash)
       {
@@ -135,7 +135,10 @@ PerlIOVia_pushed(PerlIO *f, const char *mode, SV *arg)
        if (result)
         {
          if (sv_isobject(result))
-          s->obj = SvREFCNT_inc(result);
+          {
+           s->obj = SvREFCNT_inc(result);
+           SvREFCNT_dec(arg);
+          }
          else if (SvIV(result) != 0)
           return SvIV(result);
         }
@@ -147,6 +150,13 @@ PerlIOVia_pushed(PerlIO *f, const char *mode, SV *arg)
      else
       {
        Perl_warn(aTHX_ "Cannot find package '%.*s'",(int) pkglen,pkg);
+#ifdef ENOSYS
+       errno = ENOSYS;
+#else
+#ifdef ENOENT
+       errno = ENOENT;
+#endif
+#endif
        code = -1;
       }
     }
index 797b816..c82da9b 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -1470,6 +1470,8 @@ PerlIOBase_pushed(PerlIO *f, const char *mode, SV *arg)
   l->flags |= PERLIO_F_FASTGETS;
  if (mode)
   {
+   if (*mode == '#' || *mode == 'I')
+    mode++;
    switch (*mode++)
     {
      case 'r':
index 8613271..ca9cac7 100644 (file)
@@ -126,7 +126,9 @@ sub digest_file
     #print "$file $method\n";
 
     open(FILE, $file) or die "Can't open $file: $!";
-    binmode(FILE);
+# Digests avove are generated on UNIX without CRLF
+# so leave handles in text mode
+#    binmode(FILE);
     my $digest = Digest::MD5->new->addfile(*FILE)->$method();
     close(FILE);
 
@@ -138,7 +140,9 @@ sub cat_file
     my($file) = @_;
     local $/;  # slurp
     open(FILE, $file) or die "Can't open $file: $!";
-    binmode(FILE);
+# Digests avove are generated on UNIX without CRLF
+# so leave handles in text mode
+#    binmode(FILE);
     my $tmp = <FILE>;
     close(FILE);
     $tmp;
diff --git a/win32/FindExt.pm b/win32/FindExt.pm
new file mode 100644 (file)
index 0000000..ea5165f
--- /dev/null
@@ -0,0 +1,62 @@
+package FindExt;
+use strict;
+use File::Find;
+use File::Basename;
+use Cwd;
+
+my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File Syslog Sysv));
+$no = qr/^(?:$no)$/i;
+
+my %ext;
+my $ext;
+sub scan_ext
+{
+ my $here = getcwd();
+ my $dir  = shift;
+ chdir($dir) || die "Cannot cd to $dir\n";
+ ($ext = getcwd()) =~ s,/,\\,g;
+ find(\&find_ext,'.');
+ chdir($here) || die "Cannot cd to $here\n";
+ my @ext = extensions();
+}
+
+sub dynamic_extensions
+{
+ return grep $ext{$_} eq 'dynamic',keys %ext;
+}
+
+sub noxs_extensions
+{
+ return grep $ext{$_} eq 'noxs',keys %ext;
+}
+
+sub extensions
+{
+ return keys %ext;
+}
+
+sub find_ext
+{
+ if (/^(.*)\.pm$/i || /^(.*)_pm.PL$/i)
+  {
+   my $name = $1;
+   return if $name =~ $no; 
+   my $dir = $File::Find::dir; 
+   $dir =~ s,./,,;
+   return if exists $ext{$dir};
+   return unless -f "$ext/$dir/Makefile.PL";
+   if ($dir =~ /$name$/i)
+    {
+     if (-f "$ext/$dir/$name.xs")
+      {
+       $ext{$dir} = 'dynamic'; 
+      }
+     else
+      {
+       $ext{$dir} = 'nonxs'; 
+      }
+    }
+  }
+}
+
+1;
index 6e40bb9..5800750 100644 (file)
@@ -1,6 +1,6 @@
-use File::Find;
 use File::Basename;
 use Cwd;
+use FindExt;
 my $here = getcwd();
 my $perl = $^X;
 $here =~ s,/,\\,g;
@@ -15,12 +15,11 @@ my $dmod = -M $dep;
 my $dir  = shift;
 chdir($dir) || die "Cannot cd to $dir\n";
 (my $ext = getcwd()) =~ s,/,\\,g;
-my $no = join('|',qw(DynaLoader GDBM_File ODBM_File NDBM_File DB_File Syslog Sysv));
-$no = qr/^(?:$no)$/i;
-my %ext;
-find(\&find_xs,'.');
+FindExt::scan_ext($ext);
 
-foreach my $dir (sort keys %ext)
+my @ext = FindExt::extensions();
+
+foreach my $dir (sort @ext)
  {
   if (chdir("$ext\\$dir"))
    {
@@ -46,19 +45,3 @@ foreach my $dir (sort keys %ext)
    }
  }
 
-sub find_xs
-{
- if (/^(.*)\.pm$/i || /^(.*)_pm.PL$/i)
-  {
-   my $name = $1;
-   return if $name =~ $no; 
-   my $dir = $File::Find::dir; 
-   $dir =~ s,./,,;
-   return if exists $ext{$dir};
-   return unless -f "$ext/$dir/Makefile.PL";
-   if ($dir =~ /$name$/i)
-    {
-     $ext{$dir} = $name; 
-    }
-  }
-}
index 0e1d351..9757e52 100644 (file)
@@ -1,3 +1,4 @@
+use FindExt;
 # take a semicolon separated path list and turn it into a quoted
 # list of paths that Text::Parsewords will grok
 sub mungepath {
@@ -33,13 +34,19 @@ sub loadopts {
     }
 }
 
+FindExt::scan_ext("../ext");
+
 my %opt;
+
 my $optref = loadopts();
 while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) {
     $opt{$1}=$2;
     shift(@{$optref});
 }
 
+$opt{'dynamic_ext'} = join(' ',FindExt::dynamic_extensions());
+$opt{'nonxs_ext'}   = join(' ',FindExt::noxs_extensions());
+
 my $pl_h = '../patchlevel.h';
 
 if (-e $pl_h) {
index 5333ce6..25ec97d 100644 (file)
@@ -800,8 +800,6 @@ CFG_VARS    =                                       \
                _o=$(o) obj_ext=$(o)            ~       \
                _a=$(a) lib_ext=$(a)            ~       \
                static_ext=$(STATIC_EXT)        ~       \
-               dynamic_ext=$(DYNAMIC_EXT)      ~       \
-               nonxs_ext=$(NONXS_EXT)          ~       \
                use5005threads=$(USE_5005THREADS)       ~       \
                useithreads=$(USE_ITHREADS)     ~       \
                usethreads=$(USE_5005THREADS)   ~       \
@@ -902,7 +900,7 @@ config.w32 : $(CFGSH_TMPL)
        -del /f config.h
        copy $(CFGH_TMPL) config.h
 
-..\config.sh : config.w32 $(MINIPERL) config_sh.PL
+..\config.sh : config.w32 $(MINIPERL) config_sh.PL FindExt.pm
        $(MINIPERL) -I..\lib config_sh.PL --cfgsh-option-file \
            $(mktmp $(CFG_VARS)) config.w32 > ..\config.sh