This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_fbm_instr(): remove dead code.
authorDavid Mitchell <davem@iabyn.com>
Mon, 6 Feb 2017 09:20:04 +0000 (09:20 +0000)
committerDavid Mitchell <davem@iabyn.com>
Mon, 6 Feb 2017 09:32:18 +0000 (09:32 +0000)
For the case where littlestr hasn't been FBM compiled (!SvVALID()), it
can't be SvTAIL(), so there's no need for optional \n handling.

Spotted by Coverity.

util.c

diff --git a/util.c b/util.c
index 53b4109..efe4c02 100644 (file)
--- a/util.c
+++ b/util.c
@@ -951,16 +951,7 @@ Perl_fbm_instr(pTHX_ unsigned char *big, unsigned char *bigend, SV *littlestr, U
        char * const b = ninstr((char*)big,(char*)bigend,
                         (char*)little, (char*)little + littlelen);
 
-       if (!b && tail) {       /* Automatically multiline!  */
-           /* Chop \n from littlestr: */
-           s = bigend - littlelen + 1;
-           if (*s == *little
-               && memEQ((char*)s + 1, (char*)little + 1, littlelen - 2))
-           {
-               return (char*)s;
-           }
-           return NULL;
-       }
+        assert(!tail); /* valid => FBM; tail only set on SvVALID SVs */
        return b;
     }