This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[5.005_62 PATCH] binmode and locale support for -T and -B filetest operators
authorJan Dubois <jand@activestate.com>
Sat, 6 Nov 1999 22:16:43 +0000 (23:16 +0100)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 6 Nov 1999 23:10:54 +0000 (23:10 +0000)
To: perl5-porters@perl.org
Cc: Mike Blazer <blazer@mail.nevalink.ru>,
        Mark Borgerding <mborgerding@acm.org>
Message-ID: <38279207.46448719@smtprelay.t-online.de>

p4raw-id: //depot/cfgperl@4528

op.c
op.h

diff --git a/op.c b/op.c
index 56c2651..bcf154d 100644 (file)
--- a/op.c
+++ b/op.c
@@ -5017,10 +5017,10 @@ Perl_ck_ftst(pTHX_ OP *o)
     dTHR;
     I32 type = o->op_type;
 
-    if (o->op_flags & OPf_REF)
-       return o;
-
-    if (o->op_flags & OPf_KIDS && cUNOPo->op_first->op_type != OP_STUB) {
+    if (o->op_flags & OPf_REF) {
+       /* nothing */
+    }
+    else if (o->op_flags & OPf_KIDS && cUNOPo->op_first->op_type != OP_STUB) {
        SVOP *kid = (SVOP*)cUNOPo->op_first;
 
        if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
@@ -5028,17 +5028,24 @@ Perl_ck_ftst(pTHX_ OP *o)
            OP *newop = newGVOP(type, OPf_REF,
                gv_fetchpv(SvPVx(kid->op_sv, n_a), TRUE, SVt_PVIO));
            op_free(o);
-           return newop;
+           o = newop;
        }
     }
     else {
        op_free(o);
        if (type == OP_FTTTY)
-           return newGVOP(type, OPf_REF, gv_fetchpv("main::STDIN", TRUE,
+           o =  newGVOP(type, OPf_REF, gv_fetchpv("main::STDIN", TRUE,
                                SVt_PVIO));
        else
-           return newUNOP(type, 0, newDEFSVOP());
+           o = newUNOP(type, 0, newDEFSVOP());
     }
+#ifdef USE_LOCALE
+    if (type == OP_FTTEXT || type == OP_FTBINARY) {
+       o->op_private = 0;
+       if (PL_hints & HINT_LOCALE)
+           o->op_private |= OPpLOCALE;
+    }
+#endif
     return o;
 }
 
diff --git a/op.h b/op.h
index d34435b..c1ce70b 100644 (file)
--- a/op.h
+++ b/op.h
@@ -158,7 +158,8 @@ typedef U32 PADOFFSET;
 /* Private for OP_DELETE */
 #define OPpSLICE               64      /* Operating on a list of keys */
 
-/* Private for OP_SORT, OP_PRTF, OP_SPRINTF, string cmp'n, and case changers */
+/* Private for OP_SORT, OP_PRTF, OP_SPRINTF, OP_FTTEXT, OP_FTBINARY, */
+/*             string comparisons, and case changers. */
 #define OPpLOCALE              64      /* Use locale */
 
 /* Private for OP_SORT */