Re: Enhancement Request: Folding Whitespace

Chris Babcock <[email protected]> Mon, 29 Jun 2009 19:32:52 -0700
Newsgroups gmane.mail.spam.crm114
Organization Kolonel Panic
Message-ID <[email protected]>
On Tue, 30 Jun 2009 01:18:40 +0200
Ger Hobbelt <[email protected]> wrote:

> On Sun, Jun 28, 2009 at 10:34 AM, Chris
> Babcock<[email protected]> wrote:
> > A different request (unless I somehow missed it in the docs)...
> > a :_var: for { and }.

Within a script: /\\{/ or /[{]/
From the command line: /\\\{/ or /[{]/

> Well, first off, you could of course always roll your own suing an
> isolate statement like (probably buggy, off the top of my head here):
> 
> isolate (:_cbo:) /\\\{/
> isolate (:_cbc:) /\\\}/
> 
> I only show three '\' here because ...

...I said that I already tried two.

Three is what's needed to make it work from the command line:

[usak@cl-t090-563cl bin]$ crm "-{match /\\{/; output /found\n/}"
{

crm: *ERROR*
 Regular Expression Compilation Problem: Missing '}'
Sorry, but this program is very sick and probably should be killed off.
This happened at line 2 of file (from command line):
    match /\{/
(runtime system location: crm_expr_match.c(249) in routine:
crm_expr_match) [usak@cl-t090-563cl bin]$ crm "-{match /\\\{/;
output /found\n/}" {
found
[usak@cl-t090-563cl bin]$

> > I was building a little something to help me manage my CSS a little
> > easier - http://crm.pastebin.com/f61f6952e - and I found out that
> > it's somewhat tricky to match curly braces and downright demonic
> > trying to match just one without its partner. This works in a match:
> >
> >        /\\{...\\}/
> >
> > Singly, however...
> >
> > [usak@cl-t090-563cl includes]$ crm "-{match /\\{/; output /found/}"
> > {
> >
> > crm: *ERROR*
> >  Regular Expression Compilation Problem: Missing '}'
> > Sorry, but this program is very sick and probably should be killed
> > off. This happened at line 2 of file (from command line):
> >    match /\{/
> > (runtime system location: crm_expr_match.c(249) in routine:
> > crm_expr_match)
> > 
> > This is on Blame Barack. It's between delimiters, so it shouldn't
> > matter... but it does.
> 
> ... this /might/ (and note: I'm now ad libbing at full power; haven't
> touched crm114 in a while due to real life catching up with me) be due
> to either:
> 
> a) teeny bugger in TRE (my bet is: small chance, but who am I)
> 
> b) a bugger similar to the awk escape agony sisters, where in awk you
> can run into some peculiarities due to certain expressions being
> 'evaluated' _twice_, thus 'unescaping' twice: once every round.
> Add to that possible escaping in the shell and you've got jackpot.
> (Meaning: your example may behave differently as shown (shell command
> line) and when run as a crm script file (where the same statement is
> stored in a source file and thus fed to crm114.)
> 
> You may want to test this error happening with
> 
> \{
> \\{
> \\\{
> \\\\{

Here it is:
http://crm.pastebin.com/d2cc198ba

> and see which of those buggers actually makes it into TRE as a
> _literal_ curly brace open, without triggering an error.
> 
> Such test cases (and that includes the error-throwing ones!) are very
> nice to have for augmenting the test/regression set. Thanks for
> posting #1 of that set already.

At the pastebin URL above, there's the suite. 

> An alternative cop-out which I've used with awk (which I am a big fan
> of) or sed is faking it through wrapping special chars in [] set
> expressions, e.g.: sed -e expression
> 
> s/[{]/X/g

This is why caffiene is not a sleep substitute:

[usak@cl-t090-563cl bin]$ crm "-{match /[{]/; output /found\n/}"
{
found

I *know* I tried that. Really. 

I can reproduce the other error... I tried two escapes on the commmand
line (needed a third to account for the bash interpreter). When that
didn't work, I refactored the code to put both the curlies in the same
expression and added escapes until it worked - 2. The square brackets
work no matter what I do, so I must have been doing something
ingeniously stupid to break them before. I would look in .bash_history,
but am afraid.

> > Just wait until I finish the mailing list, blog, forums and CMS. ;-)
> 
> I am not worthy...

Don't applaud, just throw money. Right now all this work is helping me
to break even on an $85 a month habit, I mean hobby.

This list has been a great help. My education is a bit spotty because
it's all self-directed learning and I have the internal discipline of a
ferret on crack. 

Chris

------------------------------------------------------------------------------

_______________________________________________
Crm114-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crm114-general
signature.asc (application/pgp-signature, 489 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQEcBAEBAgAGBQJKSXlUAAoJEASgqNsqZfCHcosH/3ky0TyVKB96DkR55Hprr7FT
CrPNdK6NXXKuD/iS21ubuM65B9/tQ3C3SEy1A2iaUdCtWaPyFe0Qsgatk7eGVTNa
w7bnGkGLBnk5oU4A/g/LskAiLkabp+Tw0KVeEvBdIJeHLu99lhHMnEhBlx5lnqAx
0GcjeKbXXl/zlYIWPamFc5rEKWPBWpZhGgTL/fJjr4EzmPWiv6/r+54ub1uSZ/cN
nt5QNGzqstLtpurWXW/LSHvVgzP+rkV3NhKvjm/6MyvIvYx1BLidE2Xy2rQChrMp
diH/osLld8XAv+6dXt3MPuTNfTh/2irwcY6A4s+yqWazzklN/oTwjAO2FDMaZeg=
=rSpI
-----END PGP SIGNATURE-----