From: Jarkko Hietaniemi Date: Sat, 3 May 2003 05:33:04 +0000 (+0000) Subject: Salvage 'use filetest "access"' from compiletime to runtime. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1af34c76bc1167bbfada70004d6cbc41b0098f64;p=p5sagit%2Fp5-mst-13.2.git Salvage 'use filetest "access"' from compiletime to runtime. p4raw-id: //depot/perl@19392 --- diff --git a/dump.c b/dump.c index 244d064..119bfa3 100644 --- a/dump.c +++ b/dump.c @@ -616,6 +616,10 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, OP *o) if (o->op_private & OPpHUSH_VMSISH) sv_catpv(tmpsv, ",HUSH_VMSISH"); } + else if (OP_IS_FILETEST_ACCESS(o)) { + if (o->op_private & OPpFT_ACCESS) + sv_catpv(tmpsv, ",FT_ACCESS"); + } if (o->op_flags & OPf_MOD && o->op_private & OPpLVAL_INTRO) sv_catpv(tmpsv, ",INTRO"); if (SvCUR(tmpsv)) diff --git a/op.c b/op.c index e32eab6..be05875 100644 --- a/op.c +++ b/op.c @@ -4933,6 +4933,11 @@ Perl_ck_ftst(pTHX_ OP *o) op_free(o); o = newop; } + else { + if ((PL_hints & HINT_FILETEST_ACCESS) && + OP_IS_FILETEST_ACCESS(o)) + o->op_private |= OPpFT_ACCESS; + } } else { op_free(o); diff --git a/op.h b/op.h index 831ccbb..cfc5e2b 100644 --- a/op.h +++ b/op.h @@ -205,6 +205,16 @@ Deprecated. Use C instead. #define OPpHUSH_VMSISH 64 /* hush DCL exit msg vmsish mode*/ #define OPpEXIT_VMSISH 128 /* exit(0) vs. exit(1) vmsish mode*/ +/* Private of OP_FTXXX */ +#define OPpFT_ACCESS 2 /* use filetest 'access' */ +#define OP_IS_FILETEST_ACCESS(op) \ + (((op)->op_type) == OP_FTRREAD || \ + ((op)->op_type) == OP_FTRWRITE || \ + ((op)->op_type) == OP_FTREXEC || \ + ((op)->op_type) == OP_FTEREAD || \ + ((op)->op_type) == OP_FTEWRITE || \ + ((op)->op_type) == OP_FTEEXEC) + struct op { BASEOP }; diff --git a/pp_sys.c b/pp_sys.c index 11b8edf..ae92422 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2850,7 +2850,7 @@ PP(pp_ftrread) dSP; #if defined(HAS_ACCESS) && defined(R_OK) STRLEN n_a; - if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) { + if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) { result = access(TOPpx, R_OK); if (result == 0) RETPUSHYES; @@ -2877,7 +2877,7 @@ PP(pp_ftrwrite) dSP; #if defined(HAS_ACCESS) && defined(W_OK) STRLEN n_a; - if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) { + if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) { result = access(TOPpx, W_OK); if (result == 0) RETPUSHYES; @@ -2904,7 +2904,7 @@ PP(pp_ftrexec) dSP; #if defined(HAS_ACCESS) && defined(X_OK) STRLEN n_a; - if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) { + if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) { result = access(TOPpx, X_OK); if (result == 0) RETPUSHYES; @@ -2931,7 +2931,7 @@ PP(pp_fteread) dSP; #ifdef PERL_EFF_ACCESS_R_OK STRLEN n_a; - if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) { + if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) { result = PERL_EFF_ACCESS_R_OK(TOPpx); if (result == 0) RETPUSHYES; @@ -2958,7 +2958,7 @@ PP(pp_ftewrite) dSP; #ifdef PERL_EFF_ACCESS_W_OK STRLEN n_a; - if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) { + if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) { result = PERL_EFF_ACCESS_W_OK(TOPpx); if (result == 0) RETPUSHYES; @@ -2985,7 +2985,7 @@ PP(pp_fteexec) dSP; #ifdef PERL_EFF_ACCESS_X_OK STRLEN n_a; - if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) { + if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) { result = PERL_EFF_ACCESS_X_OK(TOPpx); if (result == 0) RETPUSHYES;