summaryrefslogtreecommitdiff
path: root/runtime/autoload/gzip.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload/gzip.vim')
-rw-r--r--runtime/autoload/gzip.vim30
1 files changed, 21 insertions, 9 deletions
diff --git a/runtime/autoload/gzip.vim b/runtime/autoload/gzip.vim
index f7c97a6d4..1ad29eaaa 100644
--- a/runtime/autoload/gzip.vim
+++ b/runtime/autoload/gzip.vim
@@ -1,6 +1,6 @@
" Vim autoload file for editing compressed files.
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2007 May 10
+" Last Change: 2008 May 29
" These functions are used by the gzip plugin.
@@ -73,8 +73,15 @@ fun gzip#read(cmd)
let empty = line("'[") == 1 && line("']") == line("$")
let tmp = tempname()
let tmpe = tmp . "." . expand("<afile>:e")
+ if exists('*fnameescape')
+ let tmp_esc = fnameescape(tmp)
+ let tmpe_esc = fnameescape(tmpe)
+ else
+ let tmp_esc = escape(tmp, ' ')
+ let tmpe_esc = escape(tmpe, ' ')
+ endif
" write the just read lines to a temp file "'[,']w tmp.gz"
- execute "silent '[,']w " . escape(tmpe, ' ')
+ execute "silent '[,']w " . tmpe_esc
" uncompress the temp file: call system("gzip -dn tmp.gz")
call system(a:cmd . " " . s:escape(tmpe))
if !filereadable(tmp)
@@ -95,12 +102,12 @@ fun gzip#read(cmd)
setlocal nobin
if exists(":lockmarks")
if empty
- execute "silent lockmarks " . l . "r ++edit " . tmp
+ execute "silent lockmarks " . l . "r ++edit " . tmp_esc
else
- execute "silent lockmarks " . l . "r " . tmp
+ execute "silent lockmarks " . l . "r " . tmp_esc
endif
else
- execute "silent " . l . "r " . tmp
+ execute "silent " . l . "r " . tmp_esc
endif
" if buffer became empty, delete trailing blank line
@@ -110,8 +117,8 @@ fun gzip#read(cmd)
endif
" delete the temp file and the used buffers
call delete(tmp)
- silent! exe "bwipe " . tmp
- silent! exe "bwipe " . tmpe
+ silent! exe "bwipe " . tmp_esc
+ silent! exe "bwipe " . tmpe_esc
endif
" Restore saved option values.
@@ -124,10 +131,15 @@ fun gzip#read(cmd)
" When uncompressed the whole buffer, do autocommands
if ok && empty
+ if exists('*fnameescape')
+ let fname = fnameescape(expand("%:r"))
+ else
+ let fname = escape(expand("%:r"), " \t\n*?[{`$\\%#'\"|!<")
+ endif
if &verbose >= 8
- execute "doau BufReadPost " . expand("%:r")
+ execute "doau BufReadPost " . fname
else
- execute "silent! doau BufReadPost " . expand("%:r")
+ execute "silent! doau BufReadPost " . fname
endif
endif
endfun