diff --git a/bookmarks/kio_bookmarks.cpp b/bookmarks/kio_bookmarks.cpp --- a/bookmarks/kio_bookmarks.cpp +++ b/bookmarks/kio_bookmarks.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -181,7 +181,8 @@ void BookmarksProtocol::get( const QUrl& url ) { QString path = url.path(); - QRegExp regexp("^/(background|icon)/([\\S]+)"); + const QRegularExpression regexp(QStringLiteral("^/(background|icon)/([\\S]+)")); + QRegularExpressionMatch rmatch; if (path.isEmpty() || path == "/") { echoIndex(); @@ -191,8 +192,8 @@ } else if (path == "/editbookmarks") { KToolInvocation::kdeinitExec("keditbookmarks"); echoHead("bookmarks:/"); - } else if (regexp.indexIn(path) >= 0) { - echoImage(regexp.cap(1), regexp.cap(2), QUrlQuery(url).queryItemValue("size")); + } else if (path.indexOf(regexp, 0, &rmatch) >= 0) { + echoImage(rmatch.captured(1), rmatch.captured(2), QUrlQuery(url).queryItemValue("size")); } else { echoHead(); echo("

" + i18n("Wrong request: %1", url.toDisplayString().toHtmlEscaped()) + "

"); diff --git a/fish/fish.cpp b/fish/fish.cpp --- a/fish/fish.cpp +++ b/fish/fish.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -787,16 +787,16 @@ va_start(list, cmd); QString realCmd = info.command; QString realAlt = info.alt; - static QRegExp rx("[][\\\\\n $`#!()*?{}~&<>;'\"%^@|\t]"); + static const QRegularExpression rx("[][\\\\\n $`#!()*?{}~&<>;'\"%^@|\t]"); for (int i = 0; i < info.params; i++) { QString arg(va_arg(list, const char *)); int pos = -2; - while ((pos = rx.indexIn(arg,pos+2)) >= 0) { + while ((pos = arg.indexOf(rx, pos + 2)) >= 0) { arg.replace(pos,0,QString("\\")); } //myDebug( << "arg " << i << ": " << arg); realCmd.append(" ").append(arg); - realAlt.replace(QRegExp('%'+QString::number(i+1)),arg); + realAlt.replace(QRegularExpression(QLatin1Char('%') + QString::number(i + 1)), arg); } QString s("#"); s.append(realCmd).append("\n ").append(realAlt).append(" 2>&1;echo '### 000'\n"); diff --git a/man/kio_man.cpp b/man/kio_man.cpp --- a/man/kio_man.cpp +++ b/man/kio_man.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -146,16 +146,17 @@ void MANProtocol::parseWhatIs( QMap &i, QTextStream &t, const QString &mark ) { - QRegExp re( mark ); + const QRegularExpression re(mark); QString l; while ( !t.atEnd() ) { l = t.readLine(); - int pos = re.indexIn( l ); + QRegularExpressionMatch match = re.match(l); + int pos = match.capturedStart(0); if (pos != -1) { QString names = l.left(pos); - QString descr = l.mid(pos + re.matchedLength()); + QString descr = l.mid(match.capturedEnd(0)); while ((pos = names.indexOf(",")) != -1) { i[names.left(pos++)] = descr; @@ -829,12 +830,17 @@ // Mappings from $PATH to manpath are given by lines starting with // "MANPATH_MAP" - QRegExp manpath_regex( "^MANPATH\\s" ); - QRegExp mandatory_regex( "^MANDATORY_MANPATH\\s" ); - QRegExp manpath_map_regex( "^MANPATH_MAP\\s" ); - QRegExp mandb_map_regex( "^MANDB_MAP\\s" ); + // The entry is e.g. "MANDATORY_MANPATH " + const QRegularExpression manpath_regex("^(?:MANPATH|MANDATORY_MANPATH)\\s+(\\S+)"); + + // The entry is "MANPATH_MAP " + const QRegularExpression manpath_map_regex("^MANPATH_MAP\\s+(\\S+)\\s+(\\S+)"); + + // The entry is "MANDB_MAP " + const QRegularExpression mandb_map_regex("^MANDB_MAP\\s+(\\S+)\\s+(\\S+)"); + //QRegExp section_regex( "^SECTION\\s" ); - QRegExp space_regex( "\\s+" ); // for parsing manpath map + const QRegularExpression space_regex("\\s+"); // for parsing manpath map QFile mc("/etc/man.conf"); // Caldera if (!mc.exists()) @@ -850,43 +856,18 @@ while (!is.atEnd()) { const QString line = is.readLine(); - if ( manpath_regex.indexIn(line) == 0 ) - { - const QString path = line.mid(8).trimmed(); - constr_path += path; - } - else if ( mandatory_regex.indexIn(line) == 0 ) - { - const QString path = line.mid(18).trimmed(); - constr_path += path; - } - else if ( manpath_map_regex.indexIn(line) == 0 ) - { - // The entry is "MANPATH_MAP " - const QStringList mapping = - line.split( space_regex); - if ( mapping.count() == 3 ) - { - const QString dir = QDir::cleanPath( mapping[1] ); - const QString mandir = QDir::cleanPath( mapping[2] ); - - manpath_map[ dir ] = mandir; - } - } - else if ( mandb_map_regex.indexIn(line) == 0 ) - { - // The entry is "MANDB_MAP " - const QStringList mapping = - line.split( space_regex); - - if ( mapping.count() == 3 ) - { - const QString mandir = QDir::cleanPath( mapping[1] ); - const QString catmandir = QDir::cleanPath( mapping[2] ); - - mandb_map[ mandir ] = catmandir; - } + QRegularExpressionMatch rmatch; + if (line.contains(manpath_regex, &rmatch)) { + constr_path += rmatch.captured(1); + } else if (line.contains(manpath_map_regex, &rmatch)) { + const QString dir = QDir::cleanPath(rmatch.captured(1)); + const QString mandir = QDir::cleanPath(rmatch.captured(2)); + manpath_map[dir] = mandir; + } else if (line.contains(mandb_map_regex, &rmatch)) { + const QString mandir = QDir::cleanPath(rmatch.captured(1)); + const QString catmandir = QDir::cleanPath(rmatch.captured(2)); + mandb_map[mandir] = catmandir; } /* sections are not used else if ( section_regex.find(line, 0) == 0 ) diff --git a/man/man2html.cpp b/man/man2html.cpp --- a/man/man2html.cpp +++ b/man/man2html.cpp @@ -130,6 +130,7 @@ #include #include #include +#include #ifdef SIMPLE_MAN2HTML # include @@ -6167,11 +6168,12 @@ // some pages contain "coding:" information. See "man manconv" // (but I find pages which do not exactly obey the format described in manconv, e.g. // the control char is either "." or "'") - // Therefore use a QRegExp - QRegExp regex("[\\.']\\\\\"[^$]*coding:\\s*(\\S*)\\s", Qt::CaseInsensitive); - if ( regex.indexIn(QLatin1String(input)) == 0 ) + // Therefore use a QRegularExpression + const QRegularExpression regex("[\\.']\\\\\"[^$]*coding:\\s*(\\S*)\\s", QRegularExpression::CaseInsensitiveOption); + QRegularExpressionMatch rmatch; + if (QString::fromLatin1(input).indexOf(regex, 0, &rmatch) == 0) { - encoding = regex.cap(1).toLatin1(); + encoding = rmatch.captured(1).toLatin1(); qCDebug(KIO_MAN_LOG) << "found embedded encoding" << encoding; }