[comp.emacs] Need some help with hexl.el

cloos@acsu.buffalo.edu (James H. Cloos) (10/09/90)

Thanks for all the responces.  As someone mailed me a copy of hexl.c
and hexl.el (thanks) & as ftp to tut.cis.ohio-state.edu kept dying on
me, I've not had a chance to check out hex.el; but wrt hexl.el, I
still need to have the nybbles reversed in each byte.  I made the
needed changes to hexl.c but do not know enough elisp to make them to
hexl.el.  Below is the diff-c output showing the changes I made in
hexl.c; if anyone is willing to make these changes to hexl.el for me,
I would be more than grateful.  You will note that I added the option
-rev-nyb to reverse the nybbles (this name seemed consistant with
those already there); the changes are simple & should be obvious.
I would also note that the option -{big,little}-endian does not seem
to be used, except that it defafults to 1 unless you specify
-group-by-64-bits, than it defaults to 0, but is not used in the rest
of the code.

here is hexl.c.diff,
-------------------------------CUT CUT-------------------------------
*** hexl.c.orig	Mon Oct  8 15:57:46 1990
--- hexl.c	Mon Oct  8 17:18:55 1990
***************
*** 12,18 ****
  extern void exit(), perror();
  
  int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1;
! int group_by = DEFAULT_GROUPING;
  char *progname;
  
  main(argc, argv)
--- 12,18 ----
  extern void exit(), perror();
  
  int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1;
! int group_by = DEFAULT_GROUPING, reverse_nybble = FALSE;
  char *progname;
  
  main(argc, argv)
***************
*** 36,41 ****
--- 36,42 ----
      ** -big-endian	Big Endian
      ** -little-endian	Little Endian
      ** -un || -de	from hexl format to binary.
+     ** -rev-nyb		assume in reverse nybble format
      ** --		End switch list.
      ** <filename>	dump filename
      ** -		(as filename == stdin)
***************
*** 72,77 ****
--- 73,82 ----
  	{
  	    endian = 0;
  	    --argc; argv++;
+ 	} else if (!strcmp(*argv, "-rev-nyb"))
+ 	{
+             reverse_nybble = TRUE;
+             --argc; argv++;
  	} else if (!strcmp(*argv, "-group-by-8-bits"))
  	{
  	    group_by = 0x00;
***************
*** 133,139 ****
  			break;
  
  		    d = getc(fp);
! 		    c = hexchar(c) * 0x10 + hexchar(d);
  		    (void) putchar(c);
  
  		    if ((i&group_by) == group_by)
--- 138,147 ----
  			break;
  
  		    d = getc(fp);
! 		    if (reverse_nybble)
! 			c = hexchar(d) * 0x10 + hexchar(c);
! 		    else
! 		        c = hexchar(c) * 0x10 + hexchar(d);
  		    (void) putchar(c);
  
  		    if ((i&group_by) == group_by)
***************
*** 187,193 ****
  			else
  			    string[i+1] = (c < 0x20 || c >= 0x7F) ? '.' : c;
  
! 			(void) printf("%02x", c);
  		    }
  
  		    if ((i&group_by) == group_by)
--- 195,204 ----
  			else
  			    string[i+1] = (c < 0x20 || c >= 0x7F) ? '.' : c;
  
! 			if (reverse_nybble)
! 			  (void) printf("%01x%01x", c&0xF, (c&0xF0) >> 4);
! 			else
! 			  (void) printf("%02x", c);
  		    }
  
  		    if ((i&group_by) == group_by)
-----------------------------CUT CUT-------------------------------------
Thanks in advance for any help sent!
-JimC
--
James H. Cloos, Jr.		Phone:  +1 716 673-1250
cloos@acsu.buffalo.edu		Snail:  PersonalZipCode:  14048-0772, USA
rutgers!ub!cloos