Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build errors when targeting the Android API 14 or older #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <unordered_map>
#include <map>
#include <string>
#include <sstream>
#include <iostream>
#include <cassert>
#include <cstddef>
Expand Down Expand Up @@ -305,9 +306,10 @@ static PatternList parse_short(Tokens& tokens, std::vector<Option>& options)
}

if (similar.size() > 1) {
std::string error = shortOpt + " is specified ambiguously "
+ std::to_string(similar.size()) + " times";
throw Tokens::OptionError(std::move(error));
std::stringstream error;
error << shortOpt << " is specified ambiguously "
<< similar.size() << " times";
throw Tokens::OptionError(std::move(error.str()));
} else if (similar.empty()) {
options.emplace_back(shortOpt, "", 0);

Expand Down
7 changes: 4 additions & 3 deletions docopt_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <vector>
#include <functional> // std::hash
#include <iosfwd>
#include <cstdlib>

namespace docopt {

Expand Down Expand Up @@ -280,9 +281,9 @@ namespace docopt {
// Attempt to convert a string to a long
if (kind == Kind::String) {
const std::string& str = variant.strValue;
std::size_t pos;
const long ret = stol(str, &pos); // Throws if it can't convert
if (pos != str.length()) {
char* pos;
const long ret = std::strtol(str.c_str(), &pos, 10);
if (*pos != 0) {
// The string ended in non-digits.
throw std::runtime_error( str + " contains non-numeric characters.");
}
Expand Down