summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-01-20 19:42:30 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-01-20 19:42:30 +0000
commita567e93b903bc9849952c06533059c2f2e2fb226 (patch)
treea93a49d4b98bf39c527f7d33fb2568de0fc2c201 /pp_sys.c
parent3b6eb69b03afe7feeb11252d06d9daecc9c262f1 (diff)
downloadperl-a567e93b903bc9849952c06533059c2f2e2fb226.tar.gz
Infrastructure to allow:
open($fh,"|-",@array); to be implemented i.e. mark pp_open as needing a stack mark, and make pp_open process its args in that style (and pass them _all_ to tied handles OPEN). Invent do_openn() which takes SV ** at allow it to see multiple args. Note this does not _do_ anything yet. p4raw-id: //depot/perlio@8484
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 32fd6864b1..8d3200e825 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -492,7 +492,9 @@ PP(pp_die)
PP(pp_open)
{
- djSP; dTARGET;
+ djSP;
+ dMARK; dORIGMARK;
+ dTARGET;
GV *gv;
SV *sv;
SV *name = Nullsv;
@@ -500,29 +502,19 @@ PP(pp_open)
char *tmps;
STRLEN len;
MAGIC *mg;
+ bool ok;
- if (MAXARG > 2) {
- name = POPs;
- have_name = 1;
- }
- if (MAXARG > 1)
- sv = POPs;
- if (!isGV(TOPs))
- DIE(aTHX_ PL_no_usym, "filehandle");
- if (MAXARG <= 1)
- sv = GvSV(TOPs);
- gv = (GV*)POPs;
+ gv = (GV *)*++MARK;
if (!isGV(gv))
DIE(aTHX_ PL_no_usym, "filehandle");
if (GvIOp(gv))
IoFLAGS(GvIOp(gv)) &= ~IOf_UNTAINT;
if ((mg = SvTIED_mg((SV*)gv, 'q'))) {
- PUSHMARK(SP);
- XPUSHs(SvTIED_obj((SV*)gv, mg));
- XPUSHs(sv);
- if (have_name)
- XPUSHs(name);
+ /* Method's args are same as ours ... */
+ /* ... except handle is replaced by the object */
+ *MARK-- = SvTIED_obj((SV*)gv, mg);
+ PUSHMARK(MARK);
PUTBACK;
ENTER;
call_method("OPEN", G_SCALAR);
@@ -531,8 +523,17 @@ PP(pp_open)
RETURN;
}
+ if (MARK < SP) {
+ sv = *++MARK;
+ }
+ else {
+ sv = GvSV(gv);
+ }
+
tmps = SvPV(sv, len);
- if (do_open9(gv, tmps, len, FALSE, O_RDONLY, 0, Nullfp, name, have_name))
+ ok = do_openn(gv, tmps, len, FALSE, O_RDONLY, 0, Nullfp, MARK+1, (SP-MARK));
+ SP = ORIGMARK;
+ if (ok)
PUSHi( (I32)PL_forkprocess );
else if (PL_forkprocess == 0) /* we are a new child */
PUSHi(0);
@@ -3602,7 +3603,7 @@ PP(pp_mkdir)
* trailing slashes. To err on the side of portability, we
* snip away one trailing slash. */
if (tmps[len-1] == '/') {
- tmps = savepvn(tmps, len - 1);
+ tmps = savepvn(tmps, len - 1);
copy = TRUE;
}