Patch 8.2.0854
Problem:    Xxd cannot show offset as a decimal number.
Solution:   Add the "-d" flag. (Aapo Rantalainen, closes #5616
Files:      src/testdir/test_xxd.vim, src/xxd/xxd.c


*** ../vim-8.2.0853/src/testdir/test_xxd.vim    2019-06-24 00:46:28.000000000 
+0200
--- src/testdir/test_xxd.vim    2020-05-30 20:46:43.209259281 +0200
***************
*** 165,170 ****
--- 165,209 ----
    call delete('Xinput')
    call delete('XXDfile')
  
+   " Test 13: simple, decimal offset
+   call PrepareBuffer(range(1,30))
+   set ff=unix
+   w! XXDfile
+   let s:test += 1
+   exe '%!' . s:xxd_cmd . ' -d %'
+   let expected = [
+         \ '00000000: 310a 320a 330a 340a 350a 360a 370a 380a  
1.2.3.4.5.6.7.8.',
+         \ '00000016: 390a 3130 0a31 310a 3132 0a31 330a 3134  
9.10.11.12.13.14',
+         \ '00000032: 0a31 350a 3136 0a31 370a 3138 0a31 390a  
.15.16.17.18.19.',
+         \ '00000048: 3230 0a32 310a 3232 0a32 330a 3234 0a32  
20.21.22.23.24.2',
+         \ '00000064: 350a 3236 0a32 370a 3238 0a32 390a 3330  
5.26.27.28.29.30',
+         \ '00000080: 0a                                       .']
+   call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
+ 
+   " Test 14: grouping with -d
+   let s:test += 1
+   let expected = [
+         \ '00000000: 310a320a 330a340a 350a360a 370a380a  1.2.3.4.5.6.7.8.',
+         \ '00000016: 390a3130 0a31310a 31320a31 330a3134  9.10.11.12.13.14',
+         \ '00000032: 0a31350a 31360a31 370a3138 0a31390a  .15.16.17.18.19.',
+         \ '00000048: 32300a32 310a3232 0a32330a 32340a32  20.21.22.23.24.2',
+         \ '00000064: 350a3236 0a32370a 32380a32 390a3330  5.26.27.28.29.30',
+         \ '00000080: 0a                                   .']
+   for arg in ['-g 4', '-group 4', '-g4']
+     exe '%!' . s:xxd_cmd . ' ' . arg . ' -d %'
+     call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
+   endfor
+ 
+   " Test 15: cols with decimal offset: -c 21 -d
+   let s:test += 1
+   let expected = [
+         \ '00000000: 310a 320a 330a 340a 350a 360a 370a 380a 390a 3130 0a  
1.2.3.4.5.6.7.8.9.10.',
+         \ '00000021: 3131 0a31 320a 3133 0a31 340a 3135 0a31 360a 3137 0a  
11.12.13.14.15.16.17.',
+         \ '00000042: 3138 0a31 390a 3230 0a32 310a 3232 0a32 330a 3234 0a  
18.19.20.21.22.23.24.',
+         \ '00000063: 3235 0a32 360a 3237 0a32 380a 3239 0a33 300a          
25.26.27.28.29.30.']
+   exe '%!' . s:xxd_cmd . ' -c 21 -d %'
+   call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
+ 
    " TODO:
    " -o -offset
  
*** ../vim-8.2.0853/src/xxd/xxd.c       2020-01-26 21:59:25.632718110 +0100
--- src/xxd/xxd.c       2020-05-30 20:49:59.204698423 +0200
***************
*** 53,58 ****
--- 53,59 ----
   * 2011 April  Formatting by Bram Moolenaar
   * 08.06.2013  Little-endian hexdump (-e) and offset (-o) by Vadim Vygonets.
   * 11.01.2019  Add full 64/32 bit range to -o and output by Christer Jensen.
+  * 04.02.2020  Add -d for decimal offsets by Aapo Rantalainen
   *
   * (c) 1990-1998 by Juergen Weigert ([email protected])
   *
***************
*** 235,240 ****
--- 236,242 ----
    fprintf(stderr, "    -ps         output in postscript plain hexdump 
style.\n");
    fprintf(stderr, "    -r          reverse operation: convert (or patch) 
hexdump into binary.\n");
    fprintf(stderr, "    -r -s off   revert with <off> added to file positions 
found in hexdump.\n");
+   fprintf(stderr, "    -d          show offset in decimal instead of hex.\n");
    fprintf(stderr, "    -s %sseek  start at <seek> bytes abs. %sinfile 
offset.\n",
  #ifdef TRY_SEEK
          "[+][-]", "(or +: rel.) ");
***************
*** 458,464 ****
  {
    FILE *fp, *fpo;
    int c, e, p = 0, relseek = 1, negseek = 0, revert = 0;
!   int cols = 0, nonzero = 0, autoskip = 0, hextype = HEX_NORMAL, capitalize = 
0;
    int ebcdic = 0;
    int octspergrp = -1;        /* number of octets grouped in output */
    int grplen;         /* total chars per octet group */
--- 460,467 ----
  {
    FILE *fp, *fpo;
    int c, e, p = 0, relseek = 1, negseek = 0, revert = 0;
!   int cols = 0, nonzero = 0, autoskip = 0, hextype = HEX_NORMAL;
!   int capitalize = 0, decimal_offset = 0;
    int ebcdic = 0;
    int octspergrp = -1;        /* number of octets grouped in output */
    int grplen;         /* total chars per octet group */
***************
*** 497,502 ****
--- 500,506 ----
        else if (!STRNCMP(pp, "-p", 2)) hextype = HEX_POSTSCRIPT;
        else if (!STRNCMP(pp, "-i", 2)) hextype = HEX_CINCLUDE;
        else if (!STRNCMP(pp, "-C", 2)) capitalize = 1;
+       else if (!STRNCMP(pp, "-d", 2)) decimal_offset = 1;
        else if (!STRNCMP(pp, "-r", 2)) revert++;
        else if (!STRNCMP(pp, "-E", 2)) ebcdic++;
        else if (!STRNCMP(pp, "-v", 2))
***************
*** 820,827 ****
      {
        if (p == 0)
        {
!         addrlen = sprintf(l, "%08lx:",
!           ((unsigned long)(n + seekoff + displayoff)));
          for (c = addrlen; c < LLEN; l[c++] = ' ');
        }
        if (hextype == HEX_NORMAL)
--- 824,835 ----
      {
        if (p == 0)
        {
!         if (decimal_offset)
!               addrlen = sprintf(l, "%08ld:",
!                                 ((unsigned long)(n + seekoff + displayoff)));
!         else
!               addrlen = sprintf(l, "%08lx:",
!                                 ((unsigned long)(n + seekoff + displayoff)));
          for (c = addrlen; c < LLEN; l[c++] = ' ');
        }
        if (hextype == HEX_NORMAL)
*** ../vim-8.2.0853/src/version.c       2020-05-30 20:30:42.900816536 +0200
--- src/version.c       2020-05-30 20:47:05.809198270 +0200
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     854,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
220. Your wife asks for sex and you tell her where to find you on IRC.

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
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/202005301850.04UIoubd430142%40masaka.moolenaar.net.

Raspunde prin e-mail lui