Cppcheck: Quote file paths

This patch fixes the most common issues with path quoting.

Fixes: QTCREATORBUG-28586
Change-Id: Ia5f400d062a2459f49288fcd4bc316ced2b269e6
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Christian Stenger
2024-05-28 09:30:10 +02:00
parent 67f18a1a56
commit 26cfa86969

View File

@@ -113,16 +113,17 @@ void CppcheckRunner::checkQueued()
if (m_queue.isEmpty() || !m_binary.isExecutableFile()) if (m_queue.isEmpty() || !m_binary.isExecutableFile())
return; return;
CommandLine commandLine{m_binary, m_arguments, CommandLine::Raw};
FilePaths files = m_queue.begin().value(); FilePaths files = m_queue.begin().value();
QString arguments = m_arguments + ' ' + m_queue.begin().key(); commandLine.addArg(m_queue.begin().key());
m_currentFiles.clear(); m_currentFiles.clear();
int argumentsLength = arguments.length(); int argumentsLength = commandLine.arguments().length();
while (!files.isEmpty()) { while (!files.isEmpty()) {
argumentsLength += files.first().toString().size() + 1; // +1 for separator argumentsLength += files.first().toString().size() + 3; // +1 for separator +2 for quotes
if (argumentsLength >= m_maxArgumentsLength) if (argumentsLength >= m_maxArgumentsLength)
break; break;
m_currentFiles.push_back(files.first()); m_currentFiles.push_back(files.first());
arguments += ' ' + files.first().toString(); commandLine.addArg(files.first().toString());
files.pop_front(); files.pop_front();
} }
@@ -131,7 +132,7 @@ void CppcheckRunner::checkQueued()
else else
m_queue.begin().value() = files; m_queue.begin().value() = files;
m_process.setCommand({m_binary, arguments, CommandLine::Raw}); m_process.setCommand(commandLine);
m_process.start(); m_process.start();
} }