Hi 

On Fr, 04 Jan 2013, Christian Brabandt wrote:

> Hi Ben!
> 
> On Do, 03 Jan 2013, Ben Fritz wrote:
> 
> > On Thursday, January 3, 2013 2:51:38 AM UTC-6, martinwguy wrote:
> > > On Tuesday, 28 June 2011 13:57:37 UTC+2, Andy Wokula  wrote:
> > > > Strange: one can't write a collection with range [X-Y] where Y is the
> > > > character ']'.
> > > > 
> > > > I thought the following should work, but it doesn't:
> > > >      /[@-\]]
> > > >
> > > > Is it a bug that '\' after '-' in a collection is taken literally?
> > > 
> > > No, that's normal vi behaviour. \ is not special in a character range (it 
> > > stands for itself) and to include ] you need to specify it as the first 
> > > character in the range.
> 
> That is how POSIX defines it:
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05
> 
> ,----
> | A bracket expression is either a matching list expression or a 
> | non-matching list expression. It consists of one or more expressions: 
> | collating elements, collating symbols, equivalence classes, character 
> | classes, or range expressions. The <right-square-bracket> ( ']' ) shall 
> | lose its special meaning and represent itself in a bracket expression if 
> | it occurs first in the list (after an initial <circumflex> ( '^' ), if 
> | any). Otherwise, it shall terminate the bracket expression, unless it 
> | appears in a collating symbol (such as "[.].]" ) or is the ending 
> | <right-square-bracket> for a collating symbol, equivalence class, or 
> | character class. The special characters '.' , '*' , '[' , and '\\' ( 
> | <period>, <asterisk>, <left-square-bracket>, and <backslash>, 
> | respectively) shall lose their special meaning within a bracket 
> | expression.
> `----
> 
> > 
> > I disagree, and consider it a bug. :help /\] says:
> > 
> >     - To include a literal ']', '^', '-' or '\' in the collection, put a
> >       backslash before it: "[xyz\]]", "[\^xyz]", "[xy\-z]" and "[xyz\\]".
> >       (Note: POSIX does not support the use of a backslash this way).  For
> >       ']' you can also make it the first character (following a possible
> >       "^"):  "[]xyz]" or "[^]xyz]" {not in Vi}.
> >       For '-' you can also make it the first or last character: "[-xyz]",
> >       "[^-xyz]" or "[xyz-]".  For '\' you can also let it be followed by
> >       any character that's not in "^]-\bdertnoUux".  "[\xyz]" matches '\',
> >       'x', 'y' and 'z'.  It's better to use "\\" though, future expansions
> >       may use other characters after '\'.
> > 
> > This works:
> > 
> > /[[\\\]]
> 
> Looks like a Vim extension to BRE (as stated in your quotation from the 
> help).
> 
> > 
> > This does not work, even though it should do the same thing if the above 
> > help entry were implemented as stated:
> > 
> > /[[-\]]
> 
> Yes, the backslash doesn't have a special meaning when used within a 
> range. Not sure, we should fix this.

I think, this is implicitly mentioned below :h /[]

,----
| - The following translations are accepted when the 'l' flag is not
|   included in 'cpoptions' {not in Vi}:
|         \e    <Esc>
|         \t    <Tab>
|         \r    <CR>    (NOT end-of-line!)
|         \b    <BS>
|         \n    line break, see above |/[\n]|
|         \d123 decimal number of character
|         \o40  octal number of character up to 0377
|         \x20  hexadecimal number of character up to 0xff
|         \u20AC        hex. number of multibyte character up to 0xffff
|         \U1234        hex. number of multibyte character up to 0xffffffff
|   NOTE: The other backslash codes mentioned above do not work inside
|   []!
`----

However, to fix this, the following patch can be applied:

diff --git a/src/regexp.c b/src/regexp.c
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -2344,7 +2344,12 @@
 
                            /* Handle \o40, \x20 and \u20AC style sequences */
                            if (endc == '\\' && !cpo_lit && !cpo_bsl)
+                           {
                                endc = coll_get_char();
+                               /* Skip over backslash */
+                               if (endc == '\\')
+                                   endc = *regparse++;
+                           }



Mit freundlichen Grüßen
Christian
-- 
Wenn der Knecht zum Waldrand hetzt, war das Örtchen schon besetzt.

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui