diff options
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); } |
