Obey line length limit.

This commit is contained in:
Victor Zverovich 2014-07-26 09:45:03 -07:00
parent f634ccb344
commit 2a1c0c9969
2 changed files with 28 additions and 25 deletions

View File

@ -421,7 +421,8 @@ class fmt::internal::ArgFormatter :
const Char *format_;
public:
ArgFormatter(fmt::BasicFormatter<Char> &f, fmt::FormatSpec &s, const Char *fmt)
ArgFormatter(
fmt::BasicFormatter<Char> &f,fmt::FormatSpec &s, const Char *fmt)
: formatter_(f), writer_(f.writer()), spec_(s), format_(fmt) {}
template <typename T>
@ -651,20 +652,20 @@ void fmt::BasicWriter<Char>::write_double(T value, const FormatSpec &spec) {
}
template <typename Char>
template <typename StringChar>
template <typename StrChar>
void fmt::BasicWriter<Char>::write_str(
const Arg::StringValue<StringChar> &str, const FormatSpec &spec) {
// Check if StringChar is convertible to Char.
internal::CharTraits<Char>::convert(StringChar());
const Arg::StringValue<StrChar> &str, const FormatSpec &spec) {
// Check if StrChar is convertible to Char.
internal::CharTraits<Char>::convert(StrChar());
if (spec.type_ && spec.type_ != 's')
internal::report_unknown_type(spec.type_, "string");
const StringChar *s = str.value;
const StrChar *s = str.value;
std::size_t size = str.size;
if (size == 0) {
if (!s)
throw FormatError("string pointer is null");
if (*s)
size = std::char_traits<StringChar>::length(s);
size = std::char_traits<StrChar>::length(s);
}
write_str(s, size, spec);
}
@ -699,12 +700,12 @@ void fmt::BasicFormatter<Char>::CheckSign(
const Char *&s, const Arg &arg) {
char sign = static_cast<char>(*s);
if (arg.type > Arg::LAST_NUMERIC_TYPE) {
report_error_(s,
fmt::format("format specifier '{}' requires numeric argument", sign).c_str());
report_error_(s, fmt::format(
"format specifier '{}' requires numeric argument", sign).c_str());
}
if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
report_error_(s,
fmt::format("format specifier '{}' requires signed argument", sign).c_str());
report_error_(s, fmt::format(
"format specifier '{}' requires signed argument", sign).c_str());
}
++s;
}

View File

@ -1337,13 +1337,13 @@ class BasicWriter {
void write_double(T value, const FormatSpec &spec);
// Writes a formatted string.
template <typename StringChar>
template <typename StrChar>
CharPtr write_str(
const StringChar *s, std::size_t size, const AlignSpec &spec);
const StrChar *s, std::size_t size, const AlignSpec &spec);
template <typename StringChar>
template <typename StrChar>
void write_str(
const internal::Arg::StringValue<StringChar> &str, const FormatSpec &spec);
const internal::Arg::StringValue<StrChar> &str, const FormatSpec &spec);
// This method is private to disallow writing a wide string to a
// char stream and vice versa. If you want to print a wide string
@ -1502,9 +1502,9 @@ class BasicWriter {
return *this;
}
template <typename StringChar>
BasicWriter &operator<<(const StrFormatSpec<StringChar> &spec) {
const StringChar *s = spec.str();
template <typename StrChar>
BasicWriter &operator<<(const StrFormatSpec<StrChar> &spec) {
const StrChar *s = spec.str();
// TODO: error if fill is not convertible to Char
write_str(s, std::char_traits<Char>::length(s), spec);
return *this;
@ -1514,9 +1514,9 @@ class BasicWriter {
};
template <typename Char>
template <typename StringChar>
template <typename StrChar>
typename BasicWriter<Char>::CharPtr BasicWriter<Char>::write_str(
const StringChar *s, std::size_t size, const AlignSpec &spec) {
const StrChar *s, std::size_t size, const AlignSpec &spec) {
CharPtr out = CharPtr();
if (spec.width() > size) {
out = GrowBuffer(spec.width());
@ -1560,7 +1560,8 @@ typename fmt::BasicWriter<Char>::CharPtr
CharPtr p = GrowBuffer(fill_size);
std::fill(p, p + fill_size, fill);
}
CharPtr result = PrepareBufferForInt(num_digits, subspec, prefix, prefix_size);
CharPtr result = PrepareBufferForInt(
num_digits, subspec, prefix, prefix_size);
if (align == ALIGN_LEFT) {
CharPtr p = GrowBuffer(fill_size);
std::fill(p, p + fill_size, fill);
@ -1651,7 +1652,8 @@ void BasicWriter<Char>::write_int(T value, const Spec &spec) {
do {
++num_digits;
} while ((n >>= 1) != 0);
Char *p = GetBase(PrepareBufferForInt(num_digits, spec, prefix, prefix_size));
Char *p = GetBase(PrepareBufferForInt(
num_digits, spec, prefix, prefix_size));
n = abs_value;
do {
*p-- = '0' + (n & 1);
@ -1917,9 +1919,9 @@ inline void FormatDec(char *&buffer, T value) {
#if FMT_GCC_VERSION
// Use the system_header pragma to suppress warnings about variadic macros
// because suppressing -Wvariadic-macros with the diagnostic pragma doesn't work.
// It is used at the end because we want to suppress as little warnings as
// possible.
// because suppressing -Wvariadic-macros with the diagnostic pragma doesn't
// work. It is used at the end because we want to suppress as little warnings
// as possible.
# pragma GCC system_header
#endif