diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-01-23 02:23:07 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-01-23 02:23:07 +0100 |
commit | e7f82626820f8a655a4015671185aefad037e78e (patch) | |
tree | ad02774a201bb8412a420f47eff7437bb5558792 /src/grab.c | |
parent | b7ad537992a6ec13f0a984ca6edb64c7d5707e97 (diff) |
Minor refactor
Diffstat (limited to 'src/grab.c')
-rw-r--r-- | src/grab.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -44,8 +44,6 @@ #define streq(a, b) (!strcmp(a, b)) #define memeq(a, b, n) (!memcmp(a, b, n)) -#define EEARLY "Input string terminated prematurely" - #define DEFCOL_FN "35" #define DEFCOL_HL "01;31" #define DEFCOL_LN "32" @@ -269,7 +267,7 @@ comppat(char8_t *s) while (*s && xisspace(*s)) s++; if (!*s) - diex(EEARLY); + diex("Input string terminated prematurely"); do { int w; @@ -292,7 +290,7 @@ comppat(char8_t *s) if (ch == RUNE_ERROR) diex("Invalid UTF-8 sequence near ‘%02hhX’", s[-1]); if (ch == '\0') - diex(EEARLY); + diex("Input string terminated prematurely"); /* Find the closing delimiter. The user is allowed to omit the closing delimiter if this is the last operation in the query pattern. */ @@ -305,15 +303,13 @@ comppat(char8_t *s) if (op.c != 'h') diex("Empty regex given to ‘%c’", op.c); op.pat = ops.buf[ops.len - 1].pat; -#ifdef GRAB_DEBUG - op.alloced = false; -#endif - } else { + } else op.pat = mkregex(p, s - p); -#ifdef GRAB_DEBUG - op.alloced = true; + +#if GRAB_DEBUG + op.alloced = s - p == 0; #endif - } + dapush(&ops, op); if (*s) { |