Working on configure.ac
This commit is contained in:
parent
cdf2ee5c8a
commit
39bcdbbdc8
|
@ -36,3 +36,4 @@ timestamp
|
|||
# Ignore backup files
|
||||
*~
|
||||
libpipecolors.h
|
||||
cpp-btree/
|
|
@ -11,9 +11,14 @@ libpipecolors_la_LIBS = -lboost_regex
|
|||
libpipecolors_la_CFLAGS = -fPIC -DPIC -pthread
|
||||
|
||||
if PC_REMOVE_INVALID
|
||||
AM_CPPFLAGS = -DPC_REMOVE_INVALID
|
||||
AM_CPPFLAGSINVALID = -DPC_REMOVE_INVALID
|
||||
endif
|
||||
|
||||
if BUILD_WITH_BTREE
|
||||
AM_CPPFLAGSBTREE = -DBUILD_WITH_BTREE
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = $(AM_CPPFLAGSBTREE) $(AM_CPPFLAGSINVALID)
|
||||
|
||||
libpipecolors_la_LDFLAGS = -module \
|
||||
-release ${PIPECOLORS_VERSION}
|
||||
|
|
44
configure.ac
44
configure.ac
|
@ -77,11 +77,47 @@ AC_ARG_ENABLE([pipe-stripping],
|
|||
[AC_HELP_STRING([--disable-pipe-stripping], [strip invalid pipe codes [default=no]])],
|
||||
[], [disable_pipe_stripping=no])
|
||||
AM_CONDITIONAL([PC_REMOVE_INVALID], [test "x$disable_pipe_stripping" = "xno"])
|
||||
|
||||
AM_COND_IF([PC_REMOVE_INVALID],
|
||||
[AC_MSG_NOTICE([Invalid pipe codes will be filtered.
|
||||
e.g. (|41Hello will show as Hello World instead of |41Hello World)])],
|
||||
[AC_MSG_NOTICE([Invalid pipe codes will not be filtered.
|
||||
e.g. (|41Hello will show |41Hello World instead of Hello World)])])
|
||||
[AC_MSG_NOTICE([Invalid pipe codes will be filtered.])],
|
||||
[AC_MSG_NOTICE([Invalid pipe codes will not be filtered.])])
|
||||
|
||||
AC_ARG_ENABLE([btree],
|
||||
[AC_HELP_STRING([--enable-btree], [enable googles btree instead of stl map [default=no]])],
|
||||
[enable_btree=yes])
|
||||
AM_CONDITIONAL([BUILD_WITH_BTREE], [test "x$enable_btree" = "xyes"])
|
||||
|
||||
if test "x$enable_btree" == "xyes"; then
|
||||
|
||||
AC_CHECK_TOOL([MERCURIAL], [hg], [no])
|
||||
|
||||
AM_CONDITIONAL([HAVE_HG_BIN], [test "x${MERCURIAL}" = "xhg"])
|
||||
|
||||
AC_MSG_CHECKING([for ${srcdir}/cpp-btree/btree.h])
|
||||
|
||||
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
|
||||
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])
|
||||
$(which hg) clone https://code.google.com/p/cpp-btree/
|
||||
else
|
||||
AC_VERBOSE([
|
||||
* Could not find hg in $PATH
|
||||
* Building with STL maps instead of Google Btree
|
||||
])
|
||||
AM_CONDITIONAL([BUILD_WITH_BTREE], [false])
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([the-force],
|
||||
[AC_HELP_STRING([--enable-the-force], [use the force [default=no]])],
|
||||
[], [enable_the_force=no])
|
||||
|
|
|
@ -25,18 +25,19 @@
|
|||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdarg.h>
|
||||
#include <cstring>
|
||||
#include <cstdarg>
|
||||
#include <map>
|
||||
#include <boost/regex.hpp>
|
||||
#include "pipecolors.h"
|
||||
|
||||
namespace pipecolors {
|
||||
|
||||
std::map<std::string, std::string> colors;
|
||||
//typedef btree::btree_map<std::string, std::string> colors;
|
||||
typedef std::map<std::string, std::string> colorMap;
|
||||
|
||||
std::map<std::string, std::string> getColors() {
|
||||
std::map<std::string, std::string> colors;
|
||||
colorMap getColors() {
|
||||
colorMap colors;
|
||||
colors["|00"] = "\x1b[0;30m"; // FG_BLACK;
|
||||
colors["|01"] = "\x1b[0;34m"; // FG_BLUE;
|
||||
colors["|02"] = "\x1b[0;32m"; // FG_GREEN;
|
||||
|
@ -66,6 +67,7 @@ namespace pipecolors {
|
|||
colors["|39"] = "\x1b[0;39m"; // FG_DEFAULT
|
||||
return colors;
|
||||
}
|
||||
|
||||
bool has_colors(void) {
|
||||
return isatty(fileno(stdout));
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ namespace pipecolors {
|
|||
end = s.end();
|
||||
std::string len(s);
|
||||
|
||||
colors = getColors();
|
||||
colorMap colors = getColors();
|
||||
|
||||
while(regex_search(start, end, match, re, flags))
|
||||
{
|
||||
|
@ -112,6 +114,7 @@ namespace pipecolors {
|
|||
char * buffer;
|
||||
va_list args;
|
||||
int ret;
|
||||
std::pair<std::string, int> result;
|
||||
|
||||
va_start(args, format);
|
||||
ret = vasprintf(&buffer, format, args);
|
||||
|
@ -124,8 +127,9 @@ namespace pipecolors {
|
|||
std::string s(buffer);
|
||||
free(buffer);
|
||||
|
||||
std::pair<std::string, int> result = replace_colors(s);
|
||||
std::cout << result.first;
|
||||
result = replace_colors(s);
|
||||
|
||||
printf("%s", result.first.c_str());
|
||||
|
||||
return(result.second);
|
||||
|
||||
|
|
Loading…
Reference in New Issue