From 75663bfa46ee50729713c4f8b847152f676481e6 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sat, 4 May 2024 10:24:15 -0400 Subject: [PATCH] After a bit of struggle figured out how to do time. So dumb that somethign so simple is so hard. --- PPP3/Makefile | 4 +++- PPP3/goc.cpp | 25 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/PPP3/Makefile b/PPP3/Makefile index 828a03e..a74bcc3 100644 --- a/PPP3/Makefile +++ b/PPP3/Makefile @@ -1,5 +1,7 @@ - all: + meson compile -C . 2>&1 | ../builddir/goc + +build: meson compile -C . test: diff --git a/PPP3/goc.cpp b/PPP3/goc.cpp index c6f5d81..90ac18c 100644 --- a/PPP3/goc.cpp +++ b/PPP3/goc.cpp @@ -1,8 +1,10 @@ #include +#include #include #include #include #include +#include using namespace std; using namespace fmt; @@ -11,21 +13,26 @@ int main() { regex err_re("(.*?):([0-9]+):([0-9]+):\\s*(.*?):\\s*(.*)"); string line; - smatch err_match; + smatch err; + ofstream stats_out; + stats_out.open("stats.csv", ios::out | ios::app); + auto t = time(nullptr); + auto tm = *std::gmtime(&t); while(getline(cin, line)) { print("{}\n", line); - if(regex_match(line, err_match, err_re)) { - string file_name = err_match[1].str(); - string line = err_match[2].str(); - string col = err_match[3].str(); - string type = err_match[4].str(); - string message = err_match[5].str(); + if(regex_match(line, err, err_re)) { + string file_name = err[1].str(); + string line = err[2].str(); + string col = err[3].str(); + string type = err[4].str(); + string message = err[5].str(); - print("{},{},{},{},{}\n", - file_name, line, col, type, message); + stats_out << put_time(&tm, "%FT%TZ"); + stats_out << format(",{},{},{},{},{}\n", file_name, line, col, type, message); } } + stats_out.close(); return 0; }