Hi,
I have hit a difference in behaviour between unix and windows with the
regex comparison operator (7.4p22 on both). Save the following viml
code to a file and do source %. On windows the second function will do
the throw, on unix it doesn't. The first function is a simpler analogy
just to check my sanity with the function logic. (The aim of the second
function is to ensure that a relative path does not go above a parent
directory.)
let s:eg1 = "abc"
func! s:strtest(altstr)
let l:s = s:eg1 . a:altstr
echo l:s . " -- " . s:eg1
if l:s !~ "^" . s:eg1
throw "Danger"
endif
return l:s
endfunc
echo s:strtest('d')
let s:dir1 = getcwd()
func! s:dirtest(subdir)
let l:d = fnamemodify(s:dir1 . "/" . a:subdir, ":p")
echo l:d . " -- " . s:dir1
if l:d !~ "^" . s:dir1
throw "Awooga"
endif
return l:d
endfunc
echo s:dirtest('fred')
Have I missed some subtlety in regexp comparison, windows file handling,
or fnamemodify() behaviour? Should it work on windows and unix? I
tried using !~? in case it was something to do with case insensitive
windows file system, no different. I have also tried escape(..., '\\')
in case it is the back slashes in the file name.
Bashes with a clue stick welcome. If someone has pointers to VIM
internals I am happy to poke around but I have no idea currently where
to start with (well I guess the !~ operator to see what it is seeing).
TIA - TTFN
Mike
--
Old enough to know better, but young enough to not care.
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.