File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change 13
13
#include < vector>
14
14
#include < functional> // std::hash
15
15
#include < iosfwd>
16
- #include < cstdio> // sscanf
17
16
18
1
8000
7
namespace docopt {
19
18
@@ -261,12 +260,9 @@ namespace docopt {
261
260
// Attempt to convert a string to a long
262
261
if (kind == Kind::String) {
263
262
// 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
263
+ // but doing so (if desired) would be trivial by checking pos.
264
+ std::size_t pos;
265
+ return stol (variant.strValue , &pos); // Throws if it can't convert
270
266
}
271
267
throwIfNotKind (Kind::Long);
272
268
return variant.longValue ;
You can’t perform that action at this time.
0 commit comments