Deprecate /^/ implictly meaning /^/m.
authorIlya Zakharevich <ilya@math.berkeley.edu>
Wed, 4 Aug 1999 16:46:57 +0000 (12:46 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 5 Aug 1999 08:09:59 +0000 (08:09 +0000)
To: Gurusamy Sarathy <gsar@activestate.com>
Cc: Tom Christiansen <tchrist@jhereg.perl.com>, chaimf@pobox.com,
        ed@chronos.net, perl5-porters@perl.org
Subject: [PATCH 5.00557] split /^/
Message-ID: <19990804164657.A3776@monk.mps.ohio-state.edu>

p4raw-id: //depot/cfgperl@3922

pod/perldiag.pod
pp.c
regexp.h

index 2542838..0ff865d 100644 (file)
@@ -2594,6 +2594,10 @@ See L<perlfunc/sort>.
 (F) A sort comparison subroutine may not return a list value with more
 or less than one element.  See L<perlfunc/sort>.
 
+=item split /^/ better written as split /^/m
+
+(W) Implicit translation of /^/ to mean /^/m in split is deprecated.
+
 =item Split loop
 
 (P) The split was looping infinitely.  (Obviously, a split shouldn't iterate
diff --git a/pp.c b/pp.c
index 18c875b..e3969be 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -5007,7 +5007,13 @@ PP(pp_split)
                ++s;
        }
     }
-    else if (strEQ("^", rx->precomp)) {
+    else if (rx->prelen == 1 && *rx->precomp == '^') {
+       if (!(pm->op_pmflags & PMf_MULTILINE)
+           && !(pm->op_pmregexp->reganch & ROPT_WARNED)) {
+           if (ckWARN(WARN_DEPRECATED))
+               warn("split /^/ better written as split /^/m");
+           pm->op_pmregexp->reganch |= ROPT_WARNED;
+       }       
        while (--limit) {
            /*SUPPRESS 530*/
            for (m = s; m < strend && *m != '\n'; m++) ;
index 5d787e0..414b254 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -69,6 +69,8 @@ typedef struct regexp {
 #define RE_INTUIT_ONECHAR      0x4000000
 #define RE_INTUIT_TAIL         0x8000000
 
+#define ROPT_WARNED            0x10000000
+
 #define RE_USE_INTUIT          (RE_USE_INTUIT_NOML|RE_USE_INTUIT_ML)
 #define REINT_AUTORITATIVE     (REINT_AUTORITATIVE_NOML|REINT_AUTORITATIVE_ML)
 #define REINT_ONCE             (REINT_ONCE_NOML|REINT_ONCE_ML)