]> khamidou — GitHub mirrors - electron.git/commitdiff
Do not use sscanf.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 21 Oct 2013 07:54:37 +0000 (15:54 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 21 Oct 2013 07:59:45 +0000 (15:59 +0800)
browser/ui/accelerator_util.cc

index e4cf70dd411d243817665e246795915066c0d7db..c1563ca123a05eaaecd195013f8edf3ab1fa7ed3 100644 (file)
@@ -17,13 +17,6 @@ namespace accelerator_util {
 
 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.
 ui::KeyboardCode KeyboardCodeFromCharCode(char c, bool* shifted) {
   *shifted = false;
@@ -175,7 +168,7 @@ bool StringToAccelerator(const std::string& description,
     } else if (tokens[i].size() > 1 && tokens[i][0] == 'f') {
       // F1 - F24.
       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);
       } else {
         LOG(WARNING) << tokens[i] << "is not available on keyboard";