From mboxrd@z Thu Jan 1 00:00:00 1970 From: dexen deVries To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Date: Fri, 5 Oct 2012 16:48:42 +0200 Message-ID: <1430690.NQGf40Hiit@coil> User-Agent: KMail/4.9.2 (Linux/3.6.0-l46; KDE/4.9.2; x86_64; ; ) In-Reply-To: References: <1492275.224dsYbtlA@coil> <37362a64c5aa9018d47a5ba6f10fcba5@brasstown.quanstro.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart5792814.YinkA8CFBr" Content-Transfer-Encoding: 7Bit Subject: Re: [9fans] acme + plumber question Topicbox-Message-UUID: bd5cf9ca-ead7-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --nextPart5792814.YinkA8CFBr Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Friday 05 of October 2012 10:34:04 erik quanstrom wrote: > > however, i thought of a really sneaky cheat, that is almost correct= .=20 > > since > > \n is 0a, and we almost never see 09 or 0b (ht and vt), we could bu= ild a > > sneaky character class to elude the parser: > >=20 > > data=09matches=09'error[=09-=0B]' > > plumb=09start=09window >=20 > i didn't think hard enough about mailers mangling this. what i had w= as >=20 > data=09matches=09'error[0x09-0x11] >=20 > of course, replace 0x09 and 0x11 with their literal codepoints. it's succinct, it works and yes, it went through correctly :D another possible way -- separate verb for multiline match. meta -- is it ok to send Git patches as an attachment? cheers, --=20 dexen deVries [[[=E2=86=93][=E2=86=92]]] --nextPart5792814.YinkA8CFBr Content-Disposition: attachment; filename="plumber-multiline.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="utf-8"; name="plumber-multiline.patch" commit fb99b4872ee3252bea88cf1f187c6cbedeba085b Author: dexen deVries Date: Fri Oct 5 16:45:19 2012 +0200 usability: provide multiline matching in plumber diff --git a/src/cmd/plumb/match.c b/src/cmd/plumb/match.c index 5a4cd88..0dcc664 100644 --- a/src/cmd/plumb/match.c +++ b/src/cmd/plumb/match.c @@ -283,6 +283,7 @@ matchpat(Plumbmsg *m, Exec *e, Rule *r) case VIsfile: return verbisfile(r->obj, m, r, e, ~DMDIR, DMDIR, &e->file); case VMatches: + case VMatchesMultiline: return verbmatches(r->obj, m, r, e); case VSet: verbset(r->obj, m, r, e); diff --git a/src/cmd/plumb/plumber.h b/src/cmd/plumb/plumber.h index c8f3081..cd00680 100644 --- a/src/cmd/plumb/plumber.h +++ b/src/cmd/plumb/plumber.h @@ -29,6 +29,7 @@ enum VIsdir, VIsfile, VMatches, + VMatchesMultiline, VSet, VStart, VTo diff --git a/src/cmd/plumb/rules.c b/src/cmd/plumb/rules.c index 4da4bb2..d815db9 100644 --- a/src/cmd/plumb/rules.c +++ b/src/cmd/plumb/rules.c @@ -64,6 +64,7 @@ char *verbs[] = "isdir", "isfile", "matches", + "matchesmultiline", "set", "start", "to", @@ -363,6 +364,10 @@ parserule(Rule *r) r->regex = regcomp(r->qarg); return; } + if(r->verb == VMatchesMultiline){ + r->regex = regcompnl(r->qarg); + return; + } break; case OPlumb: if(r->verb!=VClient && r->verb!=VStart && r->verb!=VTo) --nextPart5792814.YinkA8CFBr--