*** ./generic/tclEncoding.c.orig	Tue Nov 21 21:35:56 2000
--- ./generic/tclEncoding.c	Tue Nov 21 22:00:01 2000
***************
*** 1328,1340 ****
      TableEncodingData *dataPtr;
      unsigned short *pageMemPtr;
      Tcl_EncodingType encType;
-     char *hex;
      static char staticHex[] = {
  	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0,
  	10, 11, 12, 13, 14, 15
      };
  
!     hex = staticHex - '0';
  
      Tcl_DStringInit(&lineString);
      Tcl_Gets(chan, &lineString);
--- 1328,1340 ----
      TableEncodingData *dataPtr;
      unsigned short *pageMemPtr;
      Tcl_EncodingType encType;
      static char staticHex[] = {
  	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0,
  	10, 11, 12, 13, 14, 15
      };
  
! #define IN_RANGE(min,x,max) (((min) <= (x)) && ((x) <= (max)))
! #define HEX(ch)             (IN_RANGE ('0',ch,'9') || IN_RANGE ('A',ch,'F'))
  
      Tcl_DStringInit(&lineString);
      Tcl_Gets(chan, &lineString);
***************
*** 1383,1397 ****
  
  	Tcl_ReadChars(chan, objPtr, 3 + 16 * (16 * 4 + 1), 0);
  	p = Tcl_GetString(objPtr);
! 	hi = (hex[(int)p[0]] << 4) + hex[(int)p[1]];
  	dataPtr->toUnicode[hi] = pageMemPtr;
  	p += 2;
  	for (lo = 0; lo < 256; lo++) {
  	    if ((lo & 0x0f) == 0) {
  		p++;
  	    }
! 	    ch = (hex[(int)p[0]] << 12) + (hex[(int)p[1]] << 8)
! 		+ (hex[(int)p[2]] << 4) + hex[(int)p[3]];
  	    if (ch != 0) {
  		used[ch >> 8] = 1;
  	    }
--- 1383,1411 ----
  
  	Tcl_ReadChars(chan, objPtr, 3 + 16 * (16 * 4 + 1), 0);
  	p = Tcl_GetString(objPtr);
! 
! 	if (! (HEX (p[0]) && HEX (p[1]))) {
! 	  ckfree ((char*) dataPtr->toUnicode);
! 	  ckfree ((char*) dataPtr);
! 	  return NULL;
! 	}
! 
! 	hi = (staticHex[(int)(p[0]-'0')] << 4) + staticHex[(int)(p[1]-'0')];
  	dataPtr->toUnicode[hi] = pageMemPtr;
  	p += 2;
  	for (lo = 0; lo < 256; lo++) {
  	    if ((lo & 0x0f) == 0) {
  		p++;
  	    }
! 
! 	    if (! (HEX (p[0]) && HEX (p[1]) && HEX (p[2]) && HEX (p[3]))) {
! 	      ckfree ((char*) dataPtr->toUnicode);
! 	      ckfree ((char*) dataPtr);
! 	      return NULL;
! 	    }
! 
! 	    ch = (staticHex[(int)(p[0]-'0')] << 12) + (staticHex[(int)(p[1]-'0')] << 8)
! 		+ (staticHex[(int)(p[2]-'0')] << 4) + staticHex[(int)(p[3]-'0')];
  	    if (ch != 0) {
  		used[ch >> 8] = 1;
  	    }
***************
*** 1511,1516 ****
--- 1525,1532 ----
      encType.clientData	    = (ClientData) dataPtr;
      return Tcl_CreateEncoding(&encType);
  
+ #undef IN_RANGE
+ #undef HEX
  }
  
  /*
