[comp.bugs.4bsd] Bug in 4.3BSD adb

clyde@ut-ngp.UUCP (Head UNIX Hacquer) (12/02/86)

Subject: Output of hex print mode is signed
Index:	/usr/src/bin/adb/output.c 4.3BSD

Description:
	When printing using the 'X' format, words with the high bit set are
	printed in the form of '-nnn'.  This is pretty useless for seeing
	which bits are really on, and signed hex output doesn't make much
	sense.
Repeat-By:
	adb your favorite a.out file and step through it with '/X'.
Fix:

*** output.r1.1.c	Tue Dec  2 13:52:15 1986
--- output.c	Tue Dec  2 13:47:29 1986
***************
*** 317,328 ****
  printdbl(lxy,fmat,base)
  L_INT lxy; char fmat; int base;
  #endif
  {	int digs[20]; int *dptr; char k;
  #ifndef MULD2
! 	register char *cp1;
! 	cp1=digs; if ((lxy&0xFFFF0000L)==0xFFFF0000L) {*cp1++='-'; lxy= -lxy;}
  	sprintf(cp1,base==16 ? "%x" : "%D",lxy);
  	cp1=digs; while (*digitptr++= *cp1++); --digitptr;
  #else
  	L_REAL f ,g; long q;
  #ifdef vax
--- 318,335 ----
  printdbl(lxy,fmat,base)
  L_INT lxy; char fmat; int base;
  #endif
  {	int digs[20]; int *dptr; char k;
  #ifndef MULD2
! 	register char *cp1 = digs;
! 
! 	IF base == 10
! 	THEN
! 		IF (lxy&0xFFFF0000L)==0xFFFF0000L
! 		THEN *cp1++='-'; lxy= -lxy;
! 		FI
! 	FI
  	sprintf(cp1,base==16 ? "%x" : "%D",lxy);
  	cp1=digs; while (*digitptr++= *cp1++); --digitptr;
  #else
  	L_REAL f ,g; long q;
  #ifdef vax

Comment:
	This code (adb in general) is REALLY UGLY!!!
-- 
Shouter-To-Dead-Parrots @ Univ. of Texas Computation Center; Austin, Texas  
	clyde@ngp.cc.utexas.edu; ...!ut-sally!ut-ngp!clyde
"It's a sort of a threat, you see.  I've never been very good at them
myself, but I've told they can be very effective."