Merge pull request #1168 from geoffw0/format-amp

CPP: %@ in format strings
This commit is contained in:
Jonas Jensen
2019-03-27 09:08:39 +01:00
committed by GitHub
2 changed files with 5 additions and 3 deletions

View File

@@ -256,11 +256,11 @@ class FormatLiteral extends Literal {
}
/**
* Gets the format string, with '%%' replaced by '_' (to avoid processing
* '%%' as a format specifier).
* Gets the format string, with '%%' and '%@' replaced by '_' (to avoid processing
* them as format specifiers).
*/
string getFormat() {
result = this.getValue().replaceAll("%%", "_")
result = this.getValue().replaceAll("%%", "_").replaceAll("%@", "_")
}
/**

View File

@@ -40,4 +40,6 @@ void test(int i, const char *str)
printf("%2$.*4$f", 0, num, 0, precision); // GOOD [FALSE POSITIVE]
printf("%2$.*4$f", num, 0, precision); // BAD (too few format arguments) [INCORRECT MESSAGE]
}
printf("%@ %i %i", 1, 2); // GOOD
}