summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>1999-05-06 21:44:38 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>1999-05-06 21:44:38 +0000
commit3eb568f1c9e22faaefbd6531878f947fab30705b (patch)
treeabc3121aecba55eeb60e8055e9b880e5b069878f
parent8bac7e006f7f6c2e6c054095234f5f206bed20e9 (diff)
downloadperl-3eb568f1c9e22faaefbd6531878f947fab30705b.tar.gz
open(FH,undef) # creates new_tmpfile opened read/write
Add t/io/open.t with test for above. p4raw-id: //depot/perl@3315
-rw-r--r--pp_sys.c12
-rwxr-xr-xt/io/open.t22
2 files changed, 34 insertions, 0 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 45eee0b698..3f4a112276 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -506,6 +506,18 @@ PP(pp_open)
DIE(PL_no_usym, "filehandle");
if (GvIOp(gv))
IoFLAGS(GvIOp(gv)) &= ~IOf_UNTAINT;
+ if (sv == &PL_sv_undef) {
+#ifdef PerlIO
+ PerlIO *fp = PerlIO_tmpfile();
+#else
+ PerlIO *fp = tmpfile();
+#endif
+ if (fp != Nullfp && do_open(gv, "+>&", 3, FALSE, 0, 0, fp))
+ PUSHi( (I32)PL_forkprocess );
+ else
+ RETPUSHUNDEF;
+ RETURN;
+ }
tmps = SvPV(sv, len);
if (do_open(gv, tmps, len, FALSE, O_RDONLY, 0, Nullfp))
PUSHi( (I32)PL_forkprocess );
diff --git a/t/io/open.t b/t/io/open.t
new file mode 100755
index 0000000000..819393f29b
--- /dev/null
+++ b/t/io/open.t
@@ -0,0 +1,22 @@
+#!./perl
+
+# $RCSfile$
+$| = 1;
+
+print "1..6\n";
+
+print "$!\nnot " unless open(A,undef);
+print "ok 1\n";
+print "not " unless print A "SomeData\n";
+print "ok 2\n";
+print "not " unless tell(A) == 9;
+print "ok 3\n";
+print "not " unless seek(A,0,0);
+print "ok 4\n";
+$b = <A>;
+print "not " unless $b eq "SomeData\n";
+print "ok 5\n";
+print "not " unless close(A);
+print "ok 6\n";
+
+