From c125794bc6747dec7b593ecc62b6b7f88d93efd8 Mon Sep 17 00:00:00 2001 From: DL Date: Tue, 19 Dec 2017 18:30:10 +0300 Subject: [PATCH 1/2] Added command line option for setting maximum length of input line. --- main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index e4578ab..2168a07 100644 --- a/main.cpp +++ b/main.cpp @@ -6,6 +6,8 @@ #include "FixPathInclude.h" #include "config.h" +#define __STR(x) #x +#define DEFAULT_LINE_LENGTH 4096 class RegEx : public regex_t { @@ -153,6 +155,8 @@ int main(int argc, char** argv) bool skipCompilerLine = 0; bool skipDirectoryLine = 0; bool appendReadyLine = 0; + long maxLineLen = DEFAULT_LINE_LENGTH; + static Option options[] = { Option("help", no_argument, 0, 'h', @@ -175,6 +179,8 @@ int main(int argc, char** argv) "Skip all lines from output except those recognized as compiler lines."), Option("append_ready", no_argument, 0, 'r', "Append a line at end, so its clear we are ready."), + Option("line_length", required_argument, 0, 'l', + "Maximum line length. Default " __STR(DEFAULT_LINE_LENGTH) "."), // Option("input", required_argument, 0, 'f', "Use infile instead of stdin.", "infile"), // Option("output", required_argument, 0, 'o', "Use outfile instead of stdout.", "infile"), Option(0, 0, 0, 0) @@ -215,6 +221,12 @@ int main(int argc, char** argv) case 'r' : appendReadyLine = true; break; + case 'l' : + maxLineLen = strtol(optarg, NULL, 0); + if (maxLineLen < 0) { + maxLineLen = DEFAULT_LINE_LENGTH; + } + break; /* case 'f' : infile = optarg; @@ -260,8 +272,7 @@ int main(int argc, char** argv) string common; string prevCommon; regmatch_t match[10]; - const int maxLineLen = 4096; - char line[maxLineLen]; + char* line = new char[maxLineLen]; while (cin.getline(line, maxLineLen)) { if (regexec(®ex_we, line, 6, match, 0) == 0) @@ -347,6 +358,7 @@ int main(int argc, char** argv) { cout << "-------------------- Ready --------------------" << endl << flush; } + delete[] line; return 0; } From 852b4383701db5870f123a8fd51ad0cd9b696288 Mon Sep 17 00:00:00 2001 From: DL Date: Fri, 19 Jan 2018 08:10:08 +0300 Subject: [PATCH 2/2] Added "note" and "fatal error" error codes to trouble matcher. --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 2168a07..55cf03d 100644 --- a/main.cpp +++ b/main.cpp @@ -257,7 +257,7 @@ int main(int argc, char** argv) cout << "appendReadyLine: " << appendReadyLine << endl; */ // Recognize the warning/error line - RegEx regex_we("^(.*):([0-9]+):([0-9]+): +(warning|error): +(.*)$"); + RegEx regex_we("^(.*):([0-9]+):([0-9]+): +(note|warning|error|fatal error): +(.*)$"); // make: Entering|Leaving directory `/Users/xaljox/GitHub/bash/bash-4.4/build_mac' RegEx regex_dir("^make(\\[[0-9]+\\])?: ((Entering)|(Leaving)) directory ['`](.*)'");