Merge the master branch

This commit is contained in:
vitaut
2015-08-04 20:59:24 -07:00
parent 64eb3d8bb2
commit f6135df529
3 changed files with 22 additions and 19 deletions

View File

@ -95,9 +95,9 @@ if (BUILD_SHARED_LIBS)
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6. # unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
target_link_libraries(cppformat -Wl,--as-needed) target_link_libraries(cppformat -Wl,--as-needed)
endif () endif ()
if (FMT_PEDANTIC AND CMAKE_COMPILER_IS_GNUCXX) if (FMT_PEDANTIC AND
set_target_properties(cppformat PROPERTIES COMPILE_FLAGS (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
"-Wall -Wextra -Wshadow -pedantic") set(FMT_EXTRA_COMPILE_FLAGS "-Wall -Wextra -Wshadow -pedantic")
endif () endif ()
# If FMT_PEDANTIC is TRUE, then test compilation with both -std=c++11 # If FMT_PEDANTIC is TRUE, then test compilation with both -std=c++11
@ -105,12 +105,15 @@ endif ()
# The library is distributed in the source form and users have full control # The library is distributed in the source form and users have full control
# over compile options, so the options used here only matter for testing. # over compile options, so the options used here only matter for testing.
if (CPP11_FLAG AND FMT_PEDANTIC) if (CPP11_FLAG AND FMT_PEDANTIC)
set_target_properties(cppformat PROPERTIES COMPILE_FLAGS ${CPP11_FLAG}) set(FMT_EXTRA_COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS} ${CPP11_FLAG}")
# Test compilation with default flags. # Test compilation with default flags.
file(GLOB src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/*.cc test/*.h) file(GLOB src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/*.cc test/*.h)
add_library(testformat STATIC ${FMT_SOURCE_FILES} ${src}) add_library(testformat STATIC ${FMT_SOURCE_FILES} ${src})
endif () endif ()
set_target_properties(cppformat
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
add_subdirectory(doc) add_subdirectory(doc)
include_directories(. gmock) include_directories(. gmock)

View File

@ -205,8 +205,8 @@ int safe_strerror(
} }
public: public:
StrError(int error_code, char *&buffer, std::size_t buffer_size) StrError(int err_code, char *&buf, std::size_t buf_size)
: error_code_(error_code), buffer_(buffer), buffer_size_(buffer_size) {} : error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {}
int run() { int run() {
strerror_r(0, 0, ""); // Suppress a warning about unused strerror_r. strerror_r(0, 0, ""); // Suppress a warning about unused strerror_r.
@ -503,23 +503,23 @@ class PrintfArgFormatter :
: BasicArgFormatter<PrintfArgFormatter<Char>, Char>(w, s) {} : BasicArgFormatter<PrintfArgFormatter<Char>, Char>(w, s) {}
void visit_char(int value) { void visit_char(int value) {
const FormatSpec &spec = this->spec(); const FormatSpec &fmt_spec = this->spec();
BasicWriter<Char> &writer = this->writer(); BasicWriter<Char> &w = this->writer();
if (spec.type_ && spec.type_ != 'c') if (fmt_spec.type_ && fmt_spec.type_ != 'c')
writer.write_int(value, spec); w.write_int(value, fmt_spec);
typedef typename BasicWriter<Char>::CharPtr CharPtr; typedef typename BasicWriter<Char>::CharPtr CharPtr;
CharPtr out = CharPtr(); CharPtr out = CharPtr();
if (spec.width_ > 1) { if (fmt_spec.width_ > 1) {
Char fill = ' '; Char fill = ' ';
out = writer.grow_buffer(spec.width_); out = w.grow_buffer(fmt_spec.width_);
if (spec.align_ != ALIGN_LEFT) { if (fmt_spec.align_ != ALIGN_LEFT) {
std::fill_n(out, spec.width_ - 1, fill); std::fill_n(out, fmt_spec.width_ - 1, fill);
out += spec.width_ - 1; out += fmt_spec.width_ - 1;
} else { } else {
std::fill_n(out + 1, spec.width_ - 1, fill); std::fill_n(out + 1, fmt_spec.width_ - 1, fill);
} }
} else { } else {
out = writer.grow_buffer(1); out = w.grow_buffer(1);
} }
*out = static_cast<Char>(value); *out = static_cast<Char>(value);
} }

View File

@ -1046,8 +1046,8 @@ struct NamedArg : Arg {
BasicStringRef<Char> name; BasicStringRef<Char> name;
template <typename T> template <typename T>
NamedArg(BasicStringRef<Char> name, const T &value) NamedArg(BasicStringRef<Char> argname, const T &value)
: name(name), Arg(MakeValue<Char>(value)) { : name(argname), Arg(MakeValue<Char>(value)) {
type = static_cast<internal::Arg::Type>(MakeValue<Char>::type(value)); type = static_cast<internal::Arg::Type>(MakeValue<Char>::type(value));
} }
}; };