From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10147 Path: news.gmane.org!not-for-mail From: Julien Ramseier Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] regex: support non-greedy quantifiers Date: Thu, 16 Jun 2016 17:33:48 +0200 Message-ID: <66E91EF4-6D8E-4263-9386-24C9FF9DC2D9@gmail.com> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1466091261 26350 80.91.229.3 (16 Jun 2016 15:34:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 16 Jun 2016 15:34:21 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10160-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jun 16 17:34:21 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1bDZJD-0003ln-Kd for gllmg-musl@m.gmane.org; Thu, 16 Jun 2016 17:34:19 +0200 Original-Received: (qmail 24288 invoked by uid 550); 16 Jun 2016 15:34:17 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 24170 invoked from network); 16 Jun 2016 15:34:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=1rxX/83W0tql/32KNnKgoEqUvdOe1fmLDFuXRvHwKE8=; b=yiR0cynxaCo1EfnGvTaNxQvbaxQ4tUPfplZT01vPbH/QKTZA+fiTBHEaPXU68wCJt+ zc3jwjSWUhF9/zjTkfJG0jDOEn+tk6MFRwgN/unj51mlk0wDcoIP0NrHIDCSUBPH6EVN 6/9PFB/AZk4VpqX8mXJ7wmIXQ7Ub2LogCeb6FpcUy1IQuMGHFP2s9DLxZt7LBYfGi8o0 eXxkYCXuWF4vBm99aAEV+p6ALfJNQEToJHox59CnXoxHYQ0ewlKo2QjcY+emvxmfbKGX hBYSq/gJ1Wt8HoZxG3u9niZ6b6tiUJlT5vwRN2XYnd6O5ot2YZoVZ7CoK6m0quPZ0ual ohGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=1rxX/83W0tql/32KNnKgoEqUvdOe1fmLDFuXRvHwKE8=; b=KowLyxNm9ZyZ44NyYb0dMLP8GgC7ipJ6kcww+qms8mEK/vFqsEilInMQX5UfPAzvVy clhUjh0qXb0laRvYhTU640aACVjeo+34k2fLT+nf/xXWmKfFZ61/DMD3yoAFlKVgPdm5 Tov/F8g5CMCrfVmiFuG8Bl/sw9hPTK11Q3ZILduDRtJ+TU9N9qO4rTAe7QA5B3OJUj/o didXrhMIBk0PvsUog0BAoixlPkPtPNaWuYfko8vThNi8wdEsfYm15e5IR/0qL9aSqdvz 57CsCSV+aiXTOXALgca6t2bxJVj7hF7dXW1GiJa4RjyWU4kwOARXK7Zcah30h1L+RhGQ nddw== X-Gm-Message-State: ALyK8tL014vm0ihxSnityY5urO8Ime9u1e2u9vUlO266Lv7P2rAQxDP8602slgNlbbPVMw== X-Received: by 10.194.133.135 with SMTP id pc7mr251829wjb.49.1466091229808; Thu, 16 Jun 2016 08:33:49 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3112) Xref: news.gmane.org gmane.linux.lib.musl.general:10147 Archived-At: > Le 13 mars 2016 =C3=A0 12:06, Julien Ramseier a = =C3=A9crit : >=20 > Here's a tiny patch to enable non-greedy regex quantifiers. > This is not specified by POSIX, but I think it's a useful > extension, and all the code for supporting it is already present. >=20 > I tested this against the TRE and AT&T test suites (from NetBSD) > and didn't found any regressions. > However I don't know all the ins and outs of the implementation > and I may have missed something obvious. >=20 > - Julien >=20 > diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c > index 5fad98b..cc7d633 100644 > --- a/src/regex/regcomp.c > +++ b/src/regex/regcomp.c > @@ -979,6 +979,7 @@ static reg_errcode_t tre_parse(tre_parse_ctx_t = *ctx) > parse_iter: > for (;;) { > int min, max; > + int minimal =3D 0; >=20 > if (*s!=3D'\\' && *s!=3D'*') { > if (!ere) > @@ -1014,11 +1015,16 @@ static reg_errcode_t tre_parse(tre_parse_ctx_t = *ctx) > if (*s =3D=3D '?') > max =3D 1; > s++; > + /* Non-greedy */ > + if (ere && *s =3D=3D '?') { > + minimal =3D 1; > + s++; > + } > } > if (max =3D=3D 0) > ctx->n =3D tre_ast_new_literal(ctx->mem, = EMPTY, -1, -1); > else > - ctx->n =3D tre_ast_new_iter(ctx->mem, = ctx->n, min, max, 0); > + ctx->n =3D tre_ast_new_iter(ctx->mem, = ctx->n, min, max, minimal); > if (!ctx->n) > return REG_ESPACE; > } > --=20 > 2.7.2 Ping?