#include #include /* Highlight a pattern in the input by coloring it in the output. */ /* "regex" is used to find the patterns. */ // Build with gcc // Run by piping LF95 output to executable. For bash: "lf95 source.f90 2>&1| hl" // For tsch: "lf95 source.f90 |& hl" main ( int argc, char* argv[] ) { char b[256]; /* input buffer */ char after[] = "\033[0m"; /* black on transparent background */ char blue[] = "\033[00;34;1m"; /* bold blue on transparent background */ char puce[] = "\033[00;35;1m"; /* bold puce on transparent background */ char red[] = "\033[00;31;1m"; /* bold red on transparent background */ int i; /* Subscript/loop inductor */ typedef struct { char* find; /* Pattern to find */ char* color; /* String to but before it */ regex_t preg; /* Compiled pattern -- from regcomp */ } pat; regmatch_t match; /* Where is the string that matches the pattern? */ pat pats[] = { "[0-9]+-[SU]", red, {}, /* lf95 errors */ "[0-9]+-W", blue, {}, /* lf95 warnings */ "[0-9]+-I", puce, {}, /* lf95 informative */ /* linker patterns */ "undefined", red, {} }; /* during linking */ #define NPAT sizeof pats / sizeof pats[0] /* Compile the patterns */ for ( i=0; i