Patch 8.1.0854
Problem:    xxd does not work with more than 32 bit addresses.
Solution:   Add support for 64 bit addresses. (Christer Jensen, closes #3791)
Files:      src/xxd/xxd.c


*** ../vim-8.1.0853/src/xxd/xxd.c       2019-01-25 21:52:12.190931859 +0100
--- src/xxd/xxd.c       2019-01-30 23:00:28.306174236 +0100
***************
*** 52,57 ****
--- 52,58 ----
   * 2011 March  Better error handling by Florian Zumbiehl.
   * 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.
   *
   * (c) 1990-1998 by Juergen Weigert ([email protected])
   *
***************
*** 90,95 ****
--- 91,97 ----
  #include <stdlib.h>
  #include <string.h>   /* for strncmp() */
  #include <ctype.h>    /* for isalnum() */
+ #include <limits.h>
  #if __MWERKS__ && !defined(BEBOX)
  # include <unix.h>    /* for fdopen() on MAC */
  #endif
***************
*** 204,210 ****
  
  #define TRY_SEEK      /* attempt to use lseek, or skip forward by reading */
  #define COLS 256      /* change here, if you ever need more columns */
! #define LLEN (12 + (9*COLS-1) + COLS + 2)
  
  char hexxa[] = "0123456789abcdef0123456789ABCDEF", *hexx = hexxa;
  
--- 206,212 ----
  
  #define TRY_SEEK      /* attempt to use lseek, or skip forward by reading */
  #define COLS 256      /* change here, if you ever need more columns */
! #define LLEN ((2*(int)sizeof(unsigned long)) + 4 + (9*COLS-1) + COLS + 2)
  
  char hexxa[] = "0123456789abcdef0123456789ABCDEF", *hexx = hexxa;
  
***************
*** 466,472 ****
    int ebcdic = 0;
    int octspergrp = -1;        /* number of octets grouped in output */
    int grplen;         /* total chars per octet group */
!   long length = -1, n = 0, seekoff = 0, displayoff = 0;
    static char l[LLEN+1];  /* static because it may be too big for stack */
    char *pp;
  
--- 468,475 ----
    int ebcdic = 0;
    int octspergrp = -1;        /* number of octets grouped in output */
    int grplen;         /* total chars per octet group */
!   long length = -1, n = 0, seekoff = 0;
!   unsigned long displayoff = 0;
    static char l[LLEN+1];  /* static because it may be too big for stack */
    char *pp;
  
***************
*** 536,548 ****
        }
        else if (!STRNCMP(pp, "-o", 2))
        {
          if (pp[2] && STRNCMP("ffset", pp + 2, 5))
!           displayoff = (int)strtol(pp + 2, NULL, 0);
          else
            {
              if (!argv[2])
                exit_with_usage();
!             displayoff = (int)strtol(argv[2], NULL, 0);
              argv++;
              argc--;
            }
--- 539,563 ----
        }
        else if (!STRNCMP(pp, "-o", 2))
        {
+         int reloffset = 0;
+         int negoffset = 0;
          if (pp[2] && STRNCMP("ffset", pp + 2, 5))
!           displayoff = strtoul(pp + 2, NULL, 0);
          else
            {
              if (!argv[2])
                exit_with_usage();
! 
!             if (argv[2][0] == '+')
!              reloffset++;
!            if (argv[2][reloffset] == '-')
!              negoffset++;
! 
!            if (negoffset)
!              displayoff = ULONG_MAX - strtoul(argv[2] + reloffset+negoffset, 
NULL, 0) + 1;
!            else
!              displayoff = strtoul(argv[2] + reloffset+negoffset, NULL, 0);
! 
              argv++;
              argc--;
            }
***************
*** 805,835 ****
    else        /* hextype == HEX_BITS */
      grplen = 8 * octspergrp + 1;
  
    e = 0;
    while ((length < 0 || n < length) && (e = getc(fp)) != EOF)
      {
        if (p == 0)
        {
!         sprintf(l, "%08lx:",
!           ((unsigned long)(n + seekoff + displayoff)) & 0xffffffff);
!         for (c = 9; c < LLEN; l[c++] = ' ');
        }
        if (hextype == HEX_NORMAL)
        {
!         l[c = (10 + (grplen * p) / octspergrp)] = hexx[(e >> 4) & 0xf];
          l[++c]                                  = hexx[ e       & 0xf];
        }
        else if (hextype == HEX_LITTLEENDIAN)
        {
          int x = p ^ (octspergrp-1);
!         l[c = (10 + (grplen * x) / octspergrp)] = hexx[(e >> 4) & 0xf];
          l[++c]                                  = hexx[ e       & 0xf];
        }
        else /* hextype == HEX_BITS */
        {
          int i;
  
!         c = (10 + (grplen * p) / octspergrp) - 1;
          for (i = 7; i >= 0; i--)
            l[++c] = (e & (1 << i)) ? '1' : '0';
        }
--- 820,851 ----
    else        /* hextype == HEX_BITS */
      grplen = 8 * octspergrp + 1;
  
+   int addrlen = 9;
    e = 0;
    while ((length < 0 || n < length) && (e = getc(fp)) != EOF)
      {
        if (p == 0)
        {
!         addrlen = sprintf(l, "%08lx:",
!           ((unsigned long)(n + seekoff + displayoff)));
!         for (c = addrlen; c < LLEN; l[c++] = ' ');
        }
        if (hextype == HEX_NORMAL)
        {
!         l[c = (addrlen + 1 + (grplen * p) / octspergrp)] = hexx[(e >> 4) & 
0xf];
          l[++c]                                  = hexx[ e       & 0xf];
        }
        else if (hextype == HEX_LITTLEENDIAN)
        {
          int x = p ^ (octspergrp-1);
!         l[c = (addrlen + 1 + (grplen * x) / octspergrp)] = hexx[(e >> 4) & 
0xf];
          l[++c]                                  = hexx[ e       & 0xf];
        }
        else /* hextype == HEX_BITS */
        {
          int i;
  
!         c = (addrlen + 1 + (grplen * p) / octspergrp) - 1;
          for (i = 7; i >= 0; i--)
            l[++c] = (e & (1 << i)) ? '1' : '0';
        }
***************
*** 838,844 ****
        if (ebcdic)
        e = (e < 64) ? '.' : etoa64[e-64];
        /* When changing this update definition of LLEN above. */
!       l[12 + (grplen * cols - 1)/octspergrp + p] =
  #ifdef __MVS__
          (e >= 64)
  #else
--- 854,860 ----
        if (ebcdic)
        e = (e < 64) ? '.' : etoa64[e-64];
        /* When changing this update definition of LLEN above. */
!       l[addrlen + 3 + (grplen * cols - 1)/octspergrp + p] =
  #ifdef __MVS__
          (e >= 64)
  #else
***************
*** 848,854 ****
        n++;
        if (++p == cols)
        {
!         l[c = (12 + (grplen * cols - 1)/octspergrp + p)] = '\n'; l[++c] = 
'\0';
          xxdline(fpo, l, autoskip ? nonzero : 1);
          nonzero = 0;
          p = 0;
--- 864,870 ----
        n++;
        if (++p == cols)
        {
!         l[c = (addrlen + 3 + (grplen * cols - 1)/octspergrp + p)] = '\n'; 
l[++c] = '\0';
          xxdline(fpo, l, autoskip ? nonzero : 1);
          nonzero = 0;
          p = 0;
***************
*** 858,864 ****
      die(2);
    if (p)
      {
!       l[c = (12 + (grplen * cols - 1)/octspergrp + p)] = '\n'; l[++c] = '\0';
        xxdline(fpo, l, 1);
      }
    else if (autoskip)
--- 874,880 ----
      die(2);
    if (p)
      {
!       l[c = (addrlen + 3 + (grplen * cols - 1)/octspergrp + p)] = '\n'; 
l[++c] = '\0';
        xxdline(fpo, l, 1);
      }
    else if (autoskip)
*** ../vim-8.1.0853/src/version.c       2019-01-30 22:36:14.646981306 +0100
--- src/version.c       2019-01-30 23:01:44.097578546 +0100
***************
*** 785,786 ****
--- 785,788 ----
  {   /* Add new patch number below this line */
+ /**/
+     854,
  /**/

-- 
GUEST:        He's killed the best man!
SECOND GUEST: (holding a limp WOMAN) He's killed my auntie.
FATHER:       No, please!  This is supposed to be a happy occasion!  Let's
              not bicker and argue about who killed who ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui