diff --git a/examples/example2 b/examples/example2 index 12ea34c..594842f 100755 Binary files a/examples/example2 and b/examples/example2 differ diff --git a/examples/example2.cpp b/examples/example2.cpp index 252f45c..8faa824 100644 --- a/examples/example2.cpp +++ b/examples/example2.cpp @@ -8,7 +8,7 @@ int main(void) { int num = 5; const char* str = "My number is"; - pcprintf("|01%s |41|09%d|39\n", str, num); - + int len = pcprintf("|01%s |41|09%d|39\n", str, num); + pcprintf("|10Length of String is : |15|30%d\n", len); return 0; } \ No newline at end of file diff --git a/libpipecolors.cpp b/libpipecolors.cpp index bb345b0..89f00e1 100644 --- a/libpipecolors.cpp +++ b/libpipecolors.cpp @@ -82,7 +82,7 @@ namespace pipecolors { start = s.begin(); end = s.end(); std::string len(s); - + int reallen; colors = getColors(); while(regex_search(start, end, match, re, flags)) @@ -102,7 +102,8 @@ namespace pipecolors { start = match[0].second; flags |= boost::match_prev_avail | boost::match_not_bob; } - return std::make_pair(s, len.length()); + + return std::make_pair(s, len.find("\n") ? len.length() - 1 : len.length()); } @@ -129,4 +130,7 @@ namespace pipecolors { return(result.second); } + int pcsprintf(char **strp, const char *fmt, va_list ap) { + return true; + } } // namespace diff --git a/pipecolors.h b/pipecolors.h index 14b1f95..6b7a662 100644 --- a/pipecolors.h +++ b/pipecolors.h @@ -11,7 +11,7 @@ extern "C" { #endif int pcprintf( const char * format, ... ); -//int pcsprintf(char **strp, const char *fmt, va_list ap); +int pcsprintf(char **strp, const char *fmt, va_list ap); #ifdef __cplusplus }