QRegularExpression: fix matching over QStringRefs
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Mon, 17 Aug 2015 09:28:16 +0000 (11:28 +0200)
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Tue, 18 Aug 2015 14:18:48 +0000 (14:18 +0000)
commitee15bef3ea24a78e5fd4708c0a1cebee2e4fac5d
treecf1322ef5c14b2ae77602509fff582561dba9503
parent4738b450d26b6cdaed6f9f11f0dc22b842c124df
QRegularExpression: fix matching over QStringRefs

Playing with the offset argument of pcre_exec is not equivalent to
adjusting the pointer to the subject string. In particular, PCRE
can go behind the offset to check for lookbehinds or "transition"
metacharacters (\b, \B, etc.).

This made the code that deals with QStringRefs not matching in behavior
with the corresponding code dealing with QStrings. For instance,

   QString subject("Miss");
   QRegularExpression re("(?<=M)iss");
   re.match(subject.mid(1));           // doesn't match
   re.match(subject.midRef(1));        // matches!!!

Instead, actually adjust the pointer to the subject string so that
the behavior is identical. A broken test that relied on the
equivalence is also removed.

Change-Id: If96333241ef59621d7f5a6a170ebd0a186844874
Reviewed-by: Volker Krause <volker.krause@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qregularexpression.cpp
tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h