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