diff --git a/Makefile.am b/Makefile.am index 0134d2d..a0dbee1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,7 @@ AM_CPPFLAGSINVALID = -DPC_REMOVE_INVALID endif if BUILD_WITH_BTREE -AM_CPPFLAGSBTREE = -DBUILD_WITH_BTREE +AM_CPPFLAGSBTREE = -DBUILD_WITH_BTREE -std=c++11 endif AM_CPPFLAGS = $(AM_CPPFLAGSBTREE) $(AM_CPPFLAGSINVALID) diff --git a/configure.ac b/configure.ac index 715cebf..07474a1 100644 --- a/configure.ac +++ b/configure.ac @@ -91,26 +91,33 @@ if test "x$enable_btree" == "xyes"; then AC_CHECK_TOOL([MERCURIAL], [hg], [no]) - AM_CONDITIONAL([HAVE_HG_BIN], [test "x${MERCURIAL}" = "xhg"]) + + if test "x${MERCURIAL}" = "xhg"; then + have_hg_bin=1 + fi + + AC_MSG_CHECKING([for ${srcdir}/cpp-btree/btree_map.h]) - AC_MSG_CHECKING([for ${srcdir}/cpp-btree/btree.h]) + if test -f ${srcdir}/cpp-btree/btree_map.h; then + have_btree_h=1 + AC_MSG_RESULT([found.]) + else + AC_MSG_RESULT([no]) + fi - AM_CONDITIONAL([HAVE_BTREE_H], [test -f ${srcdir}/cpp-btree/btree.h]) - - AM_COND_IF([HAVE_BTREE_H], - [AC_MSG_RESULT([found]) - have_btree_h=1], - [AC_MSG_RESULT([no])]) - - if test x$have_btree_h = x1 && ! test ${HAVE_HG_BIN}; then + if test "x$have_btree_h" = "x1"; then AC_VERBOSE([Using already existing btree.]) AM_CONDITIONAL([BUILD_WITH_BTREE], [true]) - elif ${HAVE_HG_BIN} && test x$have_btree_h != x1; then - AC_VERBOSE([Downloading btree headers with mercurial]) + elif test "x$have_hg_bin" = "x1"; then + AC_VERBOSE([ + * Downloading btree headers with mercurial + ]) + $(which hg) clone https://code.google.com/p/cpp-btree/ + AM_CONDITIONAL([BUILD_WITH_BTREE], [true]) else AC_VERBOSE([ - * Could not find hg in $PATH + * Could not find hg in your PATH * Building with STL maps instead of Google Btree ]) AM_CONDITIONAL([BUILD_WITH_BTREE], [false]) diff --git a/examples/example2.cpp b/examples/example2.cpp index 654d0c5..13f095a 100644 --- a/examples/example2.cpp +++ b/examples/example2.cpp @@ -6,16 +6,13 @@ using namespace pipecolors; int main(void) { - char buffer[128]; - char * buf; + char buffer[256]; int num = 5; const char* str = "My number is"; const char* str2 = "|10My number is|07"; - int len = pcprintf("|01%s |41|09%d|39\n", str, num); + int len = pcprintf("|01%s |09%d|39\n", str, num); pcprintf("|10Length of Len is : |15|30%d\n|07", len); int len2 = pcsprintf(buffer, "%s %d\n", str2, num); printf("\n%s %d\n", buffer, len2); - int len3 = asprintf(&buf, "%s %d\n", str2, num); - printf("\n%s %d\n", buf, len3); return 0; } \ No newline at end of file diff --git a/libpipecolors.cpp b/libpipecolors.cpp index 6134160..9594af3 100644 --- a/libpipecolors.cpp +++ b/libpipecolors.cpp @@ -27,14 +27,18 @@ #include #include #include -#include #include #include "pipecolors.h" namespace pipecolors { - //typedef btree::btree_map colors; +#ifndef BUILD_WITH_BTREE +#include typedef std::map colorMap; +#else +#include "cpp-btree/btree_map.h" + typedef btree::btree_map colorMap; +#endif colorMap getColors() { colorMap colors;