		      Release 5 Public Patch #21
			   MIT X Consortium

To apply this patch:

cd to the top of the source tree (to the directory containing the "mit"
and "contrib" subdirectories) and do:
	patch -p -s < ThisFile
Patch will work silently unless an error occurs.
If you want to watch patch do its thing, leave out the "-s" argument to patch.


Finally, to rebuild after applying this patch, cd to the "mit" subdirectory
and (if you are on an RS/6000) do:
	make Everything >& every.log
otherwise do:
	make -k >& make.log


Brief notes on what this patch fixes:

xdm: patch 20 introduced a build problem on AIX 3
Xlib: (Xsi) XCreateFontSet calls free() with NULL
Xlib: (Xsi) wcharint.h should not check the typedef of wchar with WNULL
Xlib: (Xsi) stack allocation problem in multitasking environment
Xlib: (Xsi) bug in definition of XipLocalICRec
Xlib: (Xsi) LocalIM returns only Keysym
Xlib: (Xsi) LoadCodeset() needs to initialize `cds_mb_cur_max'...


Prereq: public-patch-20

*** /tmp/da03350	Thu Dec 17 20:13:09 1992
--- mit/bug-report	Thu Dec 17 20:13:09 1992
***************
*** 2,8 ****
  Subject: [area]: [synopsis]   [replace with actual area and short description]
  
  VERSION:
!     R5, public-patch-20
      [MIT public patches will edit this line to indicate the patch level]
  
  CLIENT MACHINE and OPERATING SYSTEM:
--- 2,8 ----
  Subject: [area]: [synopsis]   [replace with actual area and short description]
  
  VERSION:
!     R5, public-patch-21
      [MIT public patches will edit this line to indicate the patch level]
  
  CLIENT MACHINE and OPERATING SYSTEM:
*** /tmp/,RCSt1a03317	Thu Dec 17 20:09:44 1992
--- mit/clients/xdm/Imakefile	Thu Dec 17 20:00:24 1992
***************
*** 1,4 ****
! XCOMM $XConsortium: Imakefile,v 1.58 91/08/22 14:24:45 rws Exp $
  #define IHaveSubdirs
  #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
  
--- 1,4 ----
! XCOMM $XConsortium: Imakefile,v 1.58.1.1 92/12/17 20:08:19 gildea Exp $
  #define IHaveSubdirs
  #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
  
***************
*** 22,27 ****
--- 22,31 ----
  #if SystemV
  SYS_LIBRARIES = -lsec
  #endif
  #endif
+ 
+ #if (defined(AIXArchitecture) && (OSMajorVersion >= 3))
+ SYS_LIBRARIES = -ls
+ #endif
  
     XDMCONFIGDIR = XdmConfigurationSubdirectory
*** /tmp/d05328	Mon Dec 14 17:52:04 1992
--- mit/lib/X/Xsi/ProtoFlt.c	Mon Dec 14 17:51:57 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: ProtoFlt.c,v 1.27 92/04/24 16:13:58 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: ProtoFlt.c,v 1.28 92/10/22 14:25:16 rws Exp $
   */
  
  /*
***************
*** 420,426 ****
  		if (reply1.type == XIM_KEYSYM || reply1.type == XIM_STRING) {
  		    if (_XipPutICQueue(ic, (short)reply1.type,
  				       (int)reply1.length,
! 				       (KeySym)reply1.keysym, 0, NULL) < 0) {
  			return(-1);
  		    }
  		    count++;
--- 420,426 ----
  		if (reply1.type == XIM_KEYSYM || reply1.type == XIM_STRING) {
  		    if (_XipPutICQueue(ic, (short)reply1.type,
  				       (int)reply1.length,
! 				       (KeySym)reply1.keysym, 0, 0, NULL) < 0) {
  			return(-1);
  		    }
  		    count++;
*** /tmp/d05541	Mon Dec 14 17:54:01 1992
--- mit/lib/X/Xsi/XCrFntSet.c	Mon Dec 14 17:53:57 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: XCrFntSet.c,v 1.46 92/04/24 16:10:50 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: XCrFntSet.c,v 1.48 92/09/10 17:06:53 rws Exp $
   */
  
  /*
***************
*** 63,69 ****
  #define DELIM_COUNT	13      /* Number of delimiters */
  #define CSETPOS		13      /* CHARSET-REGISTRY position */
  
! #if __STDC__ && !defined(VMS)
  #define RConst const
  #else
  #define RConst /**/
--- 63,69 ----
  #define DELIM_COUNT	13      /* Number of delimiters */
  #define CSETPOS		13      /* CHARSET-REGISTRY position */
  
! #if __STDC__ && !defined(NORCONST)
  #define RConst const
  #else
  #define RConst /**/
***************
*** 416,422 ****
      char       **list;
      int		 count;
      int		 cset_count;
!     char	*fn;
      int		 ret = 0;
      _CSID	 i;
  
--- 416,422 ----
      char       **list;
      int		 count;
      int		 cset_count;
!     char	*fn = NULL;
      int		 ret = 0;
      _CSID	 i;
  
***************
*** 450,458 ****
  #else /* PRELOAD */
  		if (!info)
  		    list = XListFontsWithInfo(dpy, fname, 1, &count, &info);
  		if(! (s_tmp[i] = (XFontStruct *) Xmalloc(sizeof(XFontStruct)))){
! 		    Xfree((char *)fn);
! 		    return ret;
  		}
  # ifndef MUSTCOPY
  		s_tmp[i] = info[0];
--- 450,461 ----
  #else /* PRELOAD */
  		if (!info)
  		    list = XListFontsWithInfo(dpy, fname, 1, &count, &info);
+ 		    if (count != 1) {
+ 			/* never go to here. */
+ 			goto _err_return;
+ 		    }
  		if(! (s_tmp[i] = (XFontStruct *) Xmalloc(sizeof(XFontStruct)))){
! 		    goto _err_return;
  		}
  # ifndef MUSTCOPY
  		s_tmp[i] = info[0];
***************
*** 464,471 ****
  #endif /* PRELOAD */
  		id_tmp[i] = cset->cs_id;
  		if(! (f_tmp[i] = (char *) Xmalloc(strlen(fn) + 1))) {
! 		    Xfree((char *)fn);
! 		    return --ret;
  		}
  		strcpy(f_tmp[i], fn);
  	    } else {
--- 467,474 ----
  #endif /* PRELOAD */
  		id_tmp[i] = cset->cs_id;
  		if(! (f_tmp[i] = (char *) Xmalloc(strlen(fn) + 1))) {
! 		    --ret;
! 		    goto _err_return;
  		}
  		strcpy(f_tmp[i], fn);
  	    } else {
***************
*** 477,483 ****
      if (info) {
  	XFreeFontInfo(list, info, count);
      }
!     Xfree((char *)fn);
      return ret;
  
  }
--- 480,486 ----
      if (info) {
  	XFreeFontInfo(list, info, count);
      }
!     if (fn) Xfree((char *)fn);
      return ret;
  
  }
*** /tmp/d05671	Mon Dec 14 17:55:19 1992
--- mit/lib/X/Xsi/XIMKeyBind.c	Mon Dec 14 17:55:15 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: XIMKeyBind.c,v 1.25 92/07/29 12:10:04 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: XIMKeyBind.c,v 1.26 92/10/22 14:26:09 rws Exp $
   */
  
  /*
***************
*** 45,51 ****
      Status *status;
  {
      XipIC		ic = (XipIC)supic;
!     short		type;
      int			length;
      unsigned char	*ptr;
      int			ret_len, scanned_bytes;
--- 45,51 ----
      Status *status;
  {
      XipIC		ic = (XipIC)supic;
!     short		type, string_is_mb;
      int			length;
      unsigned char	*ptr;
      int			ret_len, scanned_bytes;
***************
*** 58,77 ****
  
      if (ev->keycode == 0) {
  	if (ev->state > 0) {
! 	    _XipGetOverflowICQueue(ic, &type, &length, &tmp_ks, (char **)&ptr);
  	} else {
! 	    _XipGetNextICQueue(ic, &type, &length, &tmp_ks, (char **)&ptr);
  	}
  	if (type == XIM_STRING || (type == XIM_KEYSYM && length > 0)) {
  #ifdef X_WCHAR
  	    ret_len = nchars;
! 	    ret = _XConvertCTToWC(ic->wc, ptr, length, (wchar *)buffer,
! 				  &ret_len, &scanned_bytes, (_State *)NULL);
  #else
  	    ret_len = length * 2;
  	    mbuf = _XAllocScratch(ev->display, ret_len);
! 	    ret = _XConvertCTToMB(ic->mb, ptr, length, mbuf,
! 				  &ret_len, &scanned_bytes, (_State *)NULL);
  	    if (ret >= 0) {
  #ifdef macII
  		ret_len = 0;
--- 58,90 ----
  
      if (ev->keycode == 0) {
  	if (ev->state > 0) {
! 	    _XipGetOverflowICQueue(ic, &type, &length, &tmp_ks,
! 				   &string_is_mb, (char **)&ptr);
  	} else {
! 	    _XipGetNextICQueue(ic, &type, &length, &tmp_ks,
! 			       &string_is_mb, (char **)&ptr);
  	}
  	if (type == XIM_STRING || (type == XIM_KEYSYM && length > 0)) {
  #ifdef X_WCHAR
  	    ret_len = nchars;
! 	    if (string_is_mb) {
! 		ret = _XConvertMBToWC(ic->wc, ptr, length, (wchar *)buffer,
! 				      &ret_len, &scanned_bytes, (_State *)NULL);
! 	    } else {
! 		ret = _XConvertCTToWC(ic->wc, ptr, length, (wchar *)buffer,
! 				      &ret_len, &scanned_bytes, (_State *)NULL);
! 	    }
  #else
  	    ret_len = length * 2;
  	    mbuf = _XAllocScratch(ev->display, ret_len);
! 	    if (string_is_mb) {
! 		ret = 0;
! 		strncpy(mbuf, (char *)ptr, length);
! 		ret_len = length;
! 	    } else {
! 		ret = _XConvertCTToMB(ic->mb, ptr, length, mbuf,
! 				      &ret_len, &scanned_bytes, (_State *)NULL);
! 	    }
  	    if (ret >= 0) {
  #ifdef macII
  		ret_len = 0;
***************
*** 84,90 ****
  	    }
  #endif
  	    if (ret == BadBuffer) {
! 		_XipSaveOverflowICQueue(ic, type, length, tmp_ks, ptr);
  		ev->state = 1;
  		*status = XBufferOverflow;
  		return(0);
--- 97,104 ----
  	    }
  #endif
  	    if (ret == BadBuffer) {
! 		_XipSaveOverflowICQueue(ic, type, length, tmp_ks,
! 					string_is_mb, ptr);
  		ev->state = 1;
  		*status = XBufferOverflow;
  		return(0);
***************
*** 160,166 ****
      Status *status;
  {
      XipIC		ic = (XipIC)supic;
!     short		type;
      int			length;
      unsigned char	*ptr;
      int			ret_len, scanned_bytes;
--- 174,180 ----
      Status *status;
  {
      XipIC		ic = (XipIC)supic;
!     short		type, string_is_mb;
      int			length;
      unsigned char	*ptr;
      int			ret_len, scanned_bytes;
***************
*** 169,202 ****
  
      if (ev->keycode == 0) {
  	if (ev->state > 0) {
! 	    _XipGetOverflowICQueue(ic, &type, &length, &tmp_ks, (char **)&ptr);
  	} else {
! 	    _XipGetNextICQueue(ic, &type, &length, &tmp_ks, (char **)&ptr);
  	}
! 	if (type == XIM_STRING) {
! 	    ret_len = nbytes;
! 	    ret = _XConvertCTToMB(ic->mb, ptr, length, (unsigned char *)buffer,
! 				  &ret_len, &scanned_bytes, (_State *)NULL);
! 	    if (ret == BadBuffer) {
! 		_XipSaveOverflowICQueue(ic, type, length, tmp_ks, ptr);
! 		ev->state = 1;
! 		*status = XBufferOverflow;
! 		return(0);
! 	    } else if (ret < 0) {
! 		*status = XLookupNone;
! 		return(0);
! 	    }
! 	    *status = XLookupChars;
! 	    return(ret_len);
! 	} else if (type == XIM_KEYSYM) {
! 	    if (length > 0) {
  		ret_len = nbytes;
  		ret = _XConvertCTToMB(ic->mb, ptr, length,
! 				      (unsigned char *)buffer,
! 				      &ret_len, &scanned_bytes,
! 				      (_State *)NULL);
  		if (ret == BadBuffer) {
! 		    _XipSaveOverflowICQueue(ic, type, length, tmp_ks, ptr);
  		    ev->state = 1;
  		    *status = XBufferOverflow;
  		    return(0);
--- 183,214 ----
  
      if (ev->keycode == 0) {
  	if (ev->state > 0) {
! 	    _XipGetOverflowICQueue(ic, &type, &length, &tmp_ks,
! 				   &string_is_mb, (char **)&ptr);
  	} else {
! 	    _XipGetNextICQueue(ic, &type, &length, &tmp_ks,
! 			       &string_is_mb, (char **)&ptr);
  	}
! 	if (type == XIM_STRING || (type == XIM_KEYSYM && length > 0)) {
! 	    if (string_is_mb) {
! 		if (nbytes < length) {
! 		    _XipSaveOverflowICQueue(ic, type, length, tmp_ks,
! 					    string_is_mb, ptr);
! 		    ev->state = 1;
! 		    *status = XBufferOverflow;
! 		    return(0);
! 		}
! 		(void)strncpy(buffer, (char *)ptr, length);
! 		if (length < nbytes) buffer[length] = '\0';
! 		ret_len = length;
! 	    } else {
  		ret_len = nbytes;
  		ret = _XConvertCTToMB(ic->mb, ptr, length,
! 				      (unsigned char *)buffer, &ret_len,
! 				      &scanned_bytes, (_State *)NULL);
  		if (ret == BadBuffer) {
! 		    _XipSaveOverflowICQueue(ic, type, length, tmp_ks,
! 					    string_is_mb, ptr);
  		    ev->state = 1;
  		    *status = XBufferOverflow;
  		    return(0);
***************
*** 204,222 ****
  		    *status = XLookupNone;
  		    return(0);
  		}
! 		if (keysym) {
! 		    *keysym = tmp_ks;
! 		    *status = XLookupBoth;
! 		} else {
! 		    *status = XLookupChars;
! 		}
! 		return(length);
! 	    } else if (keysym) {
  		*keysym = tmp_ks;
! 		*status = XLookupKeySym;
  	    } else {
! 		*status = XLookupNone;
  	    }
  	    return(0);
  	} else {
  	    *status = XLookupNone;
--- 216,232 ----
  		    *status = XLookupNone;
  		    return(0);
  		}
! 	    }
! 	    if (type == XIM_KEYSYM && keysym) {
  		*keysym = tmp_ks;
! 		*status = XLookupBoth;
  	    } else {
! 		*status = XLookupChars;
  	    }
+ 	    return(ret_len);
+ 	} else if (type == XIM_KEYSYM && keysym) {
+ 	    *keysym = tmp_ks;
+ 	    *status = XLookupKeySym;
  	    return(0);
  	} else {
  	    *status = XLookupNone;
***************
*** 244,251 ****
  }
  
  int
! _XipctLookupString(ic, ev, buffer, nbytes, keysym, status)
!     XIC ic;
      register XKeyEvent *ev;
      char *buffer;
      int nbytes;
--- 254,261 ----
  }
  
  int
! _XipctLookupString(supic, ev, buffer, nbytes, keysym, status)
!     XIC supic;
      register XKeyEvent *ev;
      char *buffer;
      int nbytes;
***************
*** 252,302 ****
      KeySym *keysym;
      Status *status;
  {
!     short		type;
      int			length;
      char		*ptr;
!     int			ret_len;
      KeySym		tmp_ks;
  
      if (ev->keycode == 0) {
  	if (ev->state > 0) {
! 	    _XipGetOverflowICQueue(ic, &type, &length, &tmp_ks, (char **)&ptr);
  	} else {
! 	    _XipGetNextICQueue(ic, &type, &length, &tmp_ks, &ptr);
  	}
! 	if (type == XIM_STRING) {
! 	    if (length > nbytes) {
! 		_XipSaveOverflowICQueue(ic, type, length, tmp_ks, ptr);
! 		ev->state = 1;
! 		*status = XBufferOverflow;
! 		return(0);
! 	    }
! 	    (void)strncpy(buffer, ptr, length);
! 	    if (length < nbytes) buffer[length] = 0;
! 	    *status = XLookupChars;
! 	    return(nbytes);
! 	} else if (type == XIM_KEYSYM) {
! 	    if (length > 0) {
  		if (length > nbytes) {
! 		    _XipSaveOverflowICQueue(ic, type, length, tmp_ks, ptr);
  		    ev->state = 1;
  		    *status = XBufferOverflow;
  		    return(0);
  		}
  		(void)strncpy(buffer, ptr, length);
! 		if (length < nbytes) buffer[length] = 0;
! 		if (keysym) {
! 		    *keysym = tmp_ks;
! 		    *status = XLookupBoth;
! 		} else {
! 		    *status = XLookupChars;
! 		}
! 		return(nbytes);
! 	    } else if (keysym) {
! 		*status = XLookupKeySym;
  	    } else {
! 		*status = XLookupNone;
  	    }
  	    return(0);
  	} else {
  	    *status = XLookupNone;
--- 262,321 ----
      KeySym *keysym;
      Status *status;
  {
!     XipIC		ic = (XipIC)supic;
!     short		type, string_is_mb;
      int			length;
      char		*ptr;
!     int			ret_len, scanned_bytes;
      KeySym		tmp_ks;
+     int			ret;
  
      if (ev->keycode == 0) {
  	if (ev->state > 0) {
! 	    _XipGetOverflowICQueue(ic, &type, &length, &tmp_ks,
! 				   &string_is_mb, (char **)&ptr);
  	} else {
! 	    _XipGetNextICQueue(ic, &type, &length, &tmp_ks,
! 			       &string_is_mb, &ptr);
  	}
! 	if (type == XIM_STRING || (type == XIM_KEYSYM && length > 0)) {
! 	    if (string_is_mb) {
! 		ret_len = nbytes;
! 		ret = _XConvertMBToCT(ic->mb, ptr, length,
! 				      (unsigned char *)buffer, &ret_len,
! 				      &scanned_bytes, (_State *)NULL);
! 		if (ret == BadBuffer) {
! 		    _XipSaveOverflowICQueue(ic, type, length, tmp_ks,
! 					    string_is_mb, ptr);
! 		    ev->state = 1;
! 		    *status = XBufferOverflow;
! 		    return(0);
! 		} else if (ret < 0) {
! 		    *status = XLookupNone;
! 		    return(0);
! 		}
! 	    } else {
  		if (length > nbytes) {
! 		    _XipSaveOverflowICQueue(ic, type, length, tmp_ks,
! 					    string_is_mb, ptr);
  		    ev->state = 1;
  		    *status = XBufferOverflow;
  		    return(0);
  		}
  		(void)strncpy(buffer, ptr, length);
! 		if (length < nbytes) buffer[length] = '\0';
! 		ret_len = length;
! 	    }
! 	    if (type == XIM_KEYSYM && keysym) {
! 		*keysym = tmp_ks;
! 		*status = XLookupBoth;
  	    } else {
! 		*status = XLookupChars;
  	    }
+ 	    return(ret_len);
+ 	} else if (type == XIM_KEYSYM && keysym) {
+ 	    *keysym = tmp_ks;
+ 	    *status = XLookupKeySym;
  	    return(0);
  	} else {
  	    *status = XLookupNone;
*** /tmp/d05715	Mon Dec 14 17:55:43 1992
--- mit/lib/X/Xsi/XIMQueue.c	Mon Dec 14 17:55:39 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: XIMQueue.c,v 1.11 92/07/29 13:55:40 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: XIMQueue.c,v 1.12 92/10/22 14:26:15 rws Exp $
   */
  
  /*
***************
*** 84,95 ****
   * Stack 
   */
  int
! _XipPutICQueue(ic, type, length, keysym, state, str)
      XipIC ic;
      short type;
      int length;
      KeySym keysym;
      unsigned int state;
      unsigned char *str;
  {
      XipIM im = ipIMofIC(ic);
--- 84,96 ----
   * Stack 
   */
  int
! _XipPutICQueue(ic, type, length, keysym, state, string_is_mb, str)
      XipIC ic;
      short type;
      int length;
      KeySym keysym;
      unsigned int state;
+     short string_is_mb;
      unsigned char *str;
  {
      XipIM im = ipIMofIC(ic);
***************
*** 121,126 ****
--- 122,128 ----
      }
  
      ic->in->type = type;
+     ic->in->string_is_mb = string_is_mb;
      if (type == XIM_KEYSYM) {
  	if (str) {
  	    length = strlen((char *)str);
***************
*** 163,173 ****
   * Get 
   */
  void
! _XipGetNextICQueue(ic, type, length, keysym, ptr)
      XipIC ic;
      short *type;
      int *length;
      KeySym *keysym;
      char **ptr;
  {
      if (ic->out) {
--- 165,176 ----
   * Get 
   */
  void
! _XipGetNextICQueue(ic, type, length, keysym, string_is_mb, ptr)
      XipIC ic;
      short *type;
      int *length;
      KeySym *keysym;
+     short *string_is_mb;
      char **ptr;
  {
      if (ic->out) {
***************
*** 174,179 ****
--- 177,183 ----
  	*type = ic->out->type;
  	*length = ic->out->length;
  	if (keysym != NULL) *keysym = ic->out->keysym;
+ 	*string_is_mb = ic->out->string_is_mb;
  	*ptr = ic->out->ptr;
  	if (ic->out->next == ic->in) {
  	    ic->out = NULL;
***************
*** 205,215 ****
   * Save to Overflow Queue
   */
  void
! _XipSaveOverflowICQueue(ic, type, length, keysym, ptr)
      XipIC ic;
      short type;
      int length;
      KeySym keysym;
      char *ptr;
  {
      register XIMQueue *q = &ic->overflow;
--- 209,220 ----
   * Save to Overflow Queue
   */
  void
! _XipSaveOverflowICQueue(ic, type, length, keysym, string_is_mb, ptr)
      XipIC ic;
      short type;
      int length;
      KeySym keysym;
+     short string_is_mb;
      char *ptr;
  {
      register XIMQueue *q = &ic->overflow;
***************
*** 218,223 ****
--- 223,229 ----
      q->length = length;
      q->keysym = keysym;
      q->state = 0;
+     q->string_is_mb = string_is_mb;
      if (q->length > 0) {
  	if (q->buf_max < q->length) {
  	    q->ptr = (char *)Xrealloc((char *)q->ptr, (unsigned)q->length);
***************
*** 231,241 ****
   * Get from Overflow Queue
   */
  void
! _XipGetOverflowICQueue(ic, type, length, keysym, ptr)
      XipIC ic;
      short *type;
      int *length;
      KeySym *keysym;
      char **ptr;
  {
      register XIMQueue *q = &ic->overflow;
--- 237,248 ----
   * Get from Overflow Queue
   */
  void
! _XipGetOverflowICQueue(ic, type, length, keysym, string_is_mb, ptr)
      XipIC ic;
      short *type;
      int *length;
      KeySym *keysym;
+     short *string_is_mb;
      char **ptr;
  {
      register XIMQueue *q = &ic->overflow;
***************
*** 244,249 ****
--- 251,257 ----
  	*type = q->type;
  	*length = q->length;
  	if (keysym != NULL) *keysym = q->keysym;
+ 	*string_is_mb = q->string_is_mb;
  	*ptr = q->ptr;
  	q->type = 0;
      } else {
*** /tmp/d05823	Mon Dec 14 17:56:49 1992
--- mit/lib/X/Xsi/XlcLoad.c	Mon Dec 14 17:56:45 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: XlcLoad.c,v 1.41 92/04/14 15:53:03 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: XlcLoad.c,v 1.44 92/12/14 09:22:48 rws Exp $
   */
  
  /*
***************
*** 38,44 ****
  #include "Xi18nint.h"
  #include <X11/Xos.h>
  
! #if __STDC__ && !defined(VMS)
  #define RConst const
  #else
  #define RConst /**/
--- 38,44 ----
  #include "Xi18nint.h"
  #include <X11/Xos.h>
  
! #if __STDC__ && !defined(NORCONST)
  #define RConst const
  #else
  #define RConst /**/
***************
*** 339,345 ****
  	codeset->cds_type = CDS_SELFDEFINED;
  	cds_GL = cds_GR = MAGIC_NO;	/* not indicate */
      }
! 
      for (num = 0; ptr = nptr; num++) {
  	ptr++;
  	if (nptr = index(ptr, ':')) *nptr = '\0';
--- 339,345 ----
  	codeset->cds_type = CDS_SELFDEFINED;
  	cds_GL = cds_GR = MAGIC_NO;	/* not indicate */
      }
!     codeset->cds_mb_cur_max = 1;
      for (num = 0; ptr = nptr; num++) {
  	ptr++;
  	if (nptr = index(ptr, ':')) *nptr = '\0';
***************
*** 396,405 ****
      Codeset        *ccs;
  {
      char            buf[MAXLINEBUF];
!     Range           cnv[MAXSPLITS];
      int             num = 0,
                      i, lastnum;
  
      ccs->cds_msbon = 0;     /* use msb on */
      for (i = 1, ccs->cds_cnvindex[0] = 0; i <= num_cs; i++) {
          lastnum = num;
--- 396,408 ----
      Codeset        *ccs;
  {
      char            buf[MAXLINEBUF];
!     Range          *cnv;
      int             num = 0,
                      i, lastnum;
  
+     if ( ! ( cnv = (Range *)Xmalloc(MAXSPLITS*sizeof(Range))))
+ 	return False;
+ 
      ccs->cds_msbon = 0;     /* use msb on */
      for (i = 1, ccs->cds_cnvindex[0] = 0; i <= num_cs; i++) {
          lastnum = num;
***************
*** 431,438 ****
      }
  
      ccs->cds_cnvlist = (Range *) Xmalloc((unsigned)sizeof(Range) * num);
!     if (!ccs->cds_cnvlist)
  	return False;
  #ifdef  FASTCOPY
      /* not used */
      (void) bcopy((char *)cnv, (char *)ccs->cds_cnvlist,
--- 434,443 ----
      }
  
      ccs->cds_cnvlist = (Range *) Xmalloc((unsigned)sizeof(Range) * num);
!     if (!ccs->cds_cnvlist) {
! 	Xfree((char *)cnv);
  	return False;
+     }
  #ifdef  FASTCOPY
      /* not used */
      (void) bcopy((char *)cnv, (char *)ccs->cds_cnvlist,
***************
*** 445,450 ****
--- 450,456 ----
          ccs->cds_cnvlist[i].cs_end = cnv[i].cs_end;
      }
  #endif
+     Xfree((char *)cnv);
      return True;
  
  }
*** /tmp/d06055	Mon Dec 14 17:58:49 1992
--- mit/lib/X/Xsi/Xi18nint.h	Mon Dec 14 17:58:46 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: Xi18nint.h,v 1.20 92/07/29 11:58:18 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: Xi18nint.h,v 1.22 92/10/22 14:26:26 rws Exp $
   */
  
  /*
***************
*** 66,71 ****
--- 66,72 ----
  
  typedef struct _XIMQueue {
      short type;				/* 0: XEvent, 1: String		 */
+     short string_is_mb;			/* 0: CT, 1: MB			 */
      int length;				/* length of String or XEvent    */
      KeySym keysym;			/* keysym			 */
      unsigned int state;			/* state 			 */
***************
*** 138,144 ****
  typedef struct {
      XICMethods		methods;		/* method list of this IC */
      XICCoreRec		core;			/* core data of this IC */
!     struct _XIMQueue	*in, *out, *prev;
      Bool		(*prototype_filter)();
      XLocale		mb;
      XLocale		wc;
--- 139,145 ----
  typedef struct {
      XICMethods		methods;		/* method list of this IC */
      XICCoreRec		core;			/* core data of this IC */
!     struct _XIMQueue	*in, *out, *prev, overflow;
      Bool		(*prototype_filter)();
      XLocale		mb;
      XLocale		wc;
*** /tmp/d06098	Mon Dec 14 17:59:11 1992
--- mit/lib/X/Xsi/wcharint.h	Mon Dec 14 17:59:09 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: wcharint.h,v 1.11 91/06/26 13:54:07 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: wcharint.h,v 1.12 92/09/10 17:09:53 rws Exp $
   */
  
  /*
***************
*** 38,46 ****
  #include "wchar.h"
  #endif
  
! #ifndef WNULL
  typedef	unsigned long wchar;	/* must be unsigned 4-byte type, ISO10646 */
  
  #define WNULL	0
  #endif
  
--- 38,49 ----
  #include "wchar.h"
  #endif
  
! #ifndef _WCHAR_
  typedef	unsigned long wchar;	/* must be unsigned 4-byte type, ISO10646 */
+ #define _WCHAR_
+ #endif
  
+ #ifndef WNULL
  #define WNULL	0
  #endif
  
*** /tmp/d06120	Mon Dec 14 17:59:23 1992
--- mit/lib/X/Xsi/XlcDefLd.c	Mon Dec 14 17:59:20 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: XlcDefLd.c,v 1.1 91/05/02 09:14:44 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: XlcDefLd.c,v 1.2 92/06/27 21:55:09 rws Exp $
   */
  
  /*
***************
*** 35,41 ****
  #include "Xlibint.h"
  #include "Xi18nint.h"
  
! #if __STDC__ && !defined(VMS)
  #define RConst const
  #else
  #define RConst /**/
--- 35,41 ----
  #include "Xlibint.h"
  #include "Xi18nint.h"
  
! #if __STDC__ && !defined(NORCONST)
  #define RConst const
  #else
  #define RConst /**/
*** /tmp/d06142	Mon Dec 14 17:59:34 1992
--- mit/lib/X/Xsi/XLocalIM.c	Mon Dec 14 17:59:31 1992
***************
*** 1,5 ****
  /*
!  * $XConsortium: XLocalIM.c,v 1.9 92/04/24 16:15:02 rws Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $XConsortium: XLocalIM.c,v 1.11 92/10/22 14:26:20 rws Exp $
   */
  
  /*
***************
*** 68,74 ****
  extern char *getenv();
  #endif
  
! #if __STDC__ && !defined(VMS)
  #define RConst const
  #else
  #define RConst /**/
--- 68,74 ----
  extern char *getenv();
  #endif
  
! #if __STDC__ && !defined(NORCONST)
  #define RConst const
  #else
  #define RConst /**/
***************
*** 290,296 ****
  {
      XipLocalKeySymTbl work_tbl[8], *p, *t;
      unsigned char work[32], *str;
!     register int i = 0, j = 0, total = 0, ret;
  
      for (p = work_tbl, total = 0; *buf; p++, total++, buf++) {
  	if ((buf = index(buf, '{')) == NULL) {
--- 290,296 ----
  {
      XipLocalKeySymTbl work_tbl[8], *p, *t;
      unsigned char work[32], *str;
!     register int i = 0, total = 0, ret;
  
      for (p = work_tbl, total = 0; *buf; p++, total++, buf++) {
  	if ((buf = index(buf, '{')) == NULL) {
***************
*** 781,794 ****
      return((XIM)xim);
  }
  
- static void
- _call_preedit_draw(ic, cb)
-     XipIC ic;
-     XIMCallback *cb;
- {
-     return;
- }
- 
  int
  _XipLocalCallCallbacks(ic)
      XipIC ic;
--- 781,786 ----
***************
*** 950,956 ****
      case -2: /* No match */
  	for (i = 0; i < xcvt->buf_cnt; i++) {
  	     if (_XipPutICQueue(ic, XIM_KEYSYM, 0, xcvt->buf[i].keysym,
! 				xcvt->buf[i].state, NULL) < 0)
  	       return(False);
  	}
  	ev->xkey.state = 0;
--- 942,948 ----
      case -2: /* No match */
  	for (i = 0; i < xcvt->buf_cnt; i++) {
  	     if (_XipPutICQueue(ic, XIM_KEYSYM, 0, xcvt->buf[i].keysym,
! 				xcvt->buf[i].state, 0, NULL) < 0)
  	       return(False);
  	}
  	ev->xkey.state = 0;
***************
*** 979,985 ****
  	for (i = 0; xcvt->tbl[c].to.tokey[i].keysym != XK_VoidSymbol; i++) {
  	     if (_XipPutICQueue(ic, XIM_KEYSYM, 0,
  				xcvt->tbl[c].to.tokey[i].keysym,
! 				xcvt->tbl[c].to.tokey[i].state,
  				xcvt->tbl[c].to.tokey[i].str) < 0)
  	       return(False);
  	}
--- 971,977 ----
  	for (i = 0; xcvt->tbl[c].to.tokey[i].keysym != XK_VoidSymbol; i++) {
  	     if (_XipPutICQueue(ic, XIM_KEYSYM, 0,
  				xcvt->tbl[c].to.tokey[i].keysym,
! 				xcvt->tbl[c].to.tokey[i].state, 1,
  				xcvt->tbl[c].to.tokey[i].str) < 0)
  	       return(False);
  	}
