runtime/doc/xxd.1 |   5 +++++
 src/xxd/xxd.c     |  20 +++++++++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)


# HG changeset patch
# User Vadim Vygonets <[email protected]>
# Date 1384858930 -3600
# Node ID f5e9ce53c1d8e9cfb73fdf3932681262e6be6707
# Parent  e5b9ff009e25d661ad1f71bba70c3f7ac71d2e80
xxd: Add -o: add offset to displayed position

diff -r e5b9ff009e25 -r f5e9ce53c1d8 runtime/doc/xxd.1
--- a/runtime/doc/xxd.1 Tue Nov 19 12:01:25 2013 +0100
+++ b/runtime/doc/xxd.1 Tue Nov 19 12:02:10 2013 +0100
@@ -109,6 +109,11 @@
 .RI  < len >
 octets.
 .TP
+.I \-o offset
+add
+.RI < offset >
+to the displayed file position.
+.TP
 .IR \-p " | " \-ps " | " \-postscript " | " \-plain
 output in postscript continuous hexdump style. Also known as plain hexdump
 style.
diff -r e5b9ff009e25 -r f5e9ce53c1d8 src/xxd/xxd.c
--- a/src/xxd/xxd.c     Tue Nov 19 12:01:25 2013 +0100
+++ b/src/xxd/xxd.c     Tue Nov 19 12:02:10 2013 +0100
@@ -51,7 +51,7 @@
  * 16.05.00 Improved MMS file and merge for VMS by Zoltan Arpadffy
  * 2011 March  Better error handling by Florian Zumbiehl.
  * 2011 April  Formatting by Bram Moolenaar
- * 08.06.2013  Little-endian hexdump (-e) by Vadim Vygonets.
+ * 08.06.2013  Little-endian hexdump (-e) and offset (-o) by Vadim Vygonets.
  *
  * (c) 1990-1998 by Juergen Weigert ([email protected])
  *
@@ -245,6 +245,7 @@
   fprintf(stderr, "    -h          print this summary.\n");
   fprintf(stderr, "    -i          output in C include file style.\n");
   fprintf(stderr, "    -l len      stop after <len> octets.\n");
+  fprintf(stderr, "    -o off      add <off> to the displayed file 
position.\n");
   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");
@@ -478,7 +479,7 @@
   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;
+  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;
 
@@ -543,6 +544,19 @@
              argc--;
            }
        }
+      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--;
+           }
+       }
       else if (!STRNCMP(pp, "-s", 2))
        {
          relseek = 0;
@@ -806,7 +820,7 @@
     {
       if (p == 0)
        {
-         sprintf(l, "%07lx: ", n + seekoff);
+         sprintf(l, "%07lx: ", n + seekoff + displayoff);
          for (c = 9; c < LLEN; l[c++] = ' ');
        }
       if (hextype == HEX_NORMAL)

-- 
-- 
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/groups/opt_out.

Raspunde prin e-mail lui