Git commit dc3487fb24aeee7c0bce788b705b99d048e45f02 by Michael Reeves. Committed on 14/07/2018 at 02:40. Pushed by mreeves into branch 'master'.
Handle unquote args and fix handling white space in command path M +3 -5 doc/en/index.docbook M +4 -3 src/pdiff.cpp https://commits.kde.org/kdiff3/dc3487fb24aeee7c0bce788b705b99d048e45f02 diff --git a/doc/en/index.docbook b/doc/en/index.docbook index 5770710..2519f7e 100644 --- a/doc/en/index.docbook +++ b/doc/en/index.docbook @@ -1172,11 +1172,9 @@ an effect. An appropriate Line-Matching-Preprocessor-Command would be: </screen> Since for <command>sed</command> the "/"-character has a special meaning, it is necessary to place the "\"-character before each "/" in the replacement-string. Sometimes the "\" is required -to add or remove a special meaning of certain characters. The single quotation marks (') before -and after the substitution-command are important now, because otherwise the shell will -try to interpret some special characters like '#', '$' or '\' before passing them to -<command>sed</command>. <emphasis>Note that on Windows you will need the double quotation marks (") here. Windows -substitutes other characters like '%', so you might have to experiment a little bit.</emphasis> +to add or remove a special meaning of certain characters. The single quotation marks (') are only important +when testing on the command shell as it will otherwise attempt to process some characters. +KDiff3 does not do this except for the escape sequences '\"' and '\\'. </para> </sect3> <sect3><title>Caseinsensitive Diff</title> diff --git a/src/pdiff.cpp b/src/pdiff.cpp index fcf3ffa..bb91ec2 100644 --- a/src/pdiff.cpp +++ b/src/pdiff.cpp @@ -2292,7 +2292,7 @@ void KDiff3App::slotNoRelevantChangesDetected() Silently convert quotes to what QProcess understands. Also convert '\"' to '"""' */ //arg and arg1 can never both match but qt's pcre2 engine insists on unique naming anyway - const QRegularExpression argRe("(?<!\\\\)\"(?<arg>(?:[^\"]|(?<=\\\\)\")*)(?<!\\\\)\"|'(?<arg1>[^']*)'"); + const QRegularExpression argRe("(?<!\\\\)\"(?<arg>(?:[^\"]|(?<=\\\\)\")*)(?<!\\\\)\"|'(?<arg1>[^']*)'|(?<!\\\\)\\s*(?<arg2>[\\S]+)"); QRegularExpressionMatchIterator i = argRe.globalMatch(cmd); QRegularExpressionMatch match; QStringList args; @@ -2301,7 +2301,7 @@ void KDiff3App::slotNoRelevantChangesDetected() { match = i.next(); args += match.captured("arg").replace("\\\"", "\"\"\"").replace("\\\\", "\\") - + match.captured("arg1"); + + match.captured("arg1") + match.captured("arg2"); } args += m_sd1.getAliasName(); args += m_sd2.getAliasName(); @@ -2310,7 +2310,8 @@ void KDiff3App::slotNoRelevantChangesDetected() cmd = cmd.left( cmd.indexOf( QRegularExpression("(?<!\\\\)[\\s]*") ) ).trimmed(); - + cmd.replace(QRegularExpression("(?<!\\\\)([\\s])"), "\1"); + QProcess process; process.start(cmd); process.waitForFinished(-1);
