[patch] fix matching [^\n] matching newlines

37 views
Skip to first unread message

Christian Brabandt

unread,
Dec 1, 2012, 2:21:37 AM12/1/12
to vim...@vim.org
Bram,
this patch fixes this item from the todo list:

/[^\n] does match at a line break. Expected to do the same as /.

Vim now handles /[^\n] exactly like matching the '.'

While making this patch, I noticed, that currently echo match("\n", '.')
returns true. This might be unexpected, since '.' shouldn't match
newlines I guess. But changing this would be an incomptabile change,
since otherwise A^@A or A^MA wouldn't match anymore and I guess, this
wouldn't not be intended. So I left it untouched.

But it should probably be documented somewhere.

BTW, hg seems to handle the testfiles as binary files (probably because
of the NUL in there). I hope this doesn't cause problems applying it,
but if it does, I can mail you the 2 complete files.

regards,
Christian
regexp_match_newline.diff

Bram Moolenaar

unread,
Dec 1, 2012, 8:26:34 AM12/1/12
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

> this patch fixes this item from the todo list:
>
> /[^\n] does match at a line break. Expected to do the same as /.
>
> Vim now handles /[^\n] exactly like matching the '.'

Thanks, I'll update the todo list.

> While making this patch, I noticed, that currently echo match("\n", '.')
> returns true. This might be unexpected, since '.' shouldn't match
> newlines I guess. But changing this would be an incomptabile change,
> since otherwise A^@A or A^MA wouldn't match anymore and I guess, this
> wouldn't not be intended. So I left it untouched.

Let's not make changes that might cause some scripts to fail in
unexpected ways.

> But it should probably be documented somewhere.

Yes.

> BTW, hg seems to handle the testfiles as binary files (probably because
> of the NUL in there). I hope this doesn't cause problems applying it,
> but if it does, I can mail you the 2 complete files.

Hmm, I don't know how to apply that binary patch, but perhaps "patch"
knows. Anyway, if you can send those files in a zip'ed attachment it
will certainly work.

--
From "know your smileys":
%-) After staring at screen for 15 hours

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Dec 1, 2012, 4:33:21 PM12/1/12
to vim...@vim.org
Hi Bram!

On Sa, 01 Dez 2012, Bram Moolenaar wrote:

> Hmm, I don't know how to apply that binary patch, but perhaps "patch"
> knows. Anyway, if you can send those files in a zip'ed attachment it
> will certainly work.

hg import at least can handle it. But anyhow, here is the tarfile of the
changed test79 files.

regards,
Christian
--
Wie man sein Kind nicht nennen sollte:
Hans A. Plast
test79.tar.gz

Bram Moolenaar

unread,
Dec 2, 2012, 11:08:31 AM12/2/12
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

> On Sa, 01 Dez 2012, Bram Moolenaar wrote:
>
> > Hmm, I don't know how to apply that binary patch, but perhaps "patch"
> > knows. Anyway, if you can send those files in a zip'ed attachment it
> > will certainly work.
>
> hg import at least can handle it. But anyhow, here is the tarfile of the
> changed test79 files.

Thanks!

--
I AM THANKFUL...
...for the mess to clean after a party because it means I have
been surrounded by friends.
Reply all
Reply to author
Forward
0 new messages