summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qregularexpression.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QRegularExpression: refactor the handling of the study dataGiuseppe D'Angelo2013-03-121-17/+24
| | | | | | | | | | | | | | | | | | | | Consider the following situation: - threads A and B have shallow copies of the same QRegularExpression - threads A and B both call match() on a string - thread A calls optimizePattern(), which doesn't optimize - thread B calls optimizePattern(), which does optimize, and sets studyData - thread A uses studyData (set by B) A needs to properly acquire the memory pointed by studyData (which, in turn, needs to be released by B). This commit implements that. (Before, we used to return a copy of the current studyData from optimizePattern(), so A didn't see that B optimized the pattern and set studyData). Change-Id: I9e4741a3d3229905c247491a07099519815680bb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve QRegularExpression captureCount / namedCaptureGroups docsGiuseppe D'Angelo2013-02-121-4/+23
| | | | | | | | | | | We need to clarify what's the status of the implicit capturing group #0 in both of this methods. The former doesn't include it, while the latter does for convenience/consistency in the way we count the capturing groups. (Note that this last behavior is actually autotested.) Change-Id: I2170842c2a6dffa34fa56389ceead61a92c07cd1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: print a warning if (?J) is used in a patternGiuseppe D'Angelo2013-02-121-0/+8
| | | | | | | | | (?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>
* QRegularExpression: don't use study data when getting the pattern infoGiuseppe D'Angelo2013-02-121-1/+2
| | | | | | | | | | | | | | Information about the pattern (number of capturing groups, newline settings, etc.) are grabbed when the pattern is compiled the first time. Studying (=> optimizing) is always done later, after a certain amount of usages. In case this ever changes, add an assert. Besides, we're not grabbing any info that require studying the pattern first. Change-Id: Ica15fa21f7bf13213288d7090d3396a89900078e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: add method for extracting the capturing group namesGiuseppe D'Angelo2013-02-051-0/+48
| | | | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-01-221-2/+2
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsavefile_p.h src/corelib/tools/qregularexpression.cpp src/gui/util/qvalidator.cpp src/gui/util/qvalidator.h Change-Id: I58fdf0358bd86e2fad5d9ad0556f3d3f1f535825
| * QRegularExpression: fix wrong argument type for pcre_fullinfoGiuseppe D'Angelo2013-01-201-1/+1
| | | | | | | | | | | | | | | | | | The pcre(3) man page says that the 4th argument of pcre_fullinfo, when requesting PCRE_INFO_OPTIONS, should point to an unsigned long int variable. Change-Id: I72cd5ab208687715329566556c5f279db57f7872 Reviewed-by: Richard J. Moore <rich@kde.org>
| * Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | | | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Introduce default ctors for QRegularExpressionMatch(Iterator)Giuseppe D'Angelo2013-01-141-0/+40
| | | | | | | | | | | | | | | | 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>
* | Avoid a QVector allocation in QRegularExpressionMatchPrivateGiuseppe D'Angelo2013-01-141-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Explicitely pass the number of capturing groups for which the offsets should be reserved in the capturedOffsets vector, instead of relying on it adding 1 (for the implicit capturing group #0). In case 0 is passed, don't allocate any space for that vector. This is being used in case of NoMatch match type or failing match (invalid regexp, out of bounds offset, etc.). Change-Id: I0ec7646d5bd53e7a7973177100b163a5e5030307 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Introduce QRegularExpression::NoMatch match typeGiuseppe D'Angelo2013-01-071-0/+17
|/ | | | | | | | | | 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>
* Add new error strings to QRegularExpressionGiuseppe D'Angelo2012-10-181-1/+3
| | | | | | | | They are introduced in PCRE 8.31. Change-Id: Id0447b381d5e23996d4e87ae0368b07a8bc1c318 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | 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>
* fix docsFrederik Gladhorn2012-09-031-5/+1
| | | | | | Change-Id: Id57b7932afb89fe9d3f4f6e6c3b558265475d77b Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Doc: Add \inmodule QtCore to all QtCore class doc bodiesThiago Macieira2012-08-231-0/+4
| | | | | Change-Id: I19100755c97cc155c76a859e19940e9f9222d34e Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Fix some spelling errorsSergio Ahumada2012-07-111-4/+4
| | | | | | Change-Id: I19d3b2e9a5180b13deb828b55195404ef20be295 Reviewed-by: Daniel Teske <daniel.teske@nokia.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QRegularExpression: Fix warnings about deprecated tr()-function.Friedemann Kleint2012-05-211-2/+2
| | | | | Change-Id: I2325bcab9bb80e5507f53887b282a859d0fdb58c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Doc: Prepare for building modular QtCore docs.Casper van Donderen2012-04-191-32/+32
| | | | | | | | | | | | This change fixes most qdoc errors in QtCore. There are about 900 left. The main thing this change does is moving documentation from qtcore from /doc/src to /src/corelib/doc. Other issues resolved are mis-use of qdoc commands. Change-Id: I002d01edfb13575e8bf27ce91596a577a92562d1 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com> Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
* qdoc: Fixed bugs causing invalid DITA XMLMartin Smith2012-04-141-1/+1
| | | | | | | | | | | Fixed a bug in qdoc that caused too many end elements to be generated. Also fixed some doc errors that caused invalid DITA to be generated. Task nr: QTBUG-25302 Change-Id: Ifbbf457d28c51c2691a252888447739da7713bc9 Reviewed-by: Martin Smith <martin.smith@nokia.com> Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* QRegularExpression: optimize global matchGiuseppe D'Angelo2012-04-121-1/+12
| | | | | | | | | | | | | | | | | | | | PCRE doesn't like illegal Unicode sequences (it's explicitely documented in pcreunicode(3) that they trigger undefined behaviour, and the program may crash). Therefore, we always let PCRE check the validity of both the pattern and the subject string. However, when performing global matching, the subject string can be checked only once: subsequent matches can safely skip the check and avoid a huge performance hit of scanning the whole subject string for each match (!). This patch implements that behaviour internally -- it's still not possible for the user to skip the sanity check. On large subject strings, this gives a terrific performance benefit. Change-Id: Ia44cf18782e07966c9cd6ec4ccfef081ed131763 Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: operator<<(QDebug, PatternOptions) improvementsGiuseppe D'Angelo2012-03-311-12/+12
| | | | | | | | Avoid building a QStringList and then joining the strings with pipes; directly append the flags to a QByteArray instead. Change-Id: Ic352b756ed1e3b6b579b9ca412636a2b394d2eb5 Reviewed-by: hjk <qthjk@ovi.com>
* QRegularExpression: various documentation improvements/fixesGiuseppe D'Angelo2012-03-161-11/+28
| | | | | Change-Id: I683afb24f888ab6cf3c543fba8cd193a730709af Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* QRegularExpression: add error strings for translationGiuseppe D'Angelo2012-03-121-0/+115
| | | | | | | | | | Added the error strings from PCRE to be picked up by lupdate, to enable translations. Change-Id: Iaeabde5d7a17f9a0273511e0741e67a097d23a98 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QRegularExpression: minor fix to captureIndexForNameGiuseppe D'Angelo2012-03-081-0/+3
| | | | | | | | | | | | 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>
* QRegularExpression: improve JIT memory handlingGiuseppe D'Angelo2012-03-081-12/+84
| | | | | | | | | | | | | | | | | 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>
* QRegularExpression: add optimizations autotestGiuseppe D'Angelo2012-03-071-5/+9
| | | | | | | | | | | | | | | 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>
* QRegularExpression: fix optimizePattern, document the issueGiuseppe D'Angelo2012-03-071-7/+24
| | | | | | | | | | | | | | The studyData pointer is atomically set by the pointer assignment, but another processor running a different thread might see the new studyData value but not the memory it points to. Therefore, the current studyData is returned from optimizePattern and used by that thread. Docs were added to optimizePattern to explain what's going on. Change-Id: I4502c336077bb98a1751011aa93ffd4f585ed101 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: fix documentation due to qdoc changesGiuseppe D'Angelo2012-03-071-16/+16
| | | | | | | Removes the usage of various qdoc macros which are now deprecated. Change-Id: I74fa70f8d2a2a1bff57cdb2bcc14a31a7198dea0 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* QRegularExpression: const correctness fixesGiuseppe D'Angelo2012-03-061-9/+9
| | | | | | | Adding some const qualifiers to members which are never written. Change-Id: Ibb8953764c7b7790a419a5d48f2956751d5fc1f9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: add captureCount()Giuseppe D'Angelo2012-03-061-0/+13
| | | | | | | | QRegularExpression::captureCount() returns the number of capturing groups inside the regular expression pattern. Change-Id: Ib90ce67c67d06ab2966f0c98bd91da21defc156d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: do not use JIT in debug buildsGiuseppe D'Angelo2012-03-061-1/+41
| | | | | | | | | | | | | PCRE's JIT uses self-modifying code extensively, requiring full SMC checks enabled by tools like valgrind, which slow down the execution considerably; not enabling SMC checks lead to crashes. Therefore, JIT is now disabled by default in debug builds of Qt. Its usage (both in debug and release builds) can be controlled by setting the QT_ENABLE_REGEXP_JIT environment variable. Change-Id: Ib38952400e4219582942ce65ab9edcd89c432f3e Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QRegularExpression: improve operator==, add dedicated autotestGiuseppe D'Angelo2012-03-061-1/+2
| | | | | | | | Trivial change: compare dpointers first, then the data. Added test function for operator==. Change-Id: I33ac64a59db4ccad56c30be17622187e42415f38 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QRegularExpression: QDebug support for pattern optionsGiuseppe D'Angelo2012-03-061-0/+37
| | | | | | | | | Added the proper QDebug operator to debug the QRegularExpression::PatternOptions flags. Change-Id: Icd00e93a0c6cc4345db528d494fc176624f7b7a2 Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QRegularExpression: add QRegularExpression* set of classesGiuseppe D'Angelo2012-03-061-0/+2022
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>