This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlio: Fix to work with MVS Dataset
authorYaroslav Kuzmin <ykuzmin@rocketsoftware.com>
Sun, 28 Sep 2014 16:02:17 +0000 (10:02 -0600)
committerKarl Williamson <khw@cpan.org>
Tue, 21 Oct 2014 15:26:49 +0000 (09:26 -0600)
AUTHORS
perlio.c

diff --git a/AUTHORS b/AUTHORS
index 4b059a6..482b2de 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1229,6 +1229,7 @@ Wolfgang Laun                     <Wolfgang.Laun@alcatel.at>
 Wolfram Humann                 <w.c.humann@arcor.de>
 Xavier Noria                   <fxn@hashref.com>
 YAMASHINA Hio                  <hio@ymir.co.jp>
 Wolfram Humann                 <w.c.humann@arcor.de>
 Xavier Noria                   <fxn@hashref.com>
 YAMASHINA Hio                  <hio@ymir.co.jp>
+Yaroslav Kuzmin                 <ykuzmin@rocketsoftware.com>
 Yary Hluchan
 Yasushi Nakajima               <sey@jkc.co.jp>
 Yitzchak Scott-Thoennes                <sthoenna@efn.org>
 Yary Hluchan
 Yasushi Nakajima               <sey@jkc.co.jp>
 Yitzchak Scott-Thoennes                <sthoenna@efn.org>
index 6c742d2..19b73ab 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -2930,11 +2930,27 @@ PerlIO_importFILE(FILE *stdio, const char *mode)
 {
     dTHX;
     PerlIO *f = NULL;
 {
     dTHX;
     PerlIO *f = NULL;
+#ifdef EBCDIC
+        int rc;
+        char filename[FILENAME_MAX];
+        fldata_t fileinfo;
+#endif
     if (stdio) {
        PerlIOStdio *s;
         int fd0 = fileno(stdio);
         if (fd0 < 0) {
     if (stdio) {
        PerlIOStdio *s;
         int fd0 = fileno(stdio);
         if (fd0 < 0) {
+#ifdef EBCDIC
+                         rc = fldata(stdio,filename,&fileinfo);
+                         if(rc != 0){
+                                 return NULL;
+                         }
+                         if(fileinfo.__dsorgHFS){
+            return NULL;
+        }
+                         /*This MVS dataset , OK!*/
+#else
             return NULL;
             return NULL;
+#endif
         }
        if (!mode || !*mode) {
            /* We need to probe to see how we can open the stream
         }
        if (!mode || !*mode) {
            /* We need to probe to see how we can open the stream
@@ -2966,7 +2982,24 @@ PerlIO_importFILE(FILE *stdio, const char *mode)
        if ((f = PerlIO_push(aTHX_(PerlIO_allocate(aTHX)), PERLIO_FUNCS_CAST(&PerlIO_stdio), mode, NULL))) {
            s = PerlIOSelf(f, PerlIOStdio);
            s->stdio = stdio;
        if ((f = PerlIO_push(aTHX_(PerlIO_allocate(aTHX)), PERLIO_FUNCS_CAST(&PerlIO_stdio), mode, NULL))) {
            s = PerlIOSelf(f, PerlIOStdio);
            s->stdio = stdio;
+#ifdef EBCDIC
+               fd0 = fileno(stdio);
+               if(fd0 != -1){
+                       PerlIOUnix_refcnt_inc(fd0);
+               }
+               else{
+                       rc = fldata(stdio,filename,&fileinfo);
+                       if(rc != 0){
+                               PerlIOUnix_refcnt_inc(fd0);
+                       }
+                       if(fileinfo.__dsorgHFS){
+                               PerlIOUnix_refcnt_inc(fd0);
+                       }
+                         /*This MVS dataset , OK!*/
+               }
+#else
            PerlIOUnix_refcnt_inc(fileno(stdio));
            PerlIOUnix_refcnt_inc(fileno(stdio));
+#endif
        }
     }
     return f;
        }
     }
     return f;