Port QRegExp to QRegularExpression
ClosedPublic

Authored by ahmadsamir on Dec 23 2019, 9:35 AM.

Details

Summary

Port QRegExp::exactMatch() by using QRegularExpression::anchoredPattern()
to match the entire subject string.

Remove filenameOnly(), it's been broken for a long time (QStringLiteral("[/\\]")
is not a valid QRegExp pattern); besides it's not needed as QFileInfo::fileName()
is used to get the filename.

Test Plan

make && ctest

Diff Detail

Repository
R237 KConfig
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ahmadsamir created this revision.Dec 23 2019, 9:35 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptDec 23 2019, 9:35 AM
ahmadsamir requested review of this revision.Dec 23 2019, 9:35 AM
ahmadsamir planned changes to this revision.Dec 23 2019, 9:39 AM
ahmadsamir requested review of this revision.Dec 23 2019, 9:46 AM

IINM, fileNameOnly() can be safely deleted; it's only used once on line 2226:
fileNameOnly(baseName)

and baseName is initialised on line 1630:
QString baseName = QFileInfo(codegenFilename).fileName();
so it's the filename only, excluding the path, so it'll never have / or \ in it, IIUC. And the fact it's been broken at least since the kdelibs split in 2013.

ervin added a comment.Dec 23 2019, 1:44 PM

Looks good to me. Not putting the accept flag yet to give more times to others to review those critical bits.

dfaure requested changes to this revision.Dec 24 2019, 9:27 AM
dfaure added inline comments.
src/kconfig_compiler/kconfig_compiler.cpp
643–644

I wonder if qMax(path.lastIndexOf('/'), path.lastIndexOf('\\')) wouldn't be simpler and faster :-)

But yes you're right, might as well just delete this function.
I bet someone didn't realize, LONG ago, that even on Windows, Qt uses '/' in almost all of the API.

This revision now requires changes to proceed.Dec 24 2019, 9:27 AM
ahmadsamir updated this revision to Diff 72137.Dec 24 2019, 9:48 AM
ahmadsamir marked an inline comment as done.

Remove fileNameOnly() as per discussion in the review

ahmadsamir updated this revision to Diff 72138.Dec 24 2019, 9:48 AM
ahmadsamir edited the summary of this revision. (Show Details)

Ver-blinking-batim

ahmadsamir added inline comments.Dec 24 2019, 9:49 AM
src/kconfig_compiler/kconfig_compiler.cpp
643–644

Yep; (and who knows if Qt docs were as expansive/exhaustive as they're now :)).

And then fileNameOnly() became unneeded when QFileInfo was used in the code.

ervin accepted this revision.Dec 26 2019, 2:22 PM
dfaure accepted this revision.Dec 31 2019, 9:01 AM
dfaure added inline comments.
src/kconfig_compiler/kconfig_compiler.cpp
643–644

I do, and they were, that was always a big selling point for Qt ;)

(I started contributing to KDE at the time of Qt 1.1, in 1998)

This revision is now accepted and ready to land.Dec 31 2019, 9:01 AM
ahmadsamir added inline comments.Dec 31 2019, 9:06 AM
src/kconfig_compiler/kconfig_compiler.cpp
643–644

:D

This revision was automatically updated to reflect the committed changes.