mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-28 06:08:05 +03:00
do not use std::{to_string,stoi} as they cause problems with cygwin
This commit is contained in:
parent
a642026e7c
commit
6d125e6c36
@ -20,7 +20,8 @@ Color str_to_color(const String& color)
|
||||
static const Regex rgb_regex{"rgb:[0-9a-fA-F]{6}"};
|
||||
if (boost::regex_match(color, rgb_regex))
|
||||
{
|
||||
long l = stol(color.substr(ByteCount{4}), NULL, 16);
|
||||
unsigned l;
|
||||
sscanf(color.c_str() + 4, "%x", &l);
|
||||
return { (unsigned char)((l >> 16) & 0xFF),
|
||||
(unsigned char)((l >> 8) & 0xFF),
|
||||
(unsigned char)(l & 0xFF) };
|
||||
|
@ -79,7 +79,7 @@ bool is_horizontal_blank(char c)
|
||||
|
||||
struct unterminated_string : parse_error
|
||||
{
|
||||
unterminated_string(const std::string& open, const std::string& close, int nest = 0)
|
||||
unterminated_string(const String& open, const String& close, int nest = 0)
|
||||
: parse_error{"unterminated string '" + open + "..." + close + "'" +
|
||||
(nest > 0 ? "(nesting: " + to_string(nest) + ")" : "")}
|
||||
{}
|
||||
|
@ -25,14 +25,17 @@ std::vector<String> split(const String& str, char separator)
|
||||
|
||||
int str_to_int(const String& str)
|
||||
{
|
||||
try
|
||||
{
|
||||
return stoi(str);
|
||||
}
|
||||
catch (std::logic_error&)
|
||||
{
|
||||
int res = 0;
|
||||
if (sscanf(str.c_str(), "%i", &res) != 1)
|
||||
throw runtime_error(str + "is not a number");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
String to_string(int val)
|
||||
{
|
||||
char buf[16];
|
||||
sprintf(buf, "%i", val);
|
||||
return buf;
|
||||
}
|
||||
|
||||
String option_to_string(const Regex& re)
|
||||
|
@ -103,10 +103,10 @@ void option_from_string(const String& str, Regex& re);
|
||||
|
||||
int str_to_int(const String& str);
|
||||
|
||||
using std::to_string;
|
||||
String to_string(int val);
|
||||
|
||||
template<typename RealType, typename ValueType>
|
||||
std::string to_string(const StronglyTypedNumber<RealType, ValueType>& val)
|
||||
String to_string(const StronglyTypedNumber<RealType, ValueType>& val)
|
||||
{
|
||||
return to_string((ValueType)val);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user