summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0352
blob: 75ff410859e4bfc52a1b4f53702135d1fd0f240f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0352
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0352
Problem:    Browsing compressed tar files does not always work.
Solution:   Use the "file" command to get the compression type.
Files:	    runtime/autoload/tar.vim


*** ../vim-8.1.0351/runtime/autoload/tar.vim	2016-09-25 21:41:24.000000000 +0200
--- runtime/autoload/tar.vim	2018-09-08 15:09:32.841486806 +0200
***************
*** 152,161 ****
     " assuming cygwin
     let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
    endif
    let curlast= line("$")
    if tarfile =~# '\.\(gz\|tgz\)$'
  "   call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
!    exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
    elseif tarfile =~# '\.lrp'
  "   call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
     exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
--- 152,163 ----
     " assuming cygwin
     let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
    endif
+ 
    let curlast= line("$")
    if tarfile =~# '\.\(gz\|tgz\)$'
+     let gzip_command = s:get_gzip_command(tarfile)
  "   call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
!    exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
    elseif tarfile =~# '\.lrp'
  "   call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
     exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
***************
*** 287,298 ****
    else
     let tar_secure= " "
    endif
    if tarfile =~# '\.bz2$'
  "   call Decho("7: exe silent r! bzip2 -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
     exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
    elseif tarfile =~# '\.\(gz\|tgz\)$'
  "   call Decho("5: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.shellescape(fname,1))
!    exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
    elseif tarfile =~# '\.lrp$'
  "   call Decho("6: exe silent r! cat ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
     exe "sil! r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
--- 289,302 ----
    else
     let tar_secure= " "
    endif
+ 
    if tarfile =~# '\.bz2$'
  "   call Decho("7: exe silent r! bzip2 -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
     exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
    elseif tarfile =~# '\.\(gz\|tgz\)$'
+     let gzip_command = s:get_gzip_command(tarfile)
  "   call Decho("5: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.shellescape(fname,1))
!    exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
    elseif tarfile =~# '\.lrp$'
  "   call Decho("6: exe silent r! cat ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
     exe "sil! r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
***************
*** 389,394 ****
--- 393,400 ----
    let tarfile = substitute(b:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
    let fname   = substitute(b:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
  
+   let gzip_command = s:get_gzip_command(tarfile)
+ 
    " handle compressed archives
    if tarfile =~# '\.bz2'
     call system("bzip2 -d -- ".shellescape(tarfile,0))
***************
*** 396,407 ****
     let compress= "bzip2 -- ".shellescape(tarfile,0)
  "   call Decho("compress<".compress.">")
    elseif tarfile =~# '\.gz'
!    call system("gzip -d -- ".shellescape(tarfile,0))
     let tarfile = substitute(tarfile,'\.gz','','e')
     let compress= "gzip -- ".shellescape(tarfile,0)
  "   call Decho("compress<".compress.">")
    elseif tarfile =~# '\.tgz'
!    call system("gzip -d -- ".shellescape(tarfile,0))
     let tarfile = substitute(tarfile,'\.tgz','.tar','e')
     let compress= "gzip -- ".shellescape(tarfile,0)
     let tgz     = 1
--- 402,413 ----
     let compress= "bzip2 -- ".shellescape(tarfile,0)
  "   call Decho("compress<".compress.">")
    elseif tarfile =~# '\.gz'
!    call system(gzip_command . " -d -- ".shellescape(tarfile,0))
     let tarfile = substitute(tarfile,'\.gz','','e')
     let compress= "gzip -- ".shellescape(tarfile,0)
  "   call Decho("compress<".compress.">")
    elseif tarfile =~# '\.tgz'
!    call system(gzip_command . " -d -- ".shellescape(tarfile,0))
     let tarfile = substitute(tarfile,'\.tgz','.tar','e')
     let compress= "gzip -- ".shellescape(tarfile,0)
     let tgz     = 1
***************
*** 581,587 ****
  
    " if necessary, decompress the tarball; then, extract it
    if tartail =~ '\.tgz'
!    if executable("gunzip")
      silent exe "!gunzip ".shellescape(tartail)
     elseif executable("gzip")
      silent exe "!gzip -d ".shellescape(tartail)
--- 587,596 ----
  
    " if necessary, decompress the tarball; then, extract it
    if tartail =~ '\.tgz'
!    let gzip_command = s:get_gzip_command(tarfile)
!    if executable(gzip_command)
!     silent exe "!" . gzip_command . " -d ".shellescape(tartail)
!    elseif executable("gunzip")
      silent exe "!gunzip ".shellescape(tartail)
     elseif executable("gzip")
      silent exe "!gzip -d ".shellescape(tartail)
***************
*** 619,624 ****
--- 628,655 ----
  "  call Dret("tar#Vimuntar")
  endfun
  
+ func s:get_gzip_command(file)
+   " Try using the "file" command to get the actual compression type, since
+   " there is no standard way for the naming: ".tgz", ".tbz", ".txz", etc.
+   " If the "file" command doesn't work fall back to just using the file name.
+   if a:file =~# 'z$'
+     let filetype = system('file ' . a:file)
+     if filetype =~ 'bzip2 compressed' && executable('bzip2')
+       return 'bzip2'
+     endif
+     if filetype =~ 'XZ compressed' && executable('xz')
+       return 'xz'
+     endif
+   endif
+   if a:file =~# 'bz2$'
+     return 'bzip2'
+   endif
+   if a:file =~# 'xz$'
+     return 'xz'
+   endif
+   return 'gzip'
+ endfunc
+ 
  " =====================================================================
  " Modelines And Restoration: {{{1
  let &cpo= s:keepcpo
*** ../vim-8.1.0351/src/version.c	2018-09-06 21:44:13.660006996 +0200
--- src/version.c	2018-09-08 14:57:29.304425238 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     352,
  /**/

-- 
If Pacman had affected us as kids we'd be running around in dark rooms,
munching pills and listening to repetitive music.
                       -- Marcus Brigstocke

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///