aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-07-30 09:56:28 -0700
committerRob Landley <rob@landley.net>2019-07-31 11:28:40 -0500
commitd8a46b5b6befc72bb7142850fc4f4c1fd7fb1c1b (patch)
treed343b6df9619c1edf84c7648886a0f3d8fcb80c9 /toys/posix
parent88468a07124a5cda235037249a65a32c4c95f1dd (diff)
downloadtoybox-d8a46b5b6befc72bb7142850fc4f4c1fd7fb1c1b.tar.gz
Move the empty regex workaround into xregcomp.
No current caller except grep needs this, but consistency seems like a good idea. Also change the xregcomp error message to be a bit more human-readable, rather than mention an implementation detail.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/grep.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/toys/posix/grep.c b/toys/posix/grep.c
index f2ab2a0d..1fa1a7c4 100644
--- a/toys/posix/grep.c
+++ b/toys/posix/grep.c
@@ -404,9 +404,8 @@ static void parse_regex(void)
if (FLAG(o) && !*al->arg) continue;
dlist_add_nomalloc(&TT.reg, (void *)(shoe = xmalloc(sizeof(struct reg))));
- // BSD regcomp doesn't support empty regex, so we fake that.
- xregcomp(&shoe->r, *al->arg ? al->arg : "()",
- (REG_EXTENDED*(!!FLAG(E)|!*al->arg))|(REG_ICASE*!!FLAG(i)));
+ xregcomp(&shoe->r, al->arg,
+ (REG_EXTENDED*!!FLAG(E))|(REG_ICASE*!!FLAG(i)));
}
dlist_terminate(TT.reg);
}