Git commit 311bf4ea4b5b4ee4b3c3b7fd46553cf60b3a45aa by Michael Reeves. Committed on 09/07/2018 at 03:13. Pushed by mreeves into branch 'master'.
Fix behavior of preprocessor for sigle quotes The distinction between single and double quotes is purly a command shell issue. So silently convert to double quotes. Also change escaping to QTs non-standard form for double quotes if contained in single quotes. BUG: 209885 FIXED-IN: 1.7 M +0 -2 doc/en/index.docbook M +23 -2 src/pdiff.cpp https://commits.kde.org/kdiff3/311bf4ea4b5b4ee4b3c3b7fd46553cf60b3a45aa diff --git a/doc/en/index.docbook b/doc/en/index.docbook index 0437893..5770710 100644 --- a/doc/en/index.docbook +++ b/doc/en/index.docbook @@ -1130,8 +1130,6 @@ Note that the following examples assume that the <command>sed</command>-command directory in the PATH-environment variable. If this is not the case, you have to specify the full absolute path for the command. </para> -<note><para>Also note that the following examples use the single quotation mark (') which won't work for Windows. -On Windows you should use the double quotation marks (") instead.</para></note> <para> In this context only the <command>sed</command>-substitute-command is used: <screen> diff --git a/src/pdiff.cpp b/src/pdiff.cpp index 060a246..a19be99 100644 --- a/src/pdiff.cpp +++ b/src/pdiff.cpp @@ -2287,11 +2287,32 @@ void KDiff3App::slotNoRelevantChangesDetected() //KMessageBox::information( this, "No relevant changes detected", "KDiff3" ); if(!m_pOptions->m_IrrelevantMergeCmd.isEmpty()) { - QString cmd = m_pOptions->m_IrrelevantMergeCmd + " \"" + m_sd1.getAliasName() + "\" \"" + m_sd2.getAliasName() + "\" \"" + m_sd3.getAliasName(); + QString cmd = m_pOptions->m_IrrelevantMergeCmd; + /* + QProcess doesn't check for single quotes and uses non-standard escaping syntax for double quotes. + The distinction between single and double quotes is purly a command shell issue. So + 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>[^']*)'"); + QRegularExpressionMatchIterator i = argRe.globalMatch(cmd); + QRegularExpressionMatch match; + QStringList args; + + while(i.hasNext()) + { + match = i.next(); + args += match.captured("arg").replace("\\\"", "\"\"\"").replace("\\\\", "\\") + + match.captured("arg1"); + } + args += m_sd1.getAliasName(); + args += m_sd2.getAliasName(); + args += m_sd3.getAliasName(); + cmd = cmd.left(cmd.indexOf('"')).trimmed(); + QProcess process; process.start(cmd); process.waitForFinished(-1); - //::system( cmd.local8Bit() ); } } }
