diff --git a/CMakeLists.txt b/CMakeLists.txt index da5dd1daa..b41dded72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -442,22 +442,9 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # Clang/Intel specific compiler options # I disabled long-long warning because boost generates about 50 such warnings - set(WARNING_COMPILER_FLAGS "-Wall -pedantic -Wextra -Wno-long-long -Wno-unused-parameter -Wno-variadic-macros -Wno-zero-length-array") - - # Detect if this is Apple's clang - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v ERROR_VARIABLE CASS_CLANG_VERSION_INFO) - if (CASS_CLANG_VERSION_INFO MATCHES "^Apple LLVM") - set(CASS_IS_APPLE_CLANG 1) - else() - set(CASS_IS_APPLE_CLANG 0) - endif() - - if(NOT CASS_IS_APPLE_CLANG AND - (${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL "3.6" OR - ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER "3.6") - ) - set(WARNING_COMPILER_FLAGS "${WARNING_COMPILER_FLAGS} -Wno-unused-local-typedef ") - endif() + set(WARNING_COMPILER_FLAGS "-Wall -pedantic -Wextra -Wno-long-long -Wno-unused-parameter") + set(WARNING_COMPILER_FLAGS "${WARNING_COMPILER_FLAGS} -Wno-variadic-macros -Wno-zero-length-array") + set(WARNING_COMPILER_FLAGS "${WARNING_COMPILER_FLAGS} -Wno-unused-local-typedef -Wno-unknown-warning-option") # OpenSSL is deprecated on later versions of Mac OS X. The long-term solution # is to provide a CommonCryto implementation. diff --git a/packaging/homebrew/cassandra-cpp-driver.rb b/packaging/homebrew/cassandra-cpp-driver.rb index af12bfa7e..dd6d9ecae 100644 --- a/packaging/homebrew/cassandra-cpp-driver.rb +++ b/packaging/homebrew/cassandra-cpp-driver.rb @@ -2,18 +2,18 @@ class CassandraCppDriver < Formula homepage "http://datastax.github.io/cpp-driver/" - url "https://github.com/datastax/cpp-driver/archive/2.0.1.tar.gz" - sha1 "67a5b4e52ec421407c34ba7df109faeeaf4ef6dd" - version "2.0.1" + url "https://github.com/datastax/cpp-driver/archive/2.2.0-beta1.tar.gz" + sha1 "6159f1a5e31a044fb70567f849286572afa57174" + version "2.2.0-beta1" - head "git://github.com:datastax/cpp-driver.git", :branch => "2.0" + head "git://github.com:datastax/cpp-driver.git", :branch => "master" depends_on "cmake" => :build depends_on "libuv" def install mkdir 'build' do - system "cmake", "-DCMAKE_BUILD_TYPE=RELEASE", "-DCASS_BUILD_STATIC=ON", "-DCMAKE_INSTALL_PREFIX:PATH=#{prefix}", ".." + system "cmake", "-DCMAKE_BUILD_TYPE=RELEASE", "-DCASS_BUILD_STATIC=ON", "-DCMAKE_INSTALL_PREFIX:PATH=#{prefix}", "-DCMAKE_INSTALL_LIBDIR=#{lib}", ".." system "make", "install" end end diff --git a/src/uuids.cpp b/src/uuids.cpp index 6db10f71b..f316ed187 100644 --- a/src/uuids.cpp +++ b/src/uuids.cpp @@ -92,14 +92,15 @@ void cass_uuid_string(CassUuid uuid, char* output) { size_t pos = 0; char encoded[16]; cass::encode_uuid(encoded, uuid); + static const char half_byte_to_hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; for (size_t i = 0; i < 16; ++i) { - char buf[3] = { '\0' }; - sprintf(buf, "%02x", static_cast(encoded[i])); if (i == 4 || i == 6 || i == 8 || i == 10) { output[pos++] = '-'; } - output[pos++] = buf[0]; - output[pos++] = buf[1]; + uint8_t byte = static_cast(encoded[i]); + output[pos++] = half_byte_to_hex[(byte >> 4) & 0x0F]; + output[pos++] = half_byte_to_hex[byte & 0x0F]; } output[pos] = '\0'; } @@ -120,19 +121,37 @@ CassError cass_uuid_from_string_n(const char* str, const char* pos = str; char buf[16]; + static const char hex_to_half_byte[256] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + }; + if (str == NULL || str_length != 36) { return CASS_ERROR_LIB_BAD_PARAMS; } for (size_t i = 0; i < 16; ++i) { if (*pos == '-') pos++; - unsigned int byte; - intptr_t bytes_left = str - pos; - if (bytes_left >= 2 || !isxdigit(*pos) || !isxdigit(*(pos + 1))) { + uint8_t p0 = static_cast(pos[0]); + uint8_t p1 = static_cast(pos[1]); + if (hex_to_half_byte[p0] == -1 || hex_to_half_byte[p1] == -1) { return CASS_ERROR_LIB_BAD_PARAMS; } - sscanf(pos, "%2x", &byte); - buf[i] = static_cast(byte); + buf[i] = (hex_to_half_byte[p0] << 4) + hex_to_half_byte[p1]; pos += 2; }