Do not use sscanf.

This commit is contained in:
Cheng Zhao 2013-10-21 15:54:37 +08:00
parent 94e4044160
commit 5ce66fca5c

View file

@ -17,13 +17,6 @@ namespace accelerator_util {
namespace { namespace {
// The sscanf is deprecated in Windows.
#if defined(OS_WIN)
#define SSCANF sscanf_s
#else
#define SSCANF sscanf
#endif
// Return key code of the char. // Return key code of the char.
ui::KeyboardCode KeyboardCodeFromCharCode(char c, bool* shifted) { ui::KeyboardCode KeyboardCodeFromCharCode(char c, bool* shifted) {
*shifted = false; *shifted = false;
@ -175,7 +168,7 @@ bool StringToAccelerator(const std::string& description,
} else if (tokens[i].size() > 1 && tokens[i][0] == 'f') { } else if (tokens[i].size() > 1 && tokens[i][0] == 'f') {
// F1 - F24. // F1 - F24.
int n; int n;
if (SSCANF(tokens[i].c_str(), "f%d", &n) == 1 && n > 0 && n < 25) { if (base::StringToInt(tokens[i].c_str() + 1, &n)) {
key = static_cast<ui::KeyboardCode>(ui::VKEY_F1 + n - 1); key = static_cast<ui::KeyboardCode>(ui::VKEY_F1 + n - 1);
} else { } else {
LOG(WARNING) << tokens[i] << "is not available on keyboard"; LOG(WARNING) << tokens[i] << "is not available on keyboard";