summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0821
blob: 83133c837632eba49fe7aeb81f05dd355cf5dcf3 (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0821
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.0821
Problem:    Xxd "usage" output and other arguments not tested.
Solution:   Add a test to trigger the usage output in various ways.  Fix
            uncovered problem.
Files:	    src/testdir/test_xxd.vim, src/xxd/xxd.c


*** ../vim-8.1.0820/src/testdir/test_xxd.vim	2019-01-09 23:00:58.001176090 +0100
--- src/testdir/test_xxd.vim	2019-01-25 21:49:26.831963075 +0100
***************
*** 20,26 ****
  func Test_xxd()
    call PrepareBuffer(range(1,30))
    set ff=unix
!   w XXDfile
  
    " Test 1: simple, filter the result through xxd
    let s:test = 1
--- 20,26 ----
  func Test_xxd()
    call PrepareBuffer(range(1,30))
    set ff=unix
!   w! XXDfile
  
    " Test 1: simple, filter the result through xxd
    let s:test = 1
***************
*** 39,53 ****
    exe '%!' . s:xxd_cmd . ' -r'
    call assert_equal(map(range(1,30), {v,c -> string(c)}), getline(1,'$'), s:Mess(s:test))
  
!   " Test 3: Skip the first 30 bytes
    let s:test += 1
!   exe '%!' . s:xxd_cmd . ' -s 0x30 %'
!   call assert_equal(expected[3:], getline(1,'$'), s:Mess(s:test))
  
    " Test 4: Skip the first 30 bytes
    let s:test += 1
!   exe '%!' . s:xxd_cmd . ' -s -0x31 %'
!   call assert_equal(expected[2:], getline(1,'$'), s:Mess(s:test))
  
    " Test 5: Print 120 bytes as continuous hexdump with 20 octets per line
    let s:test += 1
--- 39,57 ----
    exe '%!' . s:xxd_cmd . ' -r'
    call assert_equal(map(range(1,30), {v,c -> string(c)}), getline(1,'$'), s:Mess(s:test))
  
!   " Test 3: Skip the first 0x30 bytes
    let s:test += 1
!   for arg in ['-s 0x30', '-s0x30', '-s+0x30', '-skip 0x030', '-seek 0x30', '-seek +0x30 --']
!     exe '%!' . s:xxd_cmd . ' ' . arg . ' %'
!     call assert_equal(expected[3:], getline(1,'$'), s:Mess(s:test))
!   endfor
  
    " Test 4: Skip the first 30 bytes
    let s:test += 1
!   for arg in ['-s -0x31', '-s-0x31']
!     exe '%!' . s:xxd_cmd . ' ' . arg . ' %'
!     call assert_equal(expected[2:], getline(1,'$'), s:Mess(s:test))
!   endfor
  
    " Test 5: Print 120 bytes as continuous hexdump with 20 octets per line
    let s:test += 1
***************
*** 56,62 ****
    if has('win32') && !filereadable(fname)
      let fname = '../../doc/xxd.1'
    endif
!   exe '0r! ' . s:xxd_cmd . ' -l 120 -ps -c 20 ' . fname
    $d
    let expected = [
        \ '2e54482058584420312022417567757374203139',
--- 60,66 ----
    if has('win32') && !filereadable(fname)
      let fname = '../../doc/xxd.1'
    endif
!   exe '0r! ' . s:xxd_cmd . ' -l 120 -ps -c20 ' . fname
    $d
    let expected = [
        \ '2e54482058584420312022417567757374203139',
***************
*** 69,78 ****
  
    " Test 6: Print the date from xxd.1
    let s:test += 1
!   %d
!   exe '0r! ' . s:xxd_cmd . ' -s 0x36 -l 13 -c 13 ' . fname
!   $d
!   call assert_equal('00000036: 3231 7374 204d 6179 2031 3939 36  21st May 1996', getline(1), s:Mess(s:test))
  
    " Test 7: Print C include
    let s:test += 1
--- 73,84 ----
  
    " Test 6: Print the date from xxd.1
    let s:test += 1
!   for arg in ['-l 13', '-l13', '-len 13']
!     %d
!     exe '0r! ' . s:xxd_cmd . ' -s 0x36 -l 13 -cols 13 ' . fname
!     $d
!     call assert_equal('00000036: 3231 7374 204d 6179 2031 3939 36  21st May 1996', getline(1), s:Mess(s:test))
!   endfor
  
    " Test 7: Print C include
    let s:test += 1
***************
*** 87,100 ****
  
    " Test 8: Print C include capitalized
    let s:test += 1
!   call writefile(['TESTabcd09'], 'XXDfile')
!   %d
!   exe '0r! ' . s:xxd_cmd . ' -i -C XXDfile'
!   $d
!   let expected = ['unsigned char XXDFILE[] = {',
!         \ '  0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};',
!         \ 'unsigned int XXDFILE_LEN = 11;']
!   call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
  
    " Test 9: Create a file with containing a single 'A'
    let s:test += 1
--- 93,108 ----
  
    " Test 8: Print C include capitalized
    let s:test += 1
!   for arg in ['-C', '-capitalize']
!     call writefile(['TESTabcd09'], 'XXDfile')
!     %d
!     exe '0r! ' . s:xxd_cmd . ' -i ' . arg . ' XXDfile'
!     $d
!     let expected = ['unsigned char XXDFILE[] = {',
! 	  \ '  0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};',
! 	  \ 'unsigned int XXDFILE_LEN = 11;']
!     call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
!   endfor
  
    " Test 9: Create a file with containing a single 'A'
    let s:test += 1
***************
*** 110,115 ****
--- 118,156 ----
    call PrepareBuffer(readfile('XXDfile')[0])
    call assert_equal('A', getline(1), s:Mess(s:test))
    call delete('XXDfile')
+ 
+   " Test 10: group with 4 octets
+   let s:test += 1
+   for arg in ['-g 4', '-group 4', '-g4']
+     call writefile(['TESTabcd09'], 'XXDfile')
+     %d
+     exe '0r! ' . s:xxd_cmd . ' ' . arg . ' XXDfile'
+     $d
+     let expected = ['00000000: 54455354 61626364 30390a             TESTabcd09.']
+     call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
+     call delete('XXDfile')
+   endfor
+ 
+   " TODO:
+   " -o -offset
+ 
    %d
    bw!
  endfunc
+ 
+ " Various ways with wrong arguments that trigger the usage output.
+ func Test_xxd_usage()
+   for arg in ['-c', '-g', '-o', '-s', '-l', '-X', 'one two three']
+     new
+     exe 'r! ' . s:xxd_cmd . ' ' . arg
+     call assert_match("Usage:", join(getline(1, 3)))
+     bwipe!
+   endfor
+ endfunc
+ 
+ func Test_xxd_version()
+   new
+   exe 'r! ' . s:xxd_cmd . ' -v'
+   call assert_match("xxd V1.10 .* by Juergen Weigert", join(getline(1, 3)))
+   bwipe!
+ endfunc
*** ../vim-8.1.0820/src/xxd/xxd.c	2018-04-03 14:11:10.000000000 +0200
--- src/xxd/xxd.c	2019-01-25 21:46:21.129278533 +0100
***************
*** 508,517 ****
  	}
        else if (!STRNCMP(pp, "-c", 2))
  	{
! 	  if (pp[2] && STRNCMP("ols", pp + 2, 3))
! 	    cols = (int)strtol(pp + 2, NULL, 0);
! 	  else if (pp[2] && STRNCMP("apitalize", pp + 2, 9))
  	    capitalize = 1;
  	  else
  	    {
  	      if (!argv[2])
--- 508,517 ----
  	}
        else if (!STRNCMP(pp, "-c", 2))
  	{
! 	  if (pp[2] && !STRNCMP("apitalize", pp + 2, 9))
  	    capitalize = 1;
+ 	  else if (pp[2] && STRNCMP("ols", pp + 2, 3))
+ 	    cols = (int)strtol(pp + 2, NULL, 0);
  	  else
  	    {
  	      if (!argv[2])
***************
*** 523,529 ****
  	}
        else if (!STRNCMP(pp, "-g", 2))
  	{
! 	  if (pp[2] && STRNCMP("group", pp + 2, 5))
  	    octspergrp = (int)strtol(pp + 2, NULL, 0);
  	  else
  	    {
--- 523,529 ----
  	}
        else if (!STRNCMP(pp, "-g", 2))
  	{
! 	  if (pp[2] && STRNCMP("roup", pp + 2, 4))
  	    octspergrp = (int)strtol(pp + 2, NULL, 0);
  	  else
  	    {
*** ../vim-8.1.0820/src/version.c	2019-01-25 21:01:13.240877414 +0100
--- src/version.c	2019-01-25 21:51:57.926996288 +0100
***************
*** 789,790 ****
--- 789,792 ----
  {   /* Add new patch number below this line */
+ /**/
+     821,
  /**/

-- 
FATHER:    Who are you?
PRINCE:    I'm ... your son ...
FATHER:    Not you.
LAUNCELOT: I'm ... er ... Sir Launcelot, sir.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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    ///