diff options
-rw-r--r-- | doio.c | 23 | ||||
-rw-r--r-- | pp_hot.c | 4 |
2 files changed, 14 insertions, 13 deletions
@@ -87,7 +87,7 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, register IO *io = GvIOn(gv); PerlIO *saveifp = Nullfp; PerlIO *saveofp = Nullfp; - char savetype = ' '; + char savetype = IoTYPE_CLOSED; int writing = 0; PerlIO *fp; int fd; @@ -216,14 +216,14 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, } mode[0] = mode[1] = mode[2] = mode[3] = '\0'; IoTYPE(io) = *type; - if (*type == '+' && tlen > 1 && type[tlen-1] != '|') { /* scary */ + if (*type == IoTYPE_RDWR && tlen > 1 && type[tlen-1] != IoTYPE_PIPE) { /* scary */ mode[1] = *type++; --tlen; writing = 1; } - if (*type == '|') { - if (num_svs && (tlen != 2 || type[1] != '-')) { + if (*type == IoTYPE_PIPE) { + if (num_svs && (tlen != 2 || type[1] != IoTYPE_STD)) { unknown_desr: Perl_croak(aTHX_ "Unknown open() mode '%.*s'", (int)olen, oname); } @@ -261,10 +261,11 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, } writing = 1; } - else if (*type == '>') { + else if (*type == IoTYPE_WRONLY) { TAINT_PROPER("open"); type++; - if (*type == '>') { + if (*type == IoTYPE_WRONLY) { + /* Two IoTYPE_WRONLYs in a row make for an IoTYPE_APPEND. */ mode[0] = IoTYPE(io) = IoTYPE_APPEND; type++; tlen--; @@ -348,7 +349,7 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, else { /*SUPPRESS 530*/ for (; isSPACE(*type); type++) ; - if (strEQ(type,"-")) { + if (*type == IoTYPE_STD && !type[1]) { fp = PerlIO_stdout(); IoTYPE(io) = IoTYPE_STD; } @@ -357,7 +358,7 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, } } } - else if (*type == '<') { + else if (*type == IoTYPE_RDONLY) { if (num_svs && tlen != 1) goto unknown_desr; /*SUPPRESS 530*/ @@ -372,16 +373,16 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, name = type; goto duplicity; } - if (strEQ(type,"-")) { + if (*type == IoTYPE_STD && !type[1]) { fp = PerlIO_stdin(); IoTYPE(io) = IoTYPE_STD; } else fp = PerlIO_open((num_svs ? name : type), mode); } - else if (tlen > 1 && type[tlen-1] == '|') { + else if (tlen > 1 && type[tlen-1] == IoTYPE_PIPE) { if (num_svs) { - if (tlen != 2 || type[0] != '-') + if (tlen != 2 || type[0] != IoTYPE_STD) goto unknown_desr; } else { @@ -1339,7 +1339,7 @@ Perl_do_readline(pTHX) } else { PerlIO_rewind(tmpfp); - IoTYPE(io) = '<'; + IoTYPE(io) = IoTYPE_RDONLY; IoIFP(io) = fp = tmpfp; IoFLAGS(io) &= ~IOf_UNTAINT; /* maybe redundant */ } @@ -1393,7 +1393,7 @@ Perl_do_readline(pTHX) else if (type == OP_GLOB) SP--; else if (ckWARN(WARN_IO) /* stdout/stderr or other write fh */ - && (IoTYPE(io) == '>' || fp == PerlIO_stdout() + && (IoTYPE(io) == IoTYPE_WRONLY || fp == PerlIO_stdout() || fp == PerlIO_stderr())) { /* integrate with report_evil_fh()? */ |