(?J) inside a pattern string can be used to allow or disallow duplicated
capturing group names in the pattern string itself.
Although PCRE supports duplicated names, in Qt we don't yet.
Change-Id: I21cd0c41273cd7ef42870ced3a0fad6ba7035cbc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
It may be useful to know which named capturing groups are defined
in an regular expression, and for each of them, what's the
corresponding index. This commit adds the needed method
to QRegularExpression.
Note that extracting the information doesn't happen while holding
the mutex in the private -- pcre_fullinfo just reads information
from the compiled pattern, so that's thread-safe.
Task-number: QTBUG-29079
Change-Id: I50c00ee860f06427c2e6ea10417d5c0733cc8303
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This allows to put them in containers, and to enable subsequent
features for QString.
Change-Id: I3b3fe695ffe6930331ed9f670738376722e0fc36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This match type doesn't do any match at all; it's only necessary to
properly introduce default constructors for QRegularExpressionMatch
and QRegularExpressionMatchIterator (since they return the match type
that created them).
Change-Id: Ibfe92459c7fdd23129cf3afe073cd443c461ddeb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Check that the regular expression, the match type and the match options
returned by QRegularExpression/QRegularExpressionIterator are the
same ones passed to match / globalMatch.
Change-Id: Ibd282379bb60b53d614b1d56a7e08b3d6c236da6
Reviewed-by: Jason McDonald <macadder1@gmail.com>
These types are either built-in or 'automatically declared' and so
don't need to be explicitly declared as metatypes.
Change-Id: I54523eb854619917123d8816d3cd6c3a1f5b4c55
Reviewed-by: David Faure <david.faure@kdab.com>
Change copyrights and license headers from Nokia to Digia
Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
Qt 5.0 beta requires changing the default to the 5.0 API, disabling
the deprecated code. However, tests should test (and often do) the
compatibility API too, so turn it back on.
Task-number: QTBUG-25053
Change-Id: I8129c3ef3cb58541c95a32d083850d9e7f768927
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Although passing a null pointer to pcre16_get_stringnumber for
the compiled pattern should simply make it error out, it's actually
an undocumented behaviour, so let's stay safe and add an explicit
check.
Tests for this codepath are added.
Change-Id: Ifd9c87874f6812ba487104ec1a5bbc83c3b16761
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
PCRE's JIT uses by default 32K on the pcre_exec caller's stack. This
is fine for most situations, but in some cases (esp. patterns with
lot of recursion) more memory is required.
Therefore, if a match execution fails due to exhausting JIT memory,
we let PCRE allocate up to 512KB to be used for the JIT's stack.
The pointer to the allocated memory is put in thread local storage
(so it can be reused from the same thread, if needed, and automatically
goes away when the thread dies).
Change-Id: Ica5fb7d517068befff88ebb198a603a26ec5d8a7
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Exporting the counter that controls the optimization of a compiled
pattern lets us to forcibly optimize all patterns. Therefore,
two tests are now run: one with default optimization values
and another one which always optimizes the pattern.
The counter itself was renamed with a qt_ prefix and put
inside the Qt compilation namespace
(thanks to rohanpm for pointing it out).
Change-Id: I56602433d37adc127772b2d0d2cdaf2e49d43c71
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Some minor fixes: obviously, a valid match always come from a
valid regular expression, but a valid regular expression can create
an invalid match (internal error during matching).
Also, testing an invalid iterator should silence the emitted
warnings.
Change-Id: I585bb99a81e22f108601fd66bf30b56e0229d68b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QRegularExpression::captureCount() returns the number of
capturing groups inside the regular expression pattern.
Change-Id: Ib90ce67c67d06ab2966f0c98bd91da21defc156d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Trivial change: compare dpointers first, then the data.
Added test function for operator==.
Change-Id: I33ac64a59db4ccad56c30be17622187e42415f38
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Added QRegularExpression, QRegularExpressionMatch and
QRegularExpressionMatchIterator as PCRE-enabled, regexp classes.
Documentation is included, as well as a first round of autotests.
Task-number: QTBUG-23489
Change-Id: Id47031b80602c913ccd2fd740070e3024ea06abc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>