aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-23 02:23:07 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-23 02:23:07 +0100
commite7f82626820f8a655a4015671185aefad037e78e (patch)
treead02774a201bb8412a420f47eff7437bb5558792 /src
parentb7ad537992a6ec13f0a984ca6edb64c7d5707e97 (diff)
Minor refactor
Diffstat (limited to 'src')
-rw-r--r--src/grab.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/grab.c b/src/grab.c
index db9f70c..33943f0 100644
--- a/src/grab.c
+++ b/src/grab.c
@@ -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) {