Skip to content

Commit

Permalink
Fixing compilation errors with mysql-connector-c
Browse files Browse the repository at this point in the history
  • Loading branch information
Roslaniec committed Feb 11, 2019
1 parent 411c0fa commit fa79130
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ PROJECT(mariacpp)

SET(CPACK_PACKAGE_VERSION_MAJOR 1)
SET(CPACK_PACKAGE_VERSION_MINOR 0)
SET(CPACK_PACKAGE_VERSION_PATCH 0)
SET(CPACK_PACKAGE_VERSION_PATCH 1)
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")


Expand Down
11 changes: 6 additions & 5 deletions src/ma_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@
#include <string.h>

#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#ifndef SEC_PART_DIGITS
#define SEC_PART_DIGITS 6
#endif

size_t mariadb_time_to_string(const MYSQL_TIME *tm, char *time_str, size_t len,
unsigned int digits)
size_t mariacpp_time_to_string(const MYSQL_TIME *tm, char *time_str, size_t len)
{
size_t length;

if (!time_str || !len)
return 0;

if (digits == AUTO_SEC_PART_DIGITS)
digits= MIN((tm->second_part) ? SEC_PART_DIGITS : 0, 15);
unsigned int digits= MIN((tm->second_part) ? SEC_PART_DIGITS : 0, 15);

switch(tm->time_type) {
case MYSQL_TIMESTAMP_DATE:
Expand Down Expand Up @@ -64,7 +65,7 @@ size_t mariadb_time_to_string(const MYSQL_TIME *tm, char *time_str, size_t len,
}

// Copied from my_stmt_codec.c
my_bool mariadb_str_to_TIME(const char *str, size_t length, MYSQL_TIME *tm)
my_bool mariacpp_str_to_TIME(const char *str, size_t length, MYSQL_TIME *tm)
{
my_bool is_time=0, is_date=0, has_time_frac=0;
char *p= (char *)str;
Expand Down
10 changes: 4 additions & 6 deletions src/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
#include <ostream>

extern "C" {
size_t mariadb_time_to_string(const MYSQL_TIME *tm, char *time_str, size_t len,
unsigned int digits);
my_bool mariadb_str_to_TIME(const char *str, size_t length, MYSQL_TIME *tm);
size_t mariacpp_time_to_string(const MYSQL_TIME *tm, char *time_str,size_t len);
my_bool mariacpp_str_to_TIME(const char *str, size_t length, MYSQL_TIME *tm);
}

namespace MariaCpp {
Expand All @@ -31,7 +30,7 @@ namespace MariaCpp {
Time::Time(const std::string &str)
: MYSQL_TIME()
{
if (mariadb_str_to_TIME(str.data(), str.length(), this))
if (mariacpp_str_to_TIME(str.data(), str.length(), this))
time_type = MYSQL_TIMESTAMP_ERROR;
}

Expand Down Expand Up @@ -88,8 +87,7 @@ void
Time::print(std::ostream &os) const
{
char buff[40];
size_t len = mariadb_time_to_string(this, buff, sizeof(buff)-1,
AUTO_SEC_PART_DIGITS);
size_t len = mariacpp_time_to_string(this, buff, sizeof(buff)-1);
buff[len] = '\0';
os << buff;
}
Expand Down

0 comments on commit fa79130

Please sign in to comment.