musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/regex/regcomp.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2016年02月29日 16:36:25 +0000
committerRich Felker <dalias@aerifal.cx>2016年03月02日 00:47:22 -0500
commit29b13575376509bb21539711f30c1deaf0823033 (patch)
treea562ad6c465f6f33d0cb534d6a80a5e85bd681b3 /src/regex/regcomp.c
parent39ea71fb8afddda879a1999f2a203dfdaf57a639 (diff)
downloadmusl-29b13575376509bb21539711f30c1deaf0823033.tar.gz
fix ^* at the start of a complete BRE
This is a workaround to treat * as literal * at the start of a BRE. Ideally ^ would be treated as an anchor at the start of any BRE subexpression and similarly $ would be an anchor at the end of any subexpression. This is not required by the standard and hard to do with the current code, but it's the existing practice. If it is changed, * should be treated as literal after such anchor as well.
Diffstat (limited to 'src/regex/regcomp.c')
-rw-r--r--src/regex/regcomp.c 4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
index 7a2864cd..5fad98b3 100644
--- a/src/regex/regcomp.c
+++ b/src/regex/regcomp.c
@@ -994,6 +994,10 @@ static reg_errcode_t tre_parse(tre_parse_ctx_t *ctx)
if (*s=='\\')
s++;
+ /* handle ^* at the start of a complete BRE. */
+ if (!ere && s==ctx->re+1 && s[-1]=='^')
+ break;
+
/* extension: multiple consecutive *+?{,} is unspecified,
but (a+)+ has to be supported so accepting a++ makes
sense, note however that the RE_DUP_MAX limit can be
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月05日 19:49:24 +0000

AltStyle によって変換されたページ (->オリジナル) /