fix findtoken. it occur maxmempattern error.

This commit is contained in:
mattn
2012-05-28 09:23:16 +09:00
parent 33b90dcaf1
commit 08666e545d
2 changed files with 15 additions and 8 deletions

View File

@@ -1,23 +1,24 @@
"let s:mx = '\([+>]\|<\+\)\{-}\((*\)\{-}\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|'
let s:mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|' let s:mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|'
\ .'{.\{-}}[ \t\r\n}]*\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|' \ .'{.\{-}}[ \t\r\n}]*\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|'
\ .'#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|' \ .'#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|'
\ .'\%(\.{[{}a-zA-Z0-9_\-\$]\+\|' \ .'\%(\.{[{}a-zA-Z0-9_\-\$]\+\|'
\ .'\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\+\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)' \ .'\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\+\)\)\{0,1}\%(\*\([0-9]\+\)\)\{0,1}\(\%()\%(\*[0-9]\+\)\{0,1}\)*\)'
function! zencoding#html#findTokens(str) function! zencoding#html#findTokens(str)
let str = a:str let str = a:str
let last_pos = 0
while len(str) > 0 while len(str) > 0
let token = matchstr(str, s:mx.'\s*$') let token = matchstr(str, '\s'.s:mx)
if token == '' if token == ''
break break
elseif token =~ '^\s'
let token = substitute(token, '^\s*', '', '')
let str = str[0 : -len(token)-1]
break
endif endif
let str = str[0 : -len(token)-1] if token =~ '^\s'
let last_pos = stridx(str, matchstr(token, '^\s*\zs.*'))
endif
let str = str[stridx(str, token) + len(token):]
endwhile endwhile
return a:str[len(str) :-1] return a:str[last_pos :-1]
endfunction endfunction
function! zencoding#html#parseIntoTree(abbr, type) function! zencoding#html#parseIntoTree(abbr, type)

View File

@@ -529,6 +529,12 @@ finish
'type': "html", 'type': "html",
'result': "foo <p>bar baz</p>", 'result': "foo <p>bar baz</p>",
}, },
{
'name': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$",
'query': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$",
'type': "html",
'result': "f <div class=\"boxes\">\n\t<article class=\"box2\">\n\t\t<header>\n\t\t\t<hgroup>\n\t\t\t\t<h2>aaa</h2>\n\t\t\t\t<h3>bbb</h3>\n\t\t\t</hgroup>\n\t\t\t<p>ccc</p>\n\t\t</header>\n\t</article>\n</div>",
},
], ],
}, },
{ {