Browse Source

More fixes to parsing queries.

tags/1.1.0
Vsevolod Stakhov 8 years ago
parent
commit
e4abacbe1d
1 changed files with 19 additions and 5 deletions
  1. 19
    5
      clang-plugin/printf_check.cc

+ 19
- 5
clang-plugin/printf_check.cc View File



auto res = std::make_shared<std::vector<PrintfArgChecker> > (); auto res = std::make_shared<std::vector<PrintfArgChecker> > ();


for (const auto c : query) {
for (auto citer = query.begin(); citer != query.end(); ++citer) {
auto c = *citer;

switch (state) { switch (state) {
case ignore_chars: case ignore_chars:
if (c == '%') { if (c == '%') {
/* %*s - need integer argument */ /* %*s - need integer argument */
res->emplace_back (int_arg_handler, this->pcontext, res->emplace_back (int_arg_handler, this->pcontext,
this->ci); this->ci);
state = read_arg;

if (*std::next (citer) == '.') {
++citer;
state = read_precision;
}
else {
state = read_arg;
}
} }
else if (c == '%') { else if (c == '%') {
/* Percent character, ignore */ /* Percent character, ignore */
state = ignore_chars; state = ignore_chars;
} }
else { else {
flags.push_back (c);
// Rewind iter
--citer;
state = read_arg; state = read_arg;
} }
break; break;
precision = c - '0'; precision = c - '0';
} }
else { else {
flags.push_back (c);
// Rewind iter
--citer;
state = read_arg; state = read_arg;
} }
break; break;
state = read_arg; state = read_arg;
} }
else { else {
flags.push_back (c);
// Rewind iter
--citer;
state = read_arg; state = read_arg;
} }
break; break;
else { else {
state = ignore_chars; state = ignore_chars;
} }
flags.clear ();
width = precision = 0;
} }
else { else {
flags.push_back (c); flags.push_back (c);

Loading…
Cancel
Save