9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: dexen deVries <dexen.devries@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] acme + plumber question
Date: Fri,  5 Oct 2012 16:48:42 +0200	[thread overview]
Message-ID: <1430690.NQGf40Hiit@coil> (raw)
In-Reply-To: <b58db45827edc5d69701de6db84bc90e@brasstown.quanstro.net>

[-- Attachment #1: Type: text/plain, Size: 763 bytes --]

On Friday 05 of October 2012 10:34:04 erik quanstrom wrote:
> > however, i thought of a really sneaky cheat, that is almost correct. 
> > since
> > \n is 0a, and we almost never see 09 or 0b (ht and vt), we could build a
> > sneaky character class to elude the parser:
> > 
> > data	matches	'error[	-\v]'
> > plumb	start	window
> 
> i didn't think hard enough about mailers mangling this.  what i had was
> 
> data	matches	'error[0x09-0x11]
> 
> 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,
-- 
dexen deVries

[[[↓][→]]]

[-- Attachment #2: plumber-multiline.patch --]
[-- Type: text/x-patch, Size: 1434 bytes --]

commit fb99b4872ee3252bea88cf1f187c6cbedeba085b
Author: dexen deVries <dexen.devries@gmail.com>
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)

      reply	other threads:[~2012-10-05 14:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-05 10:23 dexen deVries
2012-10-05 11:49 ` erik quanstrom
2012-10-05 12:31   ` dexen deVries
2012-10-05 12:44   ` dexen deVries
2012-10-05 13:04     ` erik quanstrom
2012-10-05 13:08       ` dexen deVries
2012-10-05 14:25         ` erik quanstrom
2012-10-05 14:34           ` erik quanstrom
2012-10-05 14:48             ` dexen deVries [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430690.NQGf40Hiit@coil \
    --to=dexen.devries@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).