From: Craig A. Berry Date: Mon, 30 Oct 2006 00:33:34 +0000 (+0000) Subject: When we open a file and pass it along to PerlIO, be sure to enter the X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7f8ddb16e020167ce98c1281b23751a06033b224;p=p5sagit%2Fp5-mst-13.2.git When we open a file and pass it along to PerlIO, be sure to enter the PerlIO world via Unix I/O. If you start from stdio, a Unix I/O counter will get decremented on close even though it was never incremented (and may not even exist). Exposed by #29065. p4raw-id: //depot/perl@29144 --- diff --git a/vms/ext/Stdio/Stdio.xs b/vms/ext/Stdio/Stdio.xs index 3843641..2609550 100644 --- a/vms/ext/Stdio/Stdio.xs +++ b/vms/ext/Stdio/Stdio.xs @@ -192,12 +192,13 @@ flush(fp) char * getname(fp) - PerlIO * fp + PerlIO * fp PROTOTYPE: $ CODE: + FILE *stdio = PerlIO_exportFILE(fp,0); char fname[NAM$C_MAXRSS+1]; ST(0) = sv_newmortal(); - if (PerlIO_getname(fp,fname) != NULL) sv_setpv(ST(0),fname); + if (fgetname(stdio,fname) != NULL) sv_setpv(ST(0),fname); void rewind(fp) @@ -348,7 +349,7 @@ vmsopen(spec,...) break; } if (fp != Null(FILE*)) { - pio_fp = PerlIO_importFILE(fp,mode); + pio_fp = PerlIO_fdopen(fileno(fp),mode); fh = newFH(pio_fp,(mode[1] ? '+' : (mode[0] == 'r' ? '<' : (mode[0] == 'a' ? 'a' : '>')))); ST(0) = (fh ? sv_2mortal(fh) : &PL_sv_undef); } @@ -363,8 +364,7 @@ vmssysopen(spec,mode,perm,...) CODE: char *args[8]; int i, myargc, fd; - FILE *fp; - PerlIO *pio_fp; + PerlIO *pio_fp; SV *fh; STRLEN n_a; if (!spec || !*spec) { @@ -407,8 +407,7 @@ vmssysopen(spec,mode,perm,...) } i = mode & 3; if (fd >= 0 && - ((fp = fdopen(fd, &("r\000w\000r+"[2*i]))) != Null(FILE*))) { - pio_fp = PerlIO_importFILE(fp,&("r\000w\000r+"[2*i])); + ((pio_fp = PerlIO_fdopen(fd, &("r\000w\000r+"[2*i]))) != Null(PerlIO*))) { fh = newFH(pio_fp,"<>++"[i]); ST(0) = (fh ? sv_2mortal(fh) : &PL_sv_undef); }