index cea8fd3..265b162 100644
@@ -87,6 +87,7 @@ typedef struct _ConverterRec {
XrmRepresentation from, to;
XtTypeConverter converter;
+ XtReplicator replicator;
unsigned int do_ref_count:1;
unsigned int new_style:1;
@@ -94,11 +95,25 @@ typedef struct _ConverterRec {
-#define ConvertArgs(p) ((XtConvertArgList)((p)+1))
+#define ConvertArgs(p) ((XtConvertArgList)((p)+(ptrdiff_t)1))
/* used for old-style type converter cache only */
static Heap globalHeap = {NULL, NULL, 0};
+ XrmRepresentation from_type,
+ XrmRepresentation to_type,
+ XtTypeConverter converter,
+ XtConvertArgList convert_args,
+ XtCacheType cache_type,
+ XtDestructor destructor,
+ XtReplicator replicator,
void _XtSetDefaultConverterTable(
@@ -117,13 +132,11 @@ void _XtSetDefaultConverterTable(
for (i = CONVERTHASHSIZE; --i >= 0; ) {
for (rec = *globalConverterTable++; rec; rec = rec->next) {
- cache_type = rec->cache_type;
- cache_type |= XtCacheRefCount;
- _XtTableAddConverter(*table, rec->from, rec->to, rec->converter,
+ cache_type = rec->cache_type | (rec->do_ref_count & 0xff00);
+ TableAddConverter(*table, rec->from, rec->to, rec->converter,
ConvertArgs(rec), rec->num_args,
rec->new_style, cache_type,
- rec->destructor, True);
+ rec->destructor, rec->replicator, True);
@@ -155,10 +168,14 @@ typedef struct _CacheRec {
XtTypeConverter converter;
+ XtDestructor destructor;
+ XtReplicator replicator;
unsigned int conversion_succeeded:1;
unsigned int is_refcounted:1;
+ unsigned int ref_count;
unsigned int must_be_freed:1;
unsigned int from_is_value:1;
unsigned int to_is_value:1;
@@ -166,15 +183,7 @@ typedef struct _CacheRec {
-typedef struct _CacheRecExt {
- XtDestructor destructor;
-#define CEXT(p) ((CacheRecExt *)((p)+1))
-#define CARGS(p) ((p)->has_ext ? (XrmValue *)(CEXT(p)+1) : (XrmValue *)((p)+1))
+#define CARGS(p) (XrmValue *)((p)+(ptrdiff_t)1)
#define CACHEHASHSIZE 256
#define CACHEHASHMASK 255
@@ -183,6 +192,28 @@ typedef CachePtr CacheHashTable[CACHEHASHSIZE];
static CacheHashTable cacheHashTable;
void _XtTableAddConverter(
+ XrmRepresentation from_type,
+ XrmRepresentation to_type,
+ XtTypeConverter converter,
+ XtConvertArgList convert_args,
+ XtCacheType cache_type,
+ XtDestructor destructor,
+ unsigned short cache_flags;
+ cache_flags = cache_type & (XtCacheNone | XtCacheAll |
+ XtCacheByDisplay | XtCacheRefCount);
+ TableAddConverter(table, from_type, to_type, converter, convert_args, num_args,
+ new_style, cache_type, destructor, 0, global);
XrmRepresentation from_type,
XrmRepresentation to_type,
@@ -192,6 +223,7 @@ void _XtTableAddConverter(
+ XtReplicator replicator,
register ConverterPtr *pp;
@@ -215,6 +247,7 @@ void _XtTableAddConverter(
p->converter = converter;
p->destructor = destructor;
+ p->replicator = replicator;
@@ -224,21 +257,21 @@ void _XtTableAddConverter(
if (destructor || (cache_type & 0xff)) {
p->cache_type = cache_type & 0xff;
- if (cache_type & XtCacheRefCount)
- p->do_ref_count = True;
+ p->do_ref_count = cache_type & 0xff00;
p->cache_type = XtCacheNone;
-void XtSetTypeConverter(
+void _XtSetTypeConverter(
register _Xconst char* from_type,
register _Xconst char* to_type,
- XtTypeConverter converter,
+ XtTypeConverter converter,
XtConvertArgList convert_args,
- XtCacheType cache_type,
- XtDestructor destructor
+ XtCacheType cache_type,
+ XtDestructor destructor,
+ XtReplicator replicator
@@ -253,21 +286,41 @@ void XtSetTypeConverter(
to = XrmStringToRepresentation(to_type);
if (!process->globalConverterTable) {
- process->globalConverterTable = (ConverterTable)
- __XtCalloc(CONVERTHASHSIZE, (unsigned)sizeof(ConverterPtr));
+ process->globalConverterTable = (ConverterTable)
+ __XtCalloc(CONVERTHASHSIZE, (unsigned)sizeof(ConverterPtr));
- _XtTableAddConverter(process->globalConverterTable, from, to,
- converter, convert_args,
- num_args, True, cache_type, destructor, True);
+ TableAddConverter(process->globalConverterTable, from, to, converter,
+ convert_args, num_args, True, cache_type, destructor,
- _XtTableAddConverter(app->converterTable, from, to,
- converter, convert_args,
- num_args, True, cache_type, destructor, True);
+ TableAddConverter(app->converterTable, from, to, converter,
+ convert_args, num_args, True, cache_type,
+ destructor, replicator, True);
+void XtSetTypeConverter(
+ register _Xconst char* from_type,
+ register _Xconst char* to_type,
+ XtTypeConverter converter,
+ XtConvertArgList convert_args,
+ XtCacheType cache_type,
+ XtDestructor destructor
+ unsigned short cache_flags;
+ cache_flags = cache_type & (XtCacheNone | XtCacheAll |
+ XtCacheByDisplay | XtCacheRefCount);
+ _XtSetTypeConverter(from_type, to_type, converter, convert_args, num_args,
+ cache_flags, destructor, 0);
void XtAppSetTypeConverter(
register _Xconst char* from_type,
@@ -357,6 +410,7 @@ CacheEnter(
+ XtReplicator replicator,
register CachePtr *pHashEntry;
@@ -366,34 +420,22 @@ CacheEnter(
pHashEntry = &cacheHashTable[hash & CACHEHASHMASK];
- if ((succeeded && destructor) || do_ref) {
- p = (CachePtr) _XtHeapAlloc(heap, (sizeof(CacheRec) +
- num_args * sizeof(XrmValue)));
- CEXT(p)->prev = pHashEntry;
- CEXT(p)->destructor = succeeded ? destructor : NULL;
- CEXT(p)->closure = closure;
- CEXT(p)->ref_count = 1;
- p = (CachePtr)_XtHeapAlloc(heap, (sizeof(CacheRec) +
- num_args * sizeof(XrmValue)));
+ p = (CachePtr)_XtHeapAlloc(heap,
+ (sizeof(CacheRec) + num_args * sizeof(XrmValue)));
p->conversion_succeeded = succeeded;
p->is_refcounted = do_ref;
p->must_be_freed = do_free;
- if (p->next && p->next->has_ext)
- CEXT(p->next)->prev = &p->next;
p->tag = (XtPointer)heap;
p->converter = converter;
+ p->destructor = destructor;
+ p->replicator = replicator;
@@ -416,14 +458,31 @@ CacheEnter(
- } else if (to->size <= sizeof(p->
to.addr)) {
- XtMemmove(&p->
to.addr, to->addr, to->size);
- p->to_is_value = False;
- p->
to.addr = (XPointer)_XtHeapAlloc(heap, to->size);
- (void) memmove((char *)p->
to.addr, (char *)to->addr, to->size);
+ XPointer src_ptr, dest_ptr, gptr;
+ if ((size_t)to->size <= sizeof(p->
to.addr)) {
+ dest_ptr = (XPointer)&p->
to.addr;
+ p->to_is_value = False;
+ dest_ptr = p->
to.addr = (XPointer)_XtHeapAlloc(heap, to->size);
+ if (do_ref & XtCacheXmRefCount) {
+ gptr = (*(p->replicator))(*(XtPointer *)(to->addr));
+ src_ptr = (XtPointer)&gptr;
+ memmove(dest_ptr, src_ptr, to->size);
+ if ((succeeded && destructor) || do_ref) {
@@ -431,32 +490,39 @@ CacheEnter(
static void FreeCacheRec(
- if (CEXT(p)->destructor) {
- Cardinal num_args = p->num_args;
- (*CEXT(p)->destructor) (app, &toc, CEXT(p)->closure, args,
- *(CEXT(p)->prev) = p->next;
- if (p->next && p->next->has_ext)
- CEXT(p->next)->prev = CEXT(p)->prev;
- if (p->next && p->next->has_ext)
- CEXT(p->next)->prev = prev;
+ CachePtr cachep, *cachepp;
+ cachepp = &cacheHashTable[p->hash & CACHEHASHMASK];
+ while (cachep = *cachepp) {
+ *cachepp = cachep->next;
+ cachepp = &cachep->next;
+ Cardinal num_args=p->num_args;
+ (*p->destructor)(app, &toc, p->closure, args, &num_args);
@@ -480,18 +546,18 @@ void _XtCacheFlushTag(
- register CachePtr *prev;
+ register CachePtr *next_link;
for (i = CACHEHASHSIZE; --i >= 0;) {
- prev = &cacheHashTable[i];
- while ((rec = *prev)) {
+ next_link = &cacheHashTable[i];
+ while ((rec = *next_link)) {
+ next_link = &rec->next;
- FreeCacheRec(app, rec, prev);
+ FreeCacheRec(app, rec, False);
@@ -641,7 +707,12 @@ void XtDirectConvert(
/* Try to find cache entry for conversion */
hash = ((long) converter >> 2) + from->size + *((char *) from->addr);
- if (from->size > 1) hash += ((char *) from->addr)[1];
+ hash += ((char *) from->addr)[1];
+ hash += ((char *) from->addr)[6];
for (p = cacheHashTable[hash & CACHEHASHMASK]; p; p = p->next) {
@@ -685,7 +756,7 @@ void XtDirectConvert(
CacheEnter(&globalHeap, (XtTypeConverter)converter, args, num_args,
from, to, (to->addr != NULL), hash, False, False,
- (XtDestructor)NULL, NULL);
+ (XtDestructor)NULL, NULL, 0);
@@ -726,6 +797,7 @@ CallConverter(
+ XPointer from_addr, gptr;
if (!cP || ((cP->cache_type == XtCacheNone) && !cP->destructor)) {
@@ -738,7 +810,12 @@ CallConverter(
/* Try to find cache entry for conversion */
hash = ((long)(converter) >> 2) + from->size + *((char *) from->addr);
- if (from->size > 1) hash += ((char *) from->addr)[1];
+ hash += ((char *) from->addr)[1];
+ hash += ((char *) from->addr)[6];
if (cP->cache_type != XtCacheNone) {
for (p = cacheHashTable[hash & CACHEHASHMASK]; p; p = p->next){
@@ -770,14 +847,18 @@ CallConverter(
+ if (cP->do_ref_count & XtCacheXmRefCount) {
+ gptr = (*(p->replicator))(p->
to.addr);
+ from_addr = (XPointer)&gptr;
+ } else if (p->to_is_value) {
+ from_addr = (XPointer)&p->
to.addr;
- (void) memmove((char *)to->addr,
+ memmove((char *)to->addr, from_addr,
} else { /* old-style call */
@@ -787,7 +868,7 @@ CallConverter(
*cache_ref_return = (XtCacheRef)p;
@@ -810,7 +891,7 @@ CallConverter(
XtPointer closure = NULL;
unsigned int supplied_size = to->size;
- Boolean do_ref = cP->do_ref_count && cache_ref_return;
(*(XtTypeConverter)converter)(dpy, args, &num_args, from, to, &closure);
@@ -823,6 +904,8 @@ CallConverter(
+ do_ref = cache_ref_return ? cP->do_ref_count : 0;
if ((cP->cache_type == XtCacheNone) || do_ref) {
@@ -834,8 +917,12 @@ CallConverter(
heap = &XtDisplayToApplicationContext(dpy)->heap;
- p = CacheEnter(heap, converter, args, num_args, from, to, retval,
- hash, do_ref, do_free, cP->destructor, closure);
+ if (do_ref || !(cP->do_ref_count & XtCacheXmRefCount)) {
+ p = CacheEnter(heap, converter, args, num_args, from, to, retval,
+ hash, do_ref, do_free, cP->destructor,
+ cP->replicator, closure);
*cache_ref_return = (XtCacheRef)p;
else if (cache_ref_return)
@@ -1061,8 +1148,8 @@ void XtAppReleaseCacheRefs(
for (r = (CachePtr*)refs; (p = *r); r++) {
- if (p->is_refcounted && --(CEXT(p)->ref_count) == 0) {
- FreeCacheRec(app, p, NULL);
+ if (p->is_refcounted && (--p->ref_count) == 0) {
+ FreeCacheRec(app, p, True);
@@ -1078,7 +1165,6 @@ void XtCallbackReleaseCacheRefList(
XtAppReleaseCacheRefs( XtWidgetToApplicationContext(widget),
@@ -405,8 +405,7 @@ xtCreate(
CompileCallbacks(widget);
if (cache_refs != NULL) {
- XtAddCallback(widget, XtNdestroyCallback,
- XtCallbackReleaseCacheRefList, (XtPointer)cache_refs );
index 4ccf079..72ed668 100644
@@ -323,12 +323,15 @@ _XtAppInit(
* Save away argv and argc so we can set the properties later
- saved_argv = (String *)
- __XtMalloc( (Cardinal)((*argc_in_out + 1) * sizeof(String)) );
- for (i = 0 ; i < *argc_in_out ; i++) saved_argv[i] = (*argv_in_out)[i];
- saved_argv[i] = NULL; /* NULL terminate that sucker. */
+ if(*argv_in_out != NULL) {
+ saved_argv = (String *)
+ __XtMalloc( (Cardinal)((*argc_in_out + 1) * sizeof(String)) );
+ for (i = 0 ; i < *argc_in_out ; i++) saved_argv[i] = (*argv_in_out)[i];
+ saved_argv[i] = NULL; /* NULL terminate that sucker. */
*app_context_return = XtCreateApplicationContext();
index 11823d6..7c15e83 100644
@@ -563,6 +563,14 @@ void XtRegisterDrawable(
+/* need this for backward compatability */
+void _XtRegisterWindow(window, widget)
+ XtRegisterDrawable(XtDisplay(widget), (Drawable)window, widget);
void XtUnregisterDrawable(
@@ -613,6 +621,14 @@ void XtUnregisterDrawable(
+/* need this for backward compatability */
+void _XtUnregisterWindow(window, widget)
+ register Window window;
+ register Widget widget;
+ XtUnregisterDrawable(XtDisplay(widget), (Drawable)window);
static void ExpandWWTable(
@@ -330,6 +330,12 @@ _XtMakeGeometryRequest (
returnCode = (*manager)(widget, request, reply);
+ /* leob fix for bug 4153816 */
+ if (returnCode == XtGeometryDone && XtIsRealized(widget) &&
index 9783deb..2a5a8a8 100644
@@ -473,7 +473,7 @@ static String _XtDefaultLanguageProc(
if (! XSetLocaleModifiers(""))
XtWarning("X locale modifiers not supported, using default");
- return setlocale(LC_ALL, NULL); /* re-query in case overwritten */
+ return setlocale(LC_CTYPE, NULL); /* re-query in case overwritten */
XtLanguageProc XtSetLanguageProc(
@@ -994,8 +994,13 @@ Widget XtOpenApplication(XtAppContext *app_context_return,
XtSetArg(args[num], XtNscreen, DefaultScreenOfDisplay(dpy)); num++;
- XtSetArg(args[num], XtNargc, saved_argc); num++;
- XtSetArg(args[num], XtNargv, argv_in_out); num++;
+ /* only set argc and argv if argv_in_out[0] is not NULL */
+ if (argv_in_out && argv_in_out[0]) {
+ XtSetArg(args[num], XtNargc, saved_argc);
+ XtSetArg(args[num], XtNargv, argv_in_out);
merged_args = XtMergeArgLists(args_in, num_args_in, args, num);
libXt_la_LIBADD = @XT_LIBS@
-libXt_la_LDFLAGS = -version-number 6:0:0 -no-undefined
+libXt_la_LDFLAGS = -version-number 4:0:0 -no-undefined \
+ -M $(top_srcdir)/../../mapfile-vers -lc
# The util directory contains a program that builds some of the sources.
@@ -347,6 +347,51 @@ static void AdjustTimes (
+static void CheckAndTrimTimes(XtAppContext app, wait_times_ptr_t wt)
+ XtAppErrorMsg(app, "communicationError", "select",
+ XtCXtToolkitError, "Resetting timer values: zero_time=%lu:%lu, "
+ "wait_time=%lu:%lu, max_wait_time=%lu:%lu, cur_time=%lu:%lu",
+ memset(&zero_time, 0, sizeof(zero_time)); /* Ensure the integrity of */
+ { /* acceptable range if nec. */
+ /* significant at this level.) */
+ if (app->timerQueue != NULL) /* Do the same for the head of */
+ { /* the timer queue if necessary. */
+ TIMEDELTA(tv, app->timerQueue->te_timer_value, wt->cur_time);
+ XtAppErrorMsg(app, "selectError", "timerQueue",
+ XtCXtToolkitError, "timerQueue value %lu:%lu is invalid",
+ ADD_TIME(app->timerQueue->te_timer_value, wt->cur_time, tv);
@@ -629,20 +674,56 @@ WaitLoop:
* interrupt occured recalculate time value and wait again.
- if (errno == EINTR || errno == EAGAIN) {
- errno = 0; /* errno is not self reseting */
- errno = 0; /* errno is not self reseting */
- /* was it interrupted by a signal that we care about? */
- if (!ignoreSignals && app->signalQueue != NULL) {
- SignalEventRec *se_ptr = app->signalQueue;
- while (se_ptr != NULL) {
- if (se_ptr->se_notice) {
- if (block && howlong != NULL)
+ errno = 0; /* errno is not self reseting */
+ } else if (errno == EBADF) {
+ /* Bug 4482749 - If we have a bad FD stop monitoring it */
+ Cardinal param_count = 1;
+ * Get rid of any input procedures on the bad FD
+ * and regenerate the list of FDs we listen to.
+ while (app->input_list[i] != NULL) {
+ XtRemoveInput((XtInputId)app->input_list[i]);
+ InitFds (app, ignoreEvents, ignoreInputs, &wf);
+ sprintf(bad_fd, "%d", errno);
+ XtAppWarningMsg(app, "communicationError", "select",
+ "Select failed; error code %s",
+ sprintf(bad_fd, "EBADF error in select() call for file descriptor %d", i);
+ XtAppWarning(app, param);
+ } else if (errno == EINTR) {
+ /* was it interrupted by a signal that we care about? */
+ if (!ignoreSignals && app->signalQueue != NULL) {
+ SignalEventRec *se_ptr = app->signalQueue;
+ while (se_ptr != NULL) {
+ if (se_ptr->se_notice) {
+ if (block && howlong != NULL)
@@ -687,17 +768,33 @@ WaitLoop:
- Cardinal param_count = 1;
- sprintf( Errno, "%d", errno);
- XtAppWarningMsg(app, "communicationError","select",
- XtCXtToolkitError,"Select failed; error code %s",
+ } else if (errno == EINVAL) { /* (Can be recovered from if */
+ /* Do a non-blocking select to */
+ /* eliminate any timeout errors.*/
+ if (nfds == -1) { /* Now try to sort out the good */
+ if (errno == EINVAL) { /* and the bad from the ugly. */
+ char Errno[12]; /* (This is ugly). */
+ Cardinal param_count = 1;
+ sprintf(Errno, "%d", errno);
+ XtAppErrorMsg(app, "communicationError", "select",
+ XtCXtToolkitError, "Select failed; error code %s",
+ XtAppError(app, "EINVAL error in select() call");
+ } else { /* If the new error is not about */
+ /* an invalid select() parameter,*/
+ continue; /* then simply try again. */
+ } else { /* (Else the error appears to be */
+ /* in the timeout parameter.) */
+ CheckAndTrimTimes(app, &wt);
} /* timed out or input available */
@@ -750,6 +847,33 @@ WaitLoop:
#define SeCallProc(ptr) \
(*ptr->se_proc) (ptr->se_closure, (XtSignalId*)&ptr);
+int _XtwaitForSomething(
+ _XtBoolean ignoreTimers,
+ _XtBoolean ignoreInputs,
+ _XtBoolean ignoreEvents,
+ unsigned long *howlong,
+/* fix for bug 4185875 leob */
+return _XtWaitForSomething(app,
+ ignoreEvents, ignoreTimers, ignoreInputs, TRUE,
+/* fix for bug 4185875 leob */
+return _XtWaitForSomething(app,
+ ignoreEvents, ignoreTimers, ignoreInputs, TRUE,