17 Feb
2012
17 Feb
'12
3:48 p.m.
On 17/02/2012 15:35, Tom Hawtin wrote:
Although it's in some sense safe in this case, you might get a grumble about introducing a new sprintf.
+static char* getConsoleEncoding() +{ + char* buf = malloc(16); + int cp = GetConsoleCP(); + if (cp >= 874 && cp <= 950) + sprintf(buf, "ms%d", cp); + else + sprintf(buf, "cp%d", cp); + return buf; +}
Tom
You're right, we should avoid sprintf. It's not an issue here but will be flagged by tools that do static analysis on the source. -Alan.