summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-07-21 17:06:00 +0200
committerBram Moolenaar <Bram@vim.org>2013-07-21 17:06:00 +0200
commitac7c33e38c6e47a9568c1037e9ddd09d29c2a64e (patch)
tree5227002ee87a7cac4c342c612420833536f798f4 /src
parent9ba7e17de1b9ff6f443858036ac15624d86929aa (diff)
downloadvim-ac7c33e38c6e47a9568c1037e9ddd09d29c2a64e.zip
updated for version 7.4a.036
Problem: "\p" in a regexp does not match double-width characters. (Yukihiro Nakadaira) Solution: Don't count display cells, use vim_isprintc().
Diffstat (limited to 'src')
-rw-r--r--src/regexp.c7
-rw-r--r--src/regexp_nfa.c4
-rw-r--r--src/testdir/test64.in1
-rw-r--r--src/testdir/test64.ok3
-rw-r--r--src/testdir/test95.in11
-rw-r--r--src/testdir/test95.ok7
-rw-r--r--src/version.c2
7 files changed, 30 insertions, 5 deletions
diff --git a/src/regexp.c b/src/regexp.c
index fdcd9f41e..06bbb4a54 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -4563,14 +4563,14 @@ regmatch(scan)
break;
case PRINT:
- if (ptr2cells(reginput) != 1)
+ if (!vim_isprintc(PTR2CHAR(reginput)))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case SPRINT:
- if (VIM_ISDIGIT(*reginput) || ptr2cells(reginput) != 1)
+ if (VIM_ISDIGIT(*reginput) || !vim_isprintc(PTR2CHAR(reginput)))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
@@ -5944,7 +5944,8 @@ regrepeat(p, maxcount)
if (got_int)
break;
}
- else if (ptr2cells(scan) == 1 && (testval || !VIM_ISDIGIT(*scan)))
+ else if (vim_isprintc(PTR2CHAR(scan)) == 1
+ && (testval || !VIM_ISDIGIT(*scan)))
{
mb_ptr_adv(scan);
}
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index 72e3a74ff..07e2fa1fe 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -5749,12 +5749,12 @@ nfa_regmatch(prog, start, submatch, m)
break;
case NFA_PRINT: /* \p */
- result = ptr2cells(reginput) == 1;
+ result = vim_isprintc(PTR2CHAR(reginput));
ADD_STATE_IF_MATCH(t->state);
break;
case NFA_SPRINT: /* \P */
- result = !VIM_ISDIGIT(curc) && ptr2cells(reginput) == 1;
+ result = !VIM_ISDIGIT(curc) && vim_isprintc(PTR2CHAR(reginput));
ADD_STATE_IF_MATCH(t->state);
break;
diff --git a/src/testdir/test64.in b/src/testdir/test64.in
index ec6107fb1..a946aa450 100644
--- a/src/testdir/test64.in
+++ b/src/testdir/test64.in
@@ -228,6 +228,7 @@ STARTTEST
:call add(tl, [2, '\v((ab)|c*)+', 'abcccaba', 'abcccab', '', 'ab'])
:call add(tl, [2, '\v(a(c*)+b)+', 'acbababaaa', 'acbabab', 'ab', ''])
:call add(tl, [2, '\v(a|b*)+', 'aaaa', 'aaaa', ''])
+:call add(tl, [2, '\p*', 'aá ', 'aá '])
:"
:" Test greedy-ness and lazy-ness
:call add(tl, [2, 'a\{-2,7}','aaaaaaaaaaaaa', 'aa'])
diff --git a/src/testdir/test64.ok b/src/testdir/test64.ok
index 4203c8f39..efcf8dd50 100644
--- a/src/testdir/test64.ok
+++ b/src/testdir/test64.ok
@@ -506,6 +506,9 @@ OK 2 - \v(a(c*)+b)+
OK 0 - \v(a|b*)+
OK 1 - \v(a|b*)+
OK 2 - \v(a|b*)+
+OK 0 - \p*
+OK 1 - \p*
+OK 2 - \p*
OK 0 - a\{-2,7}
OK 1 - a\{-2,7}
OK 2 - a\{-2,7}
diff --git a/src/testdir/test95.in b/src/testdir/test95.in
index 306c1b4f9..90fa69945 100644
--- a/src/testdir/test95.in
+++ b/src/testdir/test95.in
@@ -29,6 +29,7 @@ STARTTEST
:" this is not a normal "i" but 0xec
:call add(tl, [2, '\p\+', 'ìa', 'ìa'])
+:call add(tl, [2, '\p*', 'aあ', 'aあ'])
:"""" Test recognition of some character classes
:call add(tl, [2, '\i\+', '&*¨xx ', 'xx'])
@@ -118,6 +119,16 @@ STARTTEST
:endfor
:unlet t tl e l
+:" check that 'ambiwidth' does not change the meaning of \p
+:set regexpengine=1 ambiwidth=single
+:$put ='eng 1 ambi single: ' . match(\"\u00EC\", '\p')
+:set regexpengine=1 ambiwidth=double
+:$put ='eng 1 ambi double: ' . match(\"\u00EC\", '\p')
+:set regexpengine=2 ambiwidth=single
+:$put ='eng 2 ambi single: ' . match(\"\u00EC\", '\p')
+:set regexpengine=2 ambiwidth=double
+:$put ='eng 2 ambi double: ' . match(\"\u00EC\", '\p')
+
:/\%#=1^Results/,$wq! test.out
ENDTEST
diff --git a/src/testdir/test95.ok b/src/testdir/test95.ok
index b9cdd2e18..c378221a7 100644
--- a/src/testdir/test95.ok
+++ b/src/testdir/test95.ok
@@ -17,6 +17,9 @@ OK 2 - [ม[:alpha:][=a=]]\+
OK 0 - \p\+
OK 1 - \p\+
OK 2 - \p\+
+OK 0 - \p*
+OK 1 - \p*
+OK 2 - \p*
OK 0 - \i\+
OK 1 - \i\+
OK 2 - \i\+
@@ -113,3 +116,7 @@ OK 2 - \Zֹ\+
OK 0 - [^[=a=]]\+
OK 1 - [^[=a=]]\+
OK 2 - [^[=a=]]\+
+eng 1 ambi single: 0
+eng 1 ambi double: 0
+eng 2 ambi single: 0
+eng 2 ambi double: 0
diff --git a/src/version.c b/src/version.c
index 04f05b038..b22b9749c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -728,6 +728,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 36,
+/**/
35,
/**/
34,