Patch 8.2.3552
Problem: Xxd revert does not handle end of line correctly.
Solution: Check for newline first. (closes #9034)
Files: src/xxd/xxd.c, src/testdir/test_xxd.vim
*** ../vim-8.2.3551/src/xxd/xxd.c 2021-10-18 13:15:59.845862991 +0100
--- src/xxd/xxd.c 2021-10-22 12:40:30.257104160 +0100
***************
*** 131,137 ****
extern long int strtol();
extern long int ftell();
! char version[] = "xxd 2020-02-04 by Juergen Weigert et al.";
#ifdef WIN32
char osver[] = " (Win32)";
#else
--- 131,137 ----
extern long int strtol();
extern long int ftell();
! char version[] = "xxd 2021-10-22 by Juergen Weigert et al.";
#ifdef WIN32
char osver[] = " (Win32)";
#else
***************
*** 318,325 ****
if (fflush(fpo) != 0)
die(3);
#ifdef TRY_SEEK
! c = fseek(fpo, base_off + want_off - have_off, 1);
! if (c >= 0)
have_off = base_off + want_off;
#endif
if (base_off + want_off < have_off)
--- 318,324 ----
if (fflush(fpo) != 0)
die(3);
#ifdef TRY_SEEK
! if (fseek(fpo, base_off + want_off - have_off, 1) >= 0)
have_off = base_off + want_off;
#endif
if (base_off + want_off < have_off)
***************
*** 349,360 ****
if (n1 < 0 && n2 < 0 && n3 < 0)
{
/* already stumbled into garbage, skip line, wait and see */
! if (!hextype)
! want_off = 0;
! while ((c = getc(fpi)) != '\n' && c != EOF)
! ;
if (c == EOF && ferror(fpi))
die(2);
ign_garb = 1;
}
}
--- 348,363 ----
if (n1 < 0 && n2 < 0 && n3 < 0)
{
/* already stumbled into garbage, skip line, wait and see */
! while (c != '\n' && c != EOF)
! c = getc(fpi);
if (c == EOF && ferror(fpi))
die(2);
+ }
+ if (c == '\n')
+ {
+ if (!hextype)
+ want_off = 0;
+ p = cols;
ign_garb = 1;
}
}
*** ../vim-8.2.3551/src/testdir/test_xxd.vim 2021-06-29 19:36:17.257832714
+0100
--- src/testdir/test_xxd.vim 2021-10-22 12:53:06.439844741 +0100
***************
*** 213,218 ****
--- 213,251 ----
call delete('XXDfile')
endfunc
+ func Test_xxd_patch()
+ let cmd = 'silent !' .. s:xxd_cmd .. ' -r Xxxdin Xxxdfile; ' .. s:xxd_cmd
.. ' -g1 Xxxdfile > Xxxdout'
+ call writefile(["2: 41 41", "8: 42 42"], 'Xxxdin')
+ call writefile(['::::::::'], 'Xxxdfile')
+ exe cmd
+ call assert_equal(['00000000: 3a 3a 41 41 3a 3a 3a 3a 42 42
::AA::::BB'], readfile('Xxxdout'))
+
+ call writefile(["2: 43 43 ", "8: 44 44"], 'Xxxdin')
+ exe cmd
+ call assert_equal(['00000000: 3a 3a 43 43 3a 3a 3a 3a 44 44
::CC::::DD'], readfile('Xxxdout'))
+
+ call writefile(["2: 45 45 ", "8: 46 46"], 'Xxxdin')
+ exe cmd
+ call assert_equal(['00000000: 3a 3a 45 45 3a 3a 3a 3a 46 46
::EE::::FF'], readfile('Xxxdout'))
+
+ call writefile(["2: 41 41", "08: 42 42"], 'Xxxdin')
+ call writefile(['::::::::'], 'Xxxdfile')
+ exe cmd
+ call assert_equal(['00000000: 3a 3a 41 41 3a 3a 3a 3a 42 42
::AA::::BB'], readfile('Xxxdout'))
+
+ call writefile(["2: 43 43 ", "09: 44 44"], 'Xxxdin')
+ exe cmd
+ call assert_equal(['00000000: 3a 3a 43 43 3a 3a 3a 3a 42 44 44
::CC::::BDD'], readfile('Xxxdout'))
+
+ call writefile(["2: 45 45 ", "0a: 46 46"], 'Xxxdin')
+ exe cmd
+ call assert_equal(['00000000: 3a 3a 45 45 3a 3a 3a 3a 42 44 46 46
::EE::::BDFF'], readfile('Xxxdout'))
+
+ call delete('Xxxdin')
+ call delete('Xxxdfile')
+ call delete('Xxxdout')
+ 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']
*** ../vim-8.2.3551/src/version.c 2021-10-21 18:01:10.101023157 +0100
--- src/version.c 2021-10-22 12:54:51.905306608 +0100
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3552,
/**/
--
A scientist is someone who knows exactly how an engine works, but
can't fix his car when it fails to start.
An engineer is someone who knows only some things about an engine, but
can fix his car when it's broken.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20211022115618.3470BC80053%40moolenaar.net.