Karsten Hopp fb3e18
To: vim_dev@googlegroups.com
Karsten Hopp fb3e18
Subject: Patch 7.3.152
Karsten Hopp fb3e18
Fcc: outbox
Karsten Hopp fb3e18
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp fb3e18
Mime-Version: 1.0
Karsten Hopp fb3e18
Content-Type: text/plain; charset=UTF-8
Karsten Hopp fb3e18
Content-Transfer-Encoding: 8bit
Karsten Hopp fb3e18
------------
Karsten Hopp fb3e18
Karsten Hopp fb3e18
Patch 7.3.152
Karsten Hopp fb3e18
Problem:    Xxd does not check for errors from library functions.
Karsten Hopp fb3e18
Solution:   Add error checks. (Florian Zumbiehl)
Karsten Hopp fb3e18
Files:	    src/xxd/xxd.c
Karsten Hopp fb3e18
Karsten Hopp fb3e18
Karsten Hopp fb3e18
*** ../vim-7.3.151/src/xxd/xxd.c	2010-08-15 21:57:25.000000000 +0200
Karsten Hopp fb3e18
--- src/xxd/xxd.c	2011-04-01 18:56:11.000000000 +0200
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 49,54 ****
Karsten Hopp fb3e18
--- 49,56 ----
Karsten Hopp fb3e18
   *	    option -b added: 01000101 binary output in normal format.
Karsten Hopp fb3e18
   * 16.05.00 Added VAXC changes by Stephen P. Wall
Karsten Hopp fb3e18
   * 16.05.00 Improved MMS file and merge for VMS by Zoltan Arpadffy
Karsten Hopp fb3e18
+  * 2011 March  Better error handling by Florian Zumbiehl.
Karsten Hopp fb3e18
+  * 2011 April  Formatting by Bram Moolenaar
Karsten Hopp fb3e18
   *
Karsten Hopp fb3e18
   * (c) 1990-1998 by Juergen Weigert (jnweiger@informatik.uni-erlangen.de)
Karsten Hopp fb3e18
   *
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 207,214 ****
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
  /* Let's collect some prototypes */
Karsten Hopp fb3e18
  /* CodeWarrior is really picky about missing prototypes */
Karsten Hopp fb3e18
! static void exit_with_usage __P((char *));
Karsten Hopp fb3e18
! static int huntype __P((FILE *, FILE *, FILE *, char *, int, int, long));
Karsten Hopp fb3e18
  static void xxdline __P((FILE *, char *, int));
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
  #define TRY_SEEK	/* attempt to use lseek, or skip forward by reading */
Karsten Hopp fb3e18
--- 209,216 ----
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
  /* Let's collect some prototypes */
Karsten Hopp fb3e18
  /* CodeWarrior is really picky about missing prototypes */
Karsten Hopp fb3e18
! static void exit_with_usage __P((void));
Karsten Hopp fb3e18
! static int huntype __P((FILE *, FILE *, FILE *, int, int, long));
Karsten Hopp fb3e18
  static void xxdline __P((FILE *, char *, int));
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
  #define TRY_SEEK	/* attempt to use lseek, or skip forward by reading */
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 223,231 ****
Karsten Hopp fb3e18
  #define HEX_CINCLUDE 2
