We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4840f38 commit 2831ca6Copy full SHA for 2831ca6
1 file changed
docopt_value.h
@@ -13,7 +13,6 @@
13
#include <vector>
14
#include <functional> // std::hash
15
#include <iosfwd>
16
-#include <cstdio> // sscanf
17
18
namespace docopt {
19
@@ -261,12 +260,9 @@ namespace docopt {
261
260
// Attempt to convert a string to a long
262
if (kind == Kind::String) {
263
// Doesn't guard against trailing characters,
264
- // but doing so (if desired) would be trivial.
265
- long ret;
266
- if (sscanf(variant.strValue.c_str(), "%ld", &ret) == 1) {
267
- return ret;
268
- }
269
- // else fall through
+ // but doing so (if desired) would be trivial by checking pos.
+ std::size_t pos;
+ return stol(variant.strValue, &pos); // Throws if it can't convert
270
}
271
throwIfNotKind(Kind::Long);
272
return variant.longValue;
0 commit comments