Skip to content

Commit 909df20

Browse files
committed
handle quoted arguments with spaces
1 parent c2b5ac9 commit 909df20

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

.github/workflows/selfcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
122122
- name: Self check (unusedFunction / no test / no gui)
123123
run: |
124-
supprs="--suppress=unusedFunction:lib/errorlogger.h:193 --suppress=unusedFunction:lib/importproject.cpp:1518 --suppress=unusedFunction:lib/importproject.cpp:1542"
124+
supprs="--suppress=unusedFunction:lib/errorlogger.h:193 --suppress=unusedFunction:lib/importproject.cpp:1516 --suppress=unusedFunction:lib/importproject.cpp:1540"
125125
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib -D__CPPCHECK__ -D__GNUC__ --enable=unusedFunction,information --exception-handling -rp=. --project=cmake.output.notest_nogui/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr $supprs
126126
env:
127127
DISABLE_VALUEFLOW: 1

lib/importproject.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,10 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings
210210
return ImportProject::Type::FAILURE;
211211
}
212212

213-
static std::string readUntil(const std::string &command, std::string::size_type *pos, const char until[])
213+
static std::string readUntil(const std::string &command, std::string::size_type *pos, const char until[], bool str = false)
214214
{
215215
std::string ret;
216216
bool escapedString = false;
217-
bool str = false;
218217
bool escape = false;
219218
for (; *pos < command.size() && (str || !std::strchr(until, command[*pos])); (*pos)++) {
220219
if (escape)
@@ -280,13 +279,12 @@ void ImportProject::fsParseCommand(FileSettings& fs, const std::string& command,
280279
break;
281280
const char F = command[pos++];
282281
if (std::strchr("DUI", F)) {
283-
while (pos < command.size() && command[pos] == ' ') {
282+
while (pos < command.size() && command[pos] == ' ')
284283
++pos;
285-
wholeArgQuoted = false;
286-
}
287284
}
288-
const char *readUntilChars = wholeArgQuoted ? " =\"" : " =";
289-
std::string fval = readUntil(command, &pos, readUntilChars);
285+
std::string fval = readUntil(command, &pos, " =", wholeArgQuoted);
286+
if (wholeArgQuoted && fval.back() == '\"')
287+
fval = fval.substr(0, fval.size() - 1);
290288
if (F=='D') {
291289
std::string defval = readUntil(command, &pos, " ");
292290
defs += fval;

0 commit comments

Comments
 (0)