diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-09-09 22:29:09 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-09-09 22:29:09 -0700 |
| commit | 3eee7c4bad6766980bf042145c54e973b1856ed2 (patch) | |
| tree | dc458e7f309b51590c4530b98e3cbff6d1789759 /utils.h | |
| parent | 64659a1566d866b484b4768a870e22a7e83a3db8 (diff) | |
Loads of changes, including new CLI flags, start-in-string mode, etc.
Diffstat (limited to 'utils.h')
| -rw-r--r-- | utils.h | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -2,10 +2,12 @@ * utils.h - Some helper code for debugging and error logging. */ +#define streq(a, b) (strcmp(a, b) == 0) // TODO: better error reporting #define check(cond, ...) do { if (!(cond)) { fprintf(stderr, __VA_ARGS__); fwrite("\n", 1, 1, stderr); _exit(1); } } while(0) #define debug(...) do { if (verbose) fprintf(stderr, __VA_ARGS__); } while(0) +static int verbose = 0; static int visualize_delay = -1; /* @@ -42,7 +44,7 @@ static inline int matchchar(const char **str, char c) static void visualize(const char *source, const char *ptr, const char *msg) { - if (visualize_delay < 0) return; + if (!verbose) return; fprintf(stderr, "\033[0;1m\r\033[2A\033[K%.*s\033[0;2m%s\033[0m\n", (int)(ptr-source), source, ptr); fprintf(stderr, "\033[0;1m"); @@ -50,5 +52,6 @@ static void visualize(const char *source, const char *ptr, const char *msg) fprintf(stderr, "^\033[K\n"); if (msg) fprintf(stderr, "\033[K\033[33;1m%s\033[0m", msg); - usleep(visualize_delay); + if (visualize_delay > 0) + usleep(visualize_delay); } |
