fmt::format fixed

This commit is contained in:
Nekotekina 2015-01-22 02:45:50 +03:00
parent ec3c899955
commit 07a2e0b55a
2 changed files with 17 additions and 77 deletions

View File

@ -96,9 +96,9 @@ size_t fmt::detail::get_fmt_len(const char* fmt, size_t len)
fmt += 2;
len -= 2;
if (fmt[1] == '1')
if (fmt[0] == '1')
{
assert(len >= 3 && fmt[2] - '0' < 7);
assert(len >= 3 && fmt[1] - '0' < 7);
res++;
fmt++;
len--;

View File

@ -435,24 +435,6 @@ namespace fmt
}
};
template<>
struct get_fmt<char*>
{
static std::string text(const char* fmt, size_t len, char* arg)
{
if (fmt[len - 1] == 's')
{
return arg;
}
else
{
throw "Invalid formatting (char*): " + std::string(fmt, len);
}
return{};
}
};
template<>
struct get_fmt<const char*>
{
@ -471,60 +453,6 @@ namespace fmt
}
};
//template<size_t size>
//struct get_fmt<char[size], false>
//{
// static std::string text(const char* fmt, size_t len, const char(&arg)[size])
// {
// if (fmt[len - 1] == 's')
// {
// return std::string(arg, size);
// }
// else
// {
// throw "Invalid formatting (char[size]): " + std::string(fmt, len);
// }
// return{};
// }
//};
//template<size_t size>
//struct get_fmt<const char[size], false>
//{
// static std::string text(const char* fmt, size_t len, const char(&arg)[size])
// {
// if (fmt[len - 1] == 's')
// {
// return std::string(arg, size);
// }
// else
// {
// throw "Invalid formatting (const char[size]): " + std::string(fmt, len);
// }
// return{};
// }
//};
template<>
struct get_fmt<std::string>
{
static std::string text(const char* fmt, size_t len, const std::string& arg)
{
if (fmt[len - 1] == 's')
{
return arg;
}
else
{
throw "Invalid formatting (std::string): " + std::string(fmt, len);
}
return{};
}
};
std::string format(const char* fmt, size_t len); // terminator
template<typename T, typename... Args>
@ -549,6 +477,17 @@ namespace fmt
}
};
template<>
struct unveil<char*, false>
{
typedef const char* result_type;
__forceinline static result_type get_value(const char* arg)
{
return arg;
}
};
template<size_t N>
struct unveil<const char[N], false>
{
@ -563,11 +502,11 @@ namespace fmt
template<>
struct unveil<std::string, false>
{
typedef const std::string& result_type;
typedef const char* result_type;
__forceinline static result_type get_value(const std::string& arg)
{
return arg;
return arg.c_str();
}
};
@ -613,8 +552,9 @@ namespace fmt
float (%x, %f)
double (%x, %f)
bool (%x, %d, %s)
char*, const char*, std::string (%s)
char* (%s)
std::string forced to .c_str() (fmt::unveil)
be_t<> of any appropriate type in this list (fmt::unveil)
enum of any appropriate type in this list (fmt::unveil)