Skip to content

Commit

Permalink
better getline() detection on macosx
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfryed committed May 13, 2012
1 parent 43d9c06 commit a3f5c13
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
=== 0.6.2 (2012-05-14)
* better getline() detection using cmake CHECK_FUNCTION_EXISTS() on macosx.

=== 0.6.1 (2012-04-19)
* reset PGresult to NULL before raising exception.
* remove openmp directive in build.
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ FIND_PACKAGE(sqlite3)

INCLUDE_DIRECTORIES(inc ${UUID_INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS})

INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
CHECK_FUNCTION_EXISTS(getline HAS_GETLINE)

IF (HAS_GETLINE)
ADD_DEFINITIONS(-DHAS_GETLINE)
ENDIF()

IF (APPLE)
FILE(GLOB SOURCES "src/*.cc" "src/bsd/getline.cc")
ELSE ()
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ local_build() {
-DCMAKE_MYSQL_VERSION=$MYSQL_VERSION \
-DCMAKE_SQLITE3_VERSION=$SQLITE3_VERSION \
-DCMAKE_INSTALL_PREFIX:PATH=tmp/
make
make -j4
make install
rm -rf lib/*
mv tmp/lib/* lib/
Expand Down
6 changes: 1 addition & 5 deletions inc/dbic++.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <uuid/uuid.h>
#include <stdint.h>

#define DBI_VERSION 0.6.1
#define DBI_VERSION 0.6.2

namespace dbi {
struct null {};
Expand Down Expand Up @@ -76,8 +76,4 @@ namespace dbi {
#include "dbic++/query.h"
#include "dbic++/etc.h"

#ifndef __linux
extern size_t getline(char **, size_t *, FILE *);
#endif

#endif
13 changes: 0 additions & 13 deletions src/bsd/getline.cc

This file was deleted.

12 changes: 12 additions & 0 deletions src/file_io.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#include "dbic++.h"

#ifndef HAS_GETLINE
size_t getline(char **lineptr, size_t *size, FILE *fp) {
if (!*lineptr) *lineptr = (char*)malloc(*size + 1);
if (!*lineptr) return -1;

if (fgets(*lineptr, *size, fp) != NULL)
return strlen(*lineptr);
else
return -1;
}
#endif

namespace dbi {
FileIO::FileIO(const char *path, char* mode) {
if (!(fp = fopen(path, mode)))
Expand Down

0 comments on commit a3f5c13

Please sign in to comment.