diff options
author | Mike Fulton <mikefultonpersonal@gmail.com> | 2021-12-31 14:00:56 -0800 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-01-01 18:13:30 -0700 |
commit | 907549069d51f344f31646b6ff2107bd43593781 (patch) | |
tree | fec8ffff9fabbd8d4cbf9dca7a6f66e84ee4a11a /util.c | |
parent | 53de846c3ad88dee846624ea33034c45122882a1 (diff) | |
download | perl-907549069d51f344f31646b6ff2107bd43593781.tar.gz |
z/OS ASCII needs file descriptors on pipes tagged as ASCII
Add code to change the file descriptor on the file descriptors opened from
``Perl_my_popen_list`` and ``Perl_my_popen`` so that the CCSID of the file
descriptor is 819. This change is only when the code is built for
ASCII ``#if (__CHARSET_LIB == 1)`` on z/OS ``#if defined(OEMVS)``.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -2646,6 +2646,22 @@ Perl_unlnk(pTHX_ const char *f) /* unlink all versions of a file */ } #endif +#if defined(OEMVS) + #if (__CHARSET_LIB == 1) + static int chgfdccsid(int fd, unsigned short ccsid) + { + attrib_t attr; + memset(&attr, 0, sizeof(attr)); + attr.att_filetagchg = 1; + attr.att_filetag.ft_ccsid = ccsid; + if (ccsid != FT_BINARY) { + attr.att_filetag.ft_txtflag = 1; + } + return __fchattr(fd, &attr, sizeof(attr)); + } + #endif +#endif + PerlIO * Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args) { @@ -2693,6 +2709,12 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args) /* Close parent's end of error status pipe (if any) */ if (did_pipes) PerlLIO_close(pp[0]); +#if defined(OEMVS) + #if (__CHARSET_LIB == 1) + chgfdccsid(p[THIS], 819); + chgfdccsid(p[THAT], 819); + #endif +#endif /* Now dup our end of _the_ pipe to right position */ if (p[THIS] != (*mode == 'r')) { PerlLIO_dup2(p[THIS], *mode == 'r'); @@ -2768,7 +2790,20 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args) } if (did_pipes) PerlLIO_close(pp[0]); +#if defined(OEMVS) + #if (__CHARSET_LIB == 1) + PerlIO* io = PerlIO_fdopen(p[This], mode); + if (io) { + chgfdccsid(p[This], 819); + } + return io; + #else return PerlIO_fdopen(p[This], mode); + #endif +#else + return PerlIO_fdopen(p[This], mode); +#endif + #else # if defined(OS2) /* Same, without fork()ing and all extra overhead... */ return my_syspopen4(aTHX_ NULL, mode, n, args); @@ -2835,6 +2870,12 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode) #define THAT This if (did_pipes) PerlLIO_close(pp[0]); +#if defined(OEMVS) + #if (__CHARSET_LIB == 1) + chgfdccsid(p[THIS], 819); + chgfdccsid(p[THAT], 819); + #endif +#endif if (p[THIS] != (*mode == 'r')) { PerlLIO_dup2(p[THIS], *mode == 'r'); PerlLIO_close(p[THIS]); @@ -2921,7 +2962,19 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode) } if (did_pipes) PerlLIO_close(pp[0]); +#if defined(OEMVS) + #if (__CHARSET_LIB == 1) + PerlIO* io = PerlIO_fdopen(p[This], mode); + if (io) { + chgfdccsid(p[This], 819); + } + return io; + #else return PerlIO_fdopen(p[This], mode); + #endif +#else + return PerlIO_fdopen(p[This], mode); +#endif } #elif defined(__LIBCATAMOUNT__) PerlIO * |