Karsten Hopp fb3e18
  #define HEX_BITS 3		/* not hex a dump, but bits: 01111001 */
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
! static void
Karsten Hopp fb3e18
! exit_with_usage(pname)
Karsten Hopp fb3e18
! char *pname;
Karsten Hopp fb3e18
  {
Karsten Hopp fb3e18
    fprintf(stderr, "Usage:\n       %s [options] [infile [outfile]]\n", pname);
Karsten Hopp fb3e18
    fprintf(stderr, "    or\n       %s -r [-s [-]offset] [-c cols] [-ps] [infile [outfile]]\n", pname);
Karsten Hopp fb3e18
--- 225,234 ----
Karsten Hopp fb3e18
  #define HEX_CINCLUDE 2
Karsten Hopp fb3e18
  #define HEX_BITS 3		/* not hex a dump, but bits: 01111001 */
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
! static char *pname;
Karsten Hopp fb3e18
! 
Karsten Hopp fb3e18
!   static void
Karsten Hopp fb3e18
! exit_with_usage()
Karsten Hopp fb3e18
  {
Karsten Hopp fb3e18
    fprintf(stderr, "Usage:\n       %s [options] [infile [outfile]]\n", pname);
Karsten Hopp fb3e18
    fprintf(stderr, "    or\n       %s -r [-s [-]offset] [-c cols] [-ps] [infile [outfile]]\n", pname);
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 252,257 ****
Karsten Hopp fb3e18
--- 255,269 ----
Karsten Hopp fb3e18
    exit(1);
Karsten Hopp fb3e18
  }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
+   static void
Karsten Hopp fb3e18
+ die(ret)
Karsten Hopp fb3e18
+   int ret;
Karsten Hopp fb3e18
+ {
Karsten Hopp fb3e18
+   fprintf(stderr, "%s: ", pname);
Karsten Hopp fb3e18
+   perror(NULL);
Karsten Hopp fb3e18
+   exit(ret);
Karsten Hopp fb3e18
+ }
Karsten Hopp fb3e18
+ 
Karsten Hopp fb3e18
  /*
Karsten Hopp fb3e18
   * Max. cols binary characters are decoded from the input stream per line.
Karsten Hopp fb3e18
   * Two adjacent garbage characters after evaluated data delimit valid data.
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 259,270 ****
Karsten Hopp fb3e18
   *
Karsten Hopp fb3e18
   * The name is historic and came from 'undo type opt h'.
Karsten Hopp fb3e18
   */
Karsten Hopp fb3e18
! static int
Karsten Hopp fb3e18
! huntype(fpi, fpo, fperr, pname, cols, hextype, base_off)
Karsten Hopp fb3e18
! FILE *fpi, *fpo, *fperr;
Karsten Hopp fb3e18
! char *pname;
Karsten Hopp fb3e18
! int cols, hextype;
Karsten Hopp fb3e18
! long base_off;
Karsten Hopp fb3e18
  {
Karsten Hopp fb3e18
    int c, ign_garb = 1, n1 = -1, n2 = 0, n3, p = cols;
Karsten Hopp fb3e18
    long have_off = 0, want_off = 0;
Karsten Hopp fb3e18
--- 271,281 ----
Karsten Hopp fb3e18
   *
Karsten Hopp fb3e18
   * The name is historic and came from 'undo type opt h'.
Karsten Hopp fb3e18
   */
Karsten Hopp fb3e18
!   static int
Karsten Hopp fb3e18
! huntype(fpi, fpo, fperr, cols, hextype, base_off)
Karsten Hopp fb3e18
!   FILE *fpi, *fpo, *fperr;
Karsten Hopp fb3e18
!   int cols, hextype;
Karsten Hopp fb3e18
!   long base_off;
Karsten Hopp fb3e18
  {
Karsten Hopp fb3e18
    int c, ign_garb = 1, n1 = -1, n2 = 0, n3, p = cols;
Karsten Hopp fb3e18
    long have_off = 0, want_off = 0;
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 318,324 ****
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        if (base_off + want_off != have_off)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  fflush(fpo);
Karsten Hopp fb3e18
  #ifdef TRY_SEEK
Karsten Hopp fb3e18
  	  c = fseek(fpo, base_off + want_off - have_off, 1);
Karsten Hopp fb3e18
  	  if (c >= 0)
Karsten Hopp fb3e18
--- 329,336 ----
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        if (base_off + want_off != have_off)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  if (fflush(fpo) != 0)
Karsten Hopp fb3e18
! 	    die(3);
Karsten Hopp fb3e18
  #ifdef TRY_SEEK
Karsten Hopp fb3e18
  	  c = fseek(fpo, base_off + want_off - have_off, 1);
Karsten Hopp fb3e18
  	  if (c >= 0)
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 330,341 ****
Karsten Hopp fb3e18
  	      return 5;
Karsten Hopp fb3e18
  	    }
Karsten Hopp fb3e18
  	  for (; have_off < base_off + want_off; have_off++)
Karsten Hopp fb3e18
! 	    putc(0, fpo);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        if (n2 >= 0 && n1 >= 0)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  putc((n2 << 4) | n1, fpo);
Karsten Hopp fb3e18
  	  have_off++;
Karsten Hopp fb3e18
  	  want_off++;
Karsten Hopp fb3e18
  	  n1 = -1;
Karsten Hopp fb3e18
--- 342,355 ----
Karsten Hopp fb3e18
  	      return 5;
Karsten Hopp fb3e18
  	    }
Karsten Hopp fb3e18
  	  for (; have_off < base_off + want_off; have_off++)
Karsten Hopp fb3e18
! 	    if (putc(0, fpo) == EOF)
Karsten Hopp fb3e18
! 	      die(3);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        if (n2 >= 0 && n1 >= 0)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  if (putc((n2 << 4) | n1, fpo) == EOF)
Karsten Hopp fb3e18
! 	    die(3);
Karsten Hopp fb3e18
  	  have_off++;
Karsten Hopp fb3e18
  	  want_off++;
Karsten Hopp fb3e18
  	  n1 = -1;
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 345,350 ****
Karsten Hopp fb3e18
--- 359,366 ----
Karsten Hopp fb3e18
  	      want_off = 0;
Karsten Hopp fb3e18
  	      while ((c = getc(fpi)) != '\n' && c != EOF)
Karsten Hopp fb3e18
  		;
Karsten Hopp fb3e18
+ 	      if (c == EOF && ferror(fpi))
Karsten Hopp fb3e18
+ 		die(2);
Karsten Hopp fb3e18
  	      ign_garb = 1;
Karsten Hopp fb3e18
  	    }
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 355,369 ****
Karsten Hopp fb3e18
  	    want_off = 0;
Karsten Hopp fb3e18
  	  while ((c = getc(fpi)) != '\n' && c != EOF)
Karsten Hopp fb3e18
  	    ;
Karsten Hopp fb3e18
  	  ign_garb = 1;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
!   fflush(fpo);
Karsten Hopp fb3e18
  #ifdef TRY_SEEK
Karsten Hopp fb3e18
    fseek(fpo, 0L, 2);
Karsten Hopp fb3e18
  #endif
Karsten Hopp fb3e18
!   fclose(fpo);
Karsten Hopp fb3e18
!   fclose(fpi);
Karsten Hopp fb3e18
    return 0;
Karsten Hopp fb3e18
  }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
--- 371,390 ----
Karsten Hopp fb3e18
  	    want_off = 0;
Karsten Hopp fb3e18
  	  while ((c = getc(fpi)) != '\n' && c != EOF)
Karsten Hopp fb3e18
  	    ;
Karsten Hopp fb3e18
+ 	  if (c == EOF && ferror(fpi))
Karsten Hopp fb3e18
+ 	    die(2);
Karsten Hopp fb3e18
  	  ign_garb = 1;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
!   if (fflush(fpo) != 0)
Karsten Hopp fb3e18
!     die(3);
Karsten Hopp fb3e18
  #ifdef TRY_SEEK
Karsten Hopp fb3e18
    fseek(fpo, 0L, 2);
Karsten Hopp fb3e18
  #endif
Karsten Hopp fb3e18
!   if (fclose(fpo) != 0)
Karsten Hopp fb3e18
!     die(3);
Karsten Hopp fb3e18
!   if (fclose(fpi) != 0)
Karsten Hopp fb3e18
!     die(2);
Karsten Hopp fb3e18
    return 0;
Karsten Hopp fb3e18
  }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 379,389 ****
Karsten Hopp fb3e18
   *
Karsten Hopp fb3e18
   * If nz is always positive, lines are never suppressed.
Karsten Hopp fb3e18
   */
Karsten Hopp fb3e18
! static void
Karsten Hopp fb3e18
  xxdline(fp, l, nz)
Karsten Hopp fb3e18
! FILE *fp;
Karsten Hopp fb3e18
! char *l;
Karsten Hopp fb3e18
! int nz;
Karsten Hopp fb3e18
  {
Karsten Hopp fb3e18
    static char z[LLEN+1];
Karsten Hopp fb3e18
    static int zero_seen = 0;
Karsten Hopp fb3e18
--- 400,410 ----
Karsten Hopp fb3e18
   *
Karsten Hopp fb3e18
   * If nz is always positive, lines are never suppressed.
Karsten Hopp fb3e18
   */
Karsten Hopp fb3e18
!   static void
Karsten Hopp fb3e18
  xxdline(fp, l, nz)
Karsten Hopp fb3e18
!   FILE *fp;
Karsten Hopp fb3e18
!   char *l;
Karsten Hopp fb3e18
!   int nz;
Karsten Hopp fb3e18
  {
Karsten Hopp fb3e18
    static char z[LLEN+1];
Karsten Hopp fb3e18
    static int zero_seen = 0;
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 398,409 ****
Karsten Hopp fb3e18
  	  if (nz < 0)
Karsten Hopp fb3e18
  	    zero_seen--;
Karsten Hopp fb3e18
  	  if (zero_seen == 2)
Karsten Hopp fb3e18
! 	    fputs(z, fp);
Karsten Hopp fb3e18
  	  if (zero_seen > 2)
Karsten Hopp fb3e18
! 	    fputs("*\n", fp);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
        if (nz >= 0 || zero_seen > 0)
Karsten Hopp fb3e18
! 	fputs(l, fp);
Karsten Hopp fb3e18
        if (nz)
Karsten Hopp fb3e18
  	zero_seen = 0;
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
--- 419,433 ----
Karsten Hopp fb3e18
  	  if (nz < 0)
Karsten Hopp fb3e18
  	    zero_seen--;
Karsten Hopp fb3e18
  	  if (zero_seen == 2)
Karsten Hopp fb3e18
! 	    if (fputs(z, fp) == EOF)
Karsten Hopp fb3e18
! 	      die(3);
Karsten Hopp fb3e18
  	  if (zero_seen > 2)
Karsten Hopp fb3e18
! 	    if (fputs("*\n", fp) == EOF)
Karsten Hopp fb3e18
! 	      die(3);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
        if (nz >= 0 || zero_seen > 0)
Karsten Hopp fb3e18
! 	if (fputs(l, fp) == EOF)
Karsten Hopp fb3e18
! 	  die(3);
Karsten Hopp fb3e18
        if (nz)
Karsten Hopp fb3e18
  	zero_seen = 0;
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 439,448 ****
Karsten Hopp fb3e18
      0070,0071,0372,0373,0374,0375,0376,0377
Karsten Hopp fb3e18
  };
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
! int
Karsten Hopp fb3e18
  main(argc, argv)
Karsten Hopp fb3e18
! int argc;
Karsten Hopp fb3e18
! char *argv[];
Karsten Hopp fb3e18
  {
Karsten Hopp fb3e18
    FILE *fp, *fpo;
Karsten Hopp fb3e18
    int c, e, p = 0, relseek = 1, negseek = 0, revert = 0;
Karsten Hopp fb3e18
--- 463,472 ----
Karsten Hopp fb3e18
      0070,0071,0372,0373,0374,0375,0376,0377
Karsten Hopp fb3e18
  };
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
!   int
Karsten Hopp fb3e18
  main(argc, argv)
Karsten Hopp fb3e18
!   int argc;
Karsten Hopp fb3e18
!   char *argv[];
Karsten Hopp fb3e18
  {
Karsten Hopp fb3e18
    FILE *fp, *fpo;
Karsten Hopp fb3e18
    int c, e, p = 0, relseek = 1, negseek = 0, revert = 0;
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 452,458 ****
Karsten Hopp fb3e18
    int grplen;		/* total chars per octet group */
Karsten Hopp fb3e18
    long length = -1, n = 0, seekoff = 0;
Karsten Hopp fb3e18
    char l[LLEN+1];
Karsten Hopp fb3e18
!   char *pname, *pp;
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
  #ifdef AMIGA
Karsten Hopp fb3e18
    /* This program doesn't work when started from the Workbench */
Karsten Hopp fb3e18
--- 476,482 ----
Karsten Hopp fb3e18
    int grplen;		/* total chars per octet group */
Karsten Hopp fb3e18
    long length = -1, n = 0, seekoff = 0;
Karsten Hopp fb3e18
    char l[LLEN+1];
Karsten Hopp fb3e18
!   char *pp;
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
  #ifdef AMIGA
Karsten Hopp fb3e18
    /* This program doesn't work when started from the Workbench */
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 495,501 ****
Karsten Hopp fb3e18
  	  else
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
  	      if (!argv[2])
Karsten Hopp fb3e18
! 		exit_with_usage(pname);
Karsten Hopp fb3e18
  	      cols = (int)strtol(argv[2], NULL, 0);
Karsten Hopp fb3e18
  	      argv++;
Karsten Hopp fb3e18
  	      argc--;
Karsten Hopp fb3e18
--- 519,525 ----
Karsten Hopp fb3e18
  	  else
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
  	      if (!argv[2])
Karsten Hopp fb3e18
! 		exit_with_usage();
Karsten Hopp fb3e18
  	      cols = (int)strtol(argv[2], NULL, 0);
Karsten Hopp fb3e18
  	      argv++;
Karsten Hopp fb3e18
  	      argc--;
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 508,514 ****
Karsten Hopp fb3e18
  	  else
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
  	      if (!argv[2])
Karsten Hopp fb3e18
! 		exit_with_usage(pname);
Karsten Hopp fb3e18
  	      octspergrp = (int)strtol(argv[2], NULL, 0);
Karsten Hopp fb3e18
  	      argv++;
Karsten Hopp fb3e18
  	      argc--;
Karsten Hopp fb3e18
--- 532,538 ----
Karsten Hopp fb3e18
  	  else
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
  	      if (!argv[2])
Karsten Hopp fb3e18
! 		exit_with_usage();
Karsten Hopp fb3e18
  	      octspergrp = (int)strtol(argv[2], NULL, 0);
Karsten Hopp fb3e18
  	      argv++;
Karsten Hopp fb3e18
  	      argc--;
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 531,537 ****
Karsten Hopp fb3e18
  	  else
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
  	      if (!argv[2])
Karsten Hopp fb3e18
! 		exit_with_usage(pname);
Karsten Hopp fb3e18
  #ifdef TRY_SEEK
Karsten Hopp fb3e18
  	      if (argv[2][0] == '+')
Karsten Hopp fb3e18
  		relseek++;
Karsten Hopp fb3e18
--- 555,561 ----
Karsten Hopp fb3e18
  	  else
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
  	      if (!argv[2])
Karsten Hopp fb3e18
! 		exit_with_usage();
Karsten Hopp fb3e18
  #ifdef TRY_SEEK
Karsten Hopp fb3e18
  	      if (argv[2][0] == '+')
Karsten Hopp fb3e18
  		relseek++;
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 550,556 ****
Karsten Hopp fb3e18
  	  else
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
  	      if (!argv[2])
Karsten Hopp fb3e18
! 		exit_with_usage(pname);
Karsten Hopp fb3e18
  	      length = strtol(argv[2], (char **)NULL, 0);
Karsten Hopp fb3e18
  	      argv++;
Karsten Hopp fb3e18
  	      argc--;
Karsten Hopp fb3e18
--- 574,580 ----
Karsten Hopp fb3e18
  	  else
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
  	      if (!argv[2])
Karsten Hopp fb3e18
! 		exit_with_usage();
Karsten Hopp fb3e18
  	      length = strtol(argv[2], (char **)NULL, 0);
Karsten Hopp fb3e18
  	      argv++;
Karsten Hopp fb3e18
  	      argc--;
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 563,569 ****
Karsten Hopp fb3e18
  	  break;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
        else if (pp[0] == '-' && pp[1])	/* unknown option */
Karsten Hopp fb3e18
! 	exit_with_usage(pname);
Karsten Hopp fb3e18
        else
Karsten Hopp fb3e18
  	break;				/* not an option */
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
--- 587,593 ----
Karsten Hopp fb3e18
  	  break;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
        else if (pp[0] == '-' && pp[1])	/* unknown option */
Karsten Hopp fb3e18
! 	exit_with_usage();
Karsten Hopp fb3e18
        else
Karsten Hopp fb3e18
  	break;				/* not an option */
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 602,608 ****
Karsten Hopp fb3e18
      octspergrp = cols;
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
    if (argc > 3)
Karsten Hopp fb3e18
!     exit_with_usage(pname);
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
    if (argc == 1 || (argv[1][0] == '-' && !argv[1][1]))
Karsten Hopp fb3e18
      BIN_ASSIGN(fp = stdin, !revert);
Karsten Hopp fb3e18
--- 626,632 ----
Karsten Hopp fb3e18
      octspergrp = cols;
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
    if (argc > 3)
Karsten Hopp fb3e18
!     exit_with_usage();
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
    if (argc == 1 || (argv[1][0] == '-' && !argv[1][1]))
Karsten Hopp fb3e18
      BIN_ASSIGN(fp = stdin, !revert);
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 640,646 ****
Karsten Hopp fb3e18
  	  fprintf(stderr, "%s: sorry, cannot revert this type of hexdump\n", pname);
Karsten Hopp fb3e18
  	  return -1;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
!       return huntype(fp, fpo, stderr, pname, cols, hextype,
Karsten Hopp fb3e18
  		negseek ? -seekoff : seekoff);
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
--- 664,670 ----
Karsten Hopp fb3e18
  	  fprintf(stderr, "%s: sorry, cannot revert this type of hexdump\n", pname);
Karsten Hopp fb3e18
  	  return -1;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
!       return huntype(fp, fpo, stderr, cols, hextype,
Karsten Hopp fb3e18
  		negseek ? -seekoff : seekoff);
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 664,670 ****
Karsten Hopp fb3e18
  	  long s = seekoff;
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
  	  while (s--)
Karsten Hopp fb3e18
! 	    (void)getc(fp);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
--- 688,703 ----
Karsten Hopp fb3e18
  	  long s = seekoff;
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
  	  while (s--)
Karsten Hopp fb3e18
! 	    if (getc(fp) == EOF)
Karsten Hopp fb3e18
! 	      if (ferror(fp))
Karsten Hopp fb3e18
! 		{
Karsten Hopp fb3e18
! 		  die(2);
Karsten Hopp fb3e18
! 		}
Karsten Hopp fb3e18
! 	      else
Karsten Hopp fb3e18
! 		{
Karsten Hopp fb3e18
! 		  fprintf(stderr, "%s: sorry cannot seek.\n", pname);
Karsten Hopp fb3e18
! 		  return 4;
Karsten Hopp fb3e18
! 		}
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 672,725 ****
Karsten Hopp fb3e18
      {
Karsten Hopp fb3e18
        if (fp != stdin)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  fprintf(fpo, "unsigned char %s", isdigit((int)argv[1][0]) ? "__" : "");
Karsten Hopp fb3e18
  	  for (e = 0; (c = argv[1][e]) != 0; e++)
Karsten Hopp fb3e18
! 	    putc(isalnum(c) ? c : '_', fpo);
Karsten Hopp fb3e18
! 	  fputs("[] = {\n", fpo);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        p = 0;
Karsten Hopp fb3e18
        while ((length < 0 || p < length) && (c = getc(fp)) != EOF)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  fprintf(fpo, (hexx == hexxa) ? "%s0x%02x" : "%s0X%02X",
Karsten Hopp fb3e18
! 	    (p % cols) ? ", " : ",\n  "+2*!p,  c);
Karsten Hopp fb3e18
  	  p++;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        if (p)
Karsten Hopp fb3e18
! 	fputs("\n};\n"+3*(fp == stdin), fpo);
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        if (fp != stdin)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  fprintf(fpo, "unsigned int %s", isdigit((int)argv[1][0]) ? "__" : "");
Karsten Hopp fb3e18
  	  for (e = 0; (c = argv[1][e]) != 0; e++)
Karsten Hopp fb3e18
! 	    putc(isalnum(c) ? c : '_', fpo);
Karsten Hopp fb3e18
! 	  fprintf(fpo, "_len = %d;\n", p);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
!       fclose(fp);
Karsten Hopp fb3e18
!       fclose(fpo);
Karsten Hopp fb3e18
        return 0;
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
    if (hextype == HEX_POSTSCRIPT)
Karsten Hopp fb3e18
      {
Karsten Hopp fb3e18
        p = cols;
Karsten Hopp fb3e18
        while ((length < 0 || n < length) && (e = getc(fp)) != EOF)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  putchar(hexx[(e >> 4) & 0xf]);
Karsten Hopp fb3e18
! 	  putchar(hexx[(e     ) & 0xf]);
Karsten Hopp fb3e18
  	  n++;
Karsten Hopp fb3e18
  	  if (!--p)
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
! 	      putchar('\n');
Karsten Hopp fb3e18
  	      p = cols;
Karsten Hopp fb3e18
  	    }
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
        if (p < cols)
Karsten Hopp fb3e18
! 	putchar('\n');
Karsten Hopp fb3e18
!       fclose(fp);
Karsten Hopp fb3e18
!       fclose(fpo);
Karsten Hopp fb3e18
        return 0;
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
--- 705,779 ----
Karsten Hopp fb3e18
      {
Karsten Hopp fb3e18
        if (fp != stdin)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  if (fprintf(fpo, "unsigned char %s", isdigit((int)argv[1][0]) ? "__" : "") < 0)
Karsten Hopp fb3e18
! 	    die(3);
Karsten Hopp fb3e18
  	  for (e = 0; (c = argv[1][e]) != 0; e++)
Karsten Hopp fb3e18
! 	    if (putc(isalnum(c) ? c : '_', fpo) == EOF)
Karsten Hopp fb3e18
! 	      die(3);
Karsten Hopp fb3e18
! 	  if (fputs("[] = {\n", fpo) == EOF)
Karsten Hopp fb3e18
! 	    die(3);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        p = 0;
Karsten Hopp fb3e18
+       c = 0;
Karsten Hopp fb3e18
        while ((length < 0 || p < length) && (c = getc(fp)) != EOF)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  if (fprintf(fpo, (hexx == hexxa) ? "%s0x%02x" : "%s0X%02X",
Karsten Hopp fb3e18
! 		(p % cols) ? ", " : ",\n  "+2*!p,  c) < 0)
Karsten Hopp fb3e18
! 	    die(3);
Karsten Hopp fb3e18
  	  p++;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
+       if (c == EOF && ferror(fp))
Karsten Hopp fb3e18
+ 	die(2);
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        if (p)
Karsten Hopp fb3e18
! 	if (fputs("\n};\n" + 3 * (fp == stdin), fpo) == EOF)
Karsten Hopp fb3e18
! 	  die(3);
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
        if (fp != stdin)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  if (fprintf(fpo, "unsigned int %s", isdigit((int)argv[1][0]) ? "__" : "") < 0)
Karsten Hopp fb3e18
! 	    die(3);
Karsten Hopp fb3e18
  	  for (e = 0; (c = argv[1][e]) != 0; e++)
Karsten Hopp fb3e18
! 	    if (putc(isalnum(c) ? c : '_', fpo) == EOF)
Karsten Hopp fb3e18
! 	      die(3);
Karsten Hopp fb3e18
! 	  if (fprintf(fpo, "_len = %d;\n", p) < 0)
Karsten Hopp fb3e18
! 	    die(3);
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
!       if (fclose(fp))
Karsten Hopp fb3e18
! 	die(2);
Karsten Hopp fb3e18
!       if (fclose(fpo))
Karsten Hopp fb3e18
! 	die(3);
Karsten Hopp fb3e18
        return 0;
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
    if (hextype == HEX_POSTSCRIPT)
Karsten Hopp fb3e18
      {
Karsten Hopp fb3e18
        p = cols;
Karsten Hopp fb3e18
+       e = 0;
Karsten Hopp fb3e18
        while ((length < 0 || n < length) && (e = getc(fp)) != EOF)
Karsten Hopp fb3e18
  	{
Karsten Hopp fb3e18
! 	  if (putc(hexx[(e >> 4) & 0xf], fpo) == EOF
Karsten Hopp fb3e18
! 		  || putc(hexx[e & 0xf], fpo) == EOF)
Karsten Hopp fb3e18
! 	    die(3);
Karsten Hopp fb3e18
  	  n++;
Karsten Hopp fb3e18
  	  if (!--p)
Karsten Hopp fb3e18
  	    {
Karsten Hopp fb3e18
! 	      if (putc('\n', fpo) == EOF)
Karsten Hopp fb3e18
! 		die(3);
Karsten Hopp fb3e18
  	      p = cols;
Karsten Hopp fb3e18
  	    }
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
+       if (e == EOF && ferror(fp))
Karsten Hopp fb3e18
+ 	die(2);
Karsten Hopp fb3e18
        if (p < cols)
Karsten Hopp fb3e18
! 	if (putc('\n', fpo) == EOF)
Karsten Hopp fb3e18
! 	  die(3);
Karsten Hopp fb3e18
!       if (fclose(fp))
Karsten Hopp fb3e18
! 	die(2);
Karsten Hopp fb3e18
!       if (fclose(fpo))
Karsten Hopp fb3e18
! 	die(3);
Karsten Hopp fb3e18
        return 0;
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 730,735 ****
Karsten Hopp fb3e18
--- 784,790 ----
Karsten Hopp fb3e18
    else	/* hextype == HEX_BITS */
Karsten Hopp fb3e18
      grplen = 8 * octspergrp + 1;
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
+   e = 0;
Karsten Hopp fb3e18
    while ((length < 0 || n < length) && (e = getc(fp)) != EOF)
Karsten Hopp fb3e18
      {
Karsten Hopp fb3e18
        if (p == 0)
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 771,776 ****
Karsten Hopp fb3e18
--- 826,833 ----
Karsten Hopp fb3e18
  	  p = 0;
Karsten Hopp fb3e18
  	}
Karsten Hopp fb3e18
      }
Karsten Hopp fb3e18
+   if (e == EOF && ferror(fp))
Karsten Hopp fb3e18
+     die(2);
Karsten Hopp fb3e18
    if (p)
Karsten Hopp fb3e18
      {
Karsten Hopp fb3e18
        l[c = (11 + (grplen * cols - 1)/octspergrp + p)] = '\n'; l[++c] = '\0';
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 779,785 ****
Karsten Hopp fb3e18
    else if (autoskip)
Karsten Hopp fb3e18
      xxdline(fpo, l, -1);	/* last chance to flush out suppressed lines */
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
!   fclose(fp);
Karsten Hopp fb3e18
!   fclose(fpo);
Karsten Hopp fb3e18
    return 0;
Karsten Hopp fb3e18
  }
Karsten Hopp fb3e18
--- 836,846 ----
Karsten Hopp fb3e18
    else if (autoskip)
Karsten Hopp fb3e18
      xxdline(fpo, l, -1);	/* last chance to flush out suppressed lines */
Karsten Hopp fb3e18
  
Karsten Hopp fb3e18
!   if (fclose(fp))
Karsten Hopp fb3e18
!     die(2);
Karsten Hopp fb3e18
!   if (fclose(fpo))
Karsten Hopp fb3e18
!     die(3);
Karsten Hopp fb3e18
    return 0;
Karsten Hopp fb3e18
  }
Karsten Hopp fb3e18
+ 
Karsten Hopp fb3e18
+ /* vi:set ts=8 sw=4 sts=2 cino+={2 cino+=n-2 : */
Karsten Hopp fb3e18
*** ../vim-7.3.151/src/version.c	2011-04-01 16:28:33.000000000 +0200
Karsten Hopp fb3e18
--- src/version.c	2011-04-01 19:00:26.000000000 +0200
Karsten Hopp fb3e18
***************
Karsten Hopp fb3e18
*** 716,717 ****
Karsten Hopp fb3e18
--- 716,719 ----
Karsten Hopp fb3e18
  {   /* Add new patch number below this line */
Karsten Hopp fb3e18
+ /**/
Karsten Hopp fb3e18
+     152,
Karsten Hopp fb3e18
  /**/
Karsten Hopp fb3e18
Karsten Hopp fb3e18
-- 
Karsten Hopp fb3e18
Eye have a spelling checker, it came with my PC;
Karsten Hopp fb3e18
It plainly marks four my revue mistakes I cannot sea.
Karsten Hopp fb3e18
I've run this poem threw it, I'm sure your please to no,
Karsten Hopp fb3e18
It's letter perfect in it's weigh, my checker tolled me sew!
Karsten Hopp fb3e18
Karsten Hopp fb3e18
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp fb3e18
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp fb3e18
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp fb3e18
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///