aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-11-01 20:26:48 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-11-01 20:26:48 +0100
commitec5976bbd5a930e040a34b9e93bf9cc41d7230c1 (patch)
treeec46751b70c254118de4df8527e3741cf08a59d2 /src
parent8199336423014729c92bac5c463e550810a28bdc (diff)
Simplify check for empty regex
Diffstat (limited to 'src')
-rw-r--r--src/main.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index d5bbedf..f702842 100644
--- a/src/main.c
+++ b/src/main.c
@@ -277,19 +277,15 @@ pattern_comp(u8view_t pat)
/* Find the right delimeter, which is optional for the last
operator */
- u8view_t re = {pat.p, -1};
+ u8view_t re = {pat.p, 0};
while ((w = ucsnext(&ch, &pat)) != 0) {
if (ch == '\\') {
if (ucsnext(nullptr, &pat) == 0)
cerr(EXIT_FATAL, "Premature end of pattern");
- } else if (ch == rdelim) {
- re.len = pat.p - re.p - w;
+ } else if (ch == rdelim)
break;
- }
}
- if (re.len == -1)
- re.len = pat.p - re.p;
- if (re.len == 0) {
+ if ((re.len = pat.p - re.p - w) == 0) {
if (op.c != 'h') {
cerr(EXIT_FATAL, "%s%c%s operator given empty regex",
lquot, op.c, rquot);