1276N/Adiff --git a/configure.ac b/configure.ac
1276N/Aindex d15b326..28185fe 100644
1276N/A--- a/configure.ac
1276N/A+++ b/configure.ac
1276N/A@@ -72,6 +72,7 @@ AC_SUBST(LDFLAGS_FOR_BUILD)
1276N/A
1276N/A # Map function checks to old Imake #defines
946N/A case $host_os in
761N/A+ solaris*) ;; # our changes to NextEvent.c break if poll() is used
1276N/A # darwin through Snow Leopard has poll() but can't be used to poll character devices.
1276N/A darwin@<:@789@:>@*|darwin10*) ;;
1276N/A darwin*)
1276N/Adiff --git a/include/X11/Intrinsic.h b/include/X11/Intrinsic.h
1276N/Aindex d09acad..d30e01f 100644
1276N/A--- a/include/X11/Intrinsic.h
1276N/A+++ b/include/X11/Intrinsic.h
1072N/A@@ -125,6 +125,7 @@ typedef int XtCacheType;
761N/A #define XtCacheAll 0x002
761N/A #define XtCacheByDisplay 0x003
761N/A #define XtCacheRefCount 0x100
761N/A+#define XtCacheXmRefCount 0x200
351N/A
761N/A /****************************************************************
761N/A *
1072N/A@@ -253,6 +254,8 @@ typedef void (*XtDestructor)(
761N/A Cardinal* /* num_args */
761N/A );
351N/A
761N/A+typedef XtPointer (*XtReplicator)(XtPointer);
761N/A+
761N/A typedef Opaque XtCacheRef;
761N/A
761N/A typedef Opaque XtActionHookId;
1072N/A@@ -656,6 +659,17 @@ extern void XtSetTypeConverter(
761N/A XtDestructor /* destructor */
761N/A );
351N/A
761N/A+extern void _XtSetTypeConverter(
761N/A+ _Xconst _XtString /* from_type */,
761N/A+ _Xconst _XtString /* to_type */,
761N/A+ XtTypeConverter /* converter */,
761N/A+ XtConvertArgList /* convert_args */,
761N/A+ Cardinal /* num_args */,
761N/A+ XtCacheType /* cache_type */,
761N/A+ XtDestructor /* destructor */,
761N/A+ XtReplicator /* replicator */
761N/A+);
761N/A+
761N/A extern void XtAppSetTypeConverter(
761N/A XtAppContext /* app_context */,
761N/A _Xconst _XtString /* from_type */,
1276N/Adiff --git a/src/Convert.c b/src/Convert.c
1276N/Aindex cea8fd3..265b162 100644
1276N/A--- a/src/Convert.c
1276N/A+++ b/src/Convert.c
1072N/A@@ -87,6 +87,7 @@ typedef struct _ConverterRec {
351N/A XrmRepresentation from, to;
351N/A XtTypeConverter converter;
351N/A XtDestructor destructor;
761N/A+ XtReplicator replicator;
351N/A unsigned short num_args;
351N/A unsigned int do_ref_count:1;
351N/A unsigned int new_style:1;
1515N/A@@ -94,6 +95,20 @@ typedef struct _ConverterRec {
351N/A /* used for old-style type converter cache only */
351N/A static Heap globalHeap = {NULL, NULL, 0};
351N/A
351N/A+static
351N/A+void TableAddConverter(
351N/A+ ConverterTable table,
351N/A+ XrmRepresentation from_type,
351N/A+ XrmRepresentation to_type,
351N/A+ XtTypeConverter converter,
351N/A+ XtConvertArgList convert_args,
351N/A+ Cardinal num_args,
351N/A+ _XtBoolean new_style,
351N/A+ XtCacheType cache_type,
351N/A+ XtDestructor destructor,
351N/A+ XtReplicator replicator,
351N/A+ _XtBoolean global);
351N/A+
351N/A void _XtSetDefaultConverterTable(
351N/A ConverterTable *table)
351N/A {
1072N/A@@ -117,13 +132,11 @@ void _XtSetDefaultConverterTable(
351N/A XtCacheType cache_type;
351N/A for (i = CONVERTHASHSIZE; --i >= 0; ) {
351N/A for (rec = *globalConverterTable++; rec; rec = rec->next) {
351N/A- cache_type = rec->cache_type;
351N/A- if (rec->do_ref_count)
351N/A- cache_type |= XtCacheRefCount;
351N/A- _XtTableAddConverter(*table, rec->from, rec->to, rec->converter,
351N/A+ cache_type = rec->cache_type | (rec->do_ref_count & 0xff00);
351N/A+ TableAddConverter(*table, rec->from, rec->to, rec->converter,
351N/A ConvertArgs(rec), rec->num_args,
351N/A rec->new_style, cache_type,
351N/A- rec->destructor, True);
351N/A+ rec->destructor, rec->replicator, True);
351N/A }
351N/A }
351N/A }
1072N/A@@ -155,10 +168,14 @@ typedef struct _CacheRec {
351N/A XtPointer tag;
351N/A int hash;
351N/A XtTypeConverter converter;
351N/A+ XtDestructor destructor;
351N/A+ XtReplicator replicator;
351N/A+ XtPointer closure;
351N/A unsigned short num_args;
351N/A unsigned int conversion_succeeded:1;
351N/A unsigned int has_ext:1;
351N/A unsigned int is_refcounted:1;
351N/A+ unsigned int ref_count;
351N/A unsigned int must_be_freed:1;
351N/A unsigned int from_is_value:1;
351N/A unsigned int to_is_value:1;
1072N/A@@ -166,15 +183,7 @@ typedef struct _CacheRec {
351N/A XrmValue to;
351N/A } CacheRec;
351N/A
351N/A-typedef struct _CacheRecExt {
351N/A- CachePtr *prev;
351N/A- XtDestructor destructor;
351N/A- XtPointer closure;
351N/A- long ref_count;
351N/A-} CacheRecExt;
351N/A-
351N/A-#define CEXT(p) ((CacheRecExt *)((p)+1))
351N/A-#define CARGS(p) ((p)->has_ext ? (XrmValue *)(CEXT(p)+1) : (XrmValue *)((p)+1))
761N/A+#define CARGS(p) (XrmValue *)((p)+(ptrdiff_t)1)
761N/A
351N/A #define CACHEHASHSIZE 256
351N/A #define CACHEHASHMASK 255
1276N/A@@ -183,6 +192,28 @@ typedef CachePtr CacheHashTable[CACHEHASHSIZE];
351N/A static CacheHashTable cacheHashTable;
351N/A
351N/A void _XtTableAddConverter(
351N/A+ ConverterTable table,
351N/A+ XrmRepresentation from_type,
351N/A+ XrmRepresentation to_type,
351N/A+ XtTypeConverter converter,
351N/A+ XtConvertArgList convert_args,
351N/A+ Cardinal num_args,
351N/A+ _XtBoolean new_style,
351N/A+ XtCacheType cache_type,
351N/A+ XtDestructor destructor,
351N/A+ _XtBoolean global)
351N/A+{
351N/A+
351N/A+ unsigned short cache_flags;
351N/A+
351N/A+ cache_flags = cache_type & (XtCacheNone | XtCacheAll |
351N/A+ XtCacheByDisplay | XtCacheRefCount);
351N/A+
351N/A+ TableAddConverter(table, from_type, to_type, converter, convert_args, num_args,
351N/A+ new_style, cache_type, destructor, 0, global);
351N/A+}
351N/A+
351N/A+void TableAddConverter(
351N/A ConverterTable table,
351N/A XrmRepresentation from_type,
351N/A XrmRepresentation to_type,
1072N/A@@ -192,6 +223,7 @@ void _XtTableAddConverter(
351N/A _XtBoolean new_style,
351N/A XtCacheType cache_type,
351N/A XtDestructor destructor,
351N/A+ XtReplicator replicator,
351N/A _XtBoolean global)
351N/A {
351N/A register ConverterPtr *pp;
1072N/A@@ -215,6 +247,7 @@ void _XtTableAddConverter(
351N/A p->to = to_type;
351N/A p->converter = converter;
351N/A p->destructor = destructor;
351N/A+ p->replicator = replicator;
351N/A p->num_args = num_args;
351N/A p->global = global;
351N/A args = ConvertArgs(p);
1072N/A@@ -224,21 +257,21 @@ void _XtTableAddConverter(
351N/A p->do_ref_count = False;
351N/A if (destructor || (cache_type & 0xff)) {
351N/A p->cache_type = cache_type & 0xff;
351N/A- if (cache_type & XtCacheRefCount)
351N/A- p->do_ref_count = True;
351N/A+ p->do_ref_count = cache_type & 0xff00;
351N/A } else {
351N/A p->cache_type = XtCacheNone;
351N/A }
351N/A }
351N/A
351N/A-void XtSetTypeConverter(
351N/A+void _XtSetTypeConverter(
351N/A register _Xconst char* from_type,
351N/A register _Xconst char* to_type,
351N/A- XtTypeConverter converter,
351N/A+ XtTypeConverter converter,
351N/A XtConvertArgList convert_args,
351N/A- Cardinal num_args,
351N/A- XtCacheType cache_type,
351N/A- XtDestructor destructor
351N/A+ Cardinal num_args,
351N/A+ XtCacheType cache_type,
351N/A+ XtDestructor destructor,
351N/A+ XtReplicator replicator
351N/A )
351N/A {
351N/A ProcessContext process;
1072N/A@@ -253,21 +286,41 @@ void XtSetTypeConverter(
351N/A to = XrmStringToRepresentation(to_type);
351N/A
351N/A if (!process->globalConverterTable) {
351N/A- process->globalConverterTable = (ConverterTable)
351N/A- __XtCalloc(CONVERTHASHSIZE, (unsigned)sizeof(ConverterPtr));
351N/A+ process->globalConverterTable = (ConverterTable)
351N/A+ __XtCalloc(CONVERTHASHSIZE, (unsigned)sizeof(ConverterPtr));
351N/A }
351N/A- _XtTableAddConverter(process->globalConverterTable, from, to,
351N/A- converter, convert_args,
351N/A- num_args, True, cache_type, destructor, True);
351N/A+
351N/A+ TableAddConverter(process->globalConverterTable, from, to, converter,
351N/A+ convert_args, num_args, True, cache_type, destructor,
351N/A+ replicator, True);
351N/A while (app) {
351N/A- _XtTableAddConverter(app->converterTable, from, to,
351N/A- converter, convert_args,
351N/A- num_args, True, cache_type, destructor, True);
351N/A+ TableAddConverter(app->converterTable, from, to, converter,
351N/A+ convert_args, num_args, True, cache_type,
351N/A+ destructor, replicator, True);
351N/A app = app->next;
351N/A }
351N/A UNLOCK_PROCESS;
351N/A }
351N/A
351N/A+void XtSetTypeConverter(
351N/A+ register _Xconst char* from_type,
351N/A+ register _Xconst char* to_type,
351N/A+ XtTypeConverter converter,
351N/A+ XtConvertArgList convert_args,
351N/A+ Cardinal num_args,
351N/A+ XtCacheType cache_type,
351N/A+ XtDestructor destructor
351N/A+ )
351N/A+{
351N/A+ unsigned short cache_flags;
351N/A+
351N/A+ cache_flags = cache_type & (XtCacheNone | XtCacheAll |
351N/A+ XtCacheByDisplay | XtCacheRefCount);
351N/A+
351N/A+ _XtSetTypeConverter(from_type, to_type, converter, convert_args, num_args,
351N/A+ cache_flags, destructor, 0);
351N/A+}
351N/A+
351N/A void XtAppSetTypeConverter(
351N/A XtAppContext app,
351N/A register _Xconst char* from_type,
1072N/A@@ -357,6 +410,7 @@ CacheEnter(
351N/A Boolean do_ref,
351N/A Boolean do_free,
351N/A XtDestructor destructor,
351N/A+ XtReplicator replicator,
351N/A XtPointer closure)
351N/A {
351N/A register CachePtr *pHashEntry;
1072N/A@@ -366,34 +420,22 @@ CacheEnter(
351N/A LOCK_PROCESS;
351N/A pHashEntry = &cacheHashTable[hash & CACHEHASHMASK];
351N/A
351N/A- if ((succeeded && destructor) || do_ref) {
351N/A- p = (CachePtr) _XtHeapAlloc(heap, (sizeof(CacheRec) +
351N/A- sizeof(CacheRecExt) +
351N/A- num_args * sizeof(XrmValue)));
351N/A- CEXT(p)->prev = pHashEntry;
351N/A- CEXT(p)->destructor = succeeded ? destructor : NULL;
351N/A- CEXT(p)->closure = closure;
351N/A- CEXT(p)->ref_count = 1;
351N/A- p->has_ext = True;
351N/A- }
351N/A- else {
351N/A- p = (CachePtr)_XtHeapAlloc(heap, (sizeof(CacheRec) +
351N/A- num_args * sizeof(XrmValue)));
351N/A- p->has_ext = False;
351N/A- }
351N/A+ p = (CachePtr)_XtHeapAlloc(heap,
351N/A+ (sizeof(CacheRec) + num_args * sizeof(XrmValue)));
351N/A+
351N/A if (!to->addr)
351N/A succeeded = False;
351N/A p->conversion_succeeded = succeeded;
351N/A p->is_refcounted = do_ref;
351N/A p->must_be_freed = do_free;
351N/A p->next = *pHashEntry;
351N/A- if (p->next && p->next->has_ext)
351N/A- CEXT(p->next)->prev = &p->next;
351N/A-
351N/A *pHashEntry = p;
351N/A p->tag = (XtPointer)heap;
351N/A p->hash = hash;
351N/A p->converter = converter;
351N/A+ p->destructor = destructor;
351N/A+ p->replicator = replicator;
351N/A+ p->closure = closure;
351N/A p->from.size = from->size;
351N/A if (from->size <= sizeof(p->from.addr)) {
351N/A p->from_is_value = True;
1072N/A@@ -416,14 +458,31 @@ CacheEnter(
351N/A if (!succeeded) {
351N/A p->to_is_value = False;
351N/A p->to.addr = NULL;
351N/A- } else if (to->size <= sizeof(p->to.addr)) {
351N/A- p->to_is_value = True;
351N/A- XtMemmove(&p->to.addr, to->addr, to->size);
351N/A } else {
351N/A- p->to_is_value = False;
351N/A- p->to.addr = (XPointer)_XtHeapAlloc(heap, to->size);
351N/A- (void) memmove((char *)p->to.addr, (char *)to->addr, to->size);
351N/A+ XPointer src_ptr, dest_ptr, gptr;
351N/A+
351N/A+ if ((size_t)to->size <= sizeof(p->to.addr)) {
351N/A+ p->to_is_value = True;
351N/A+ dest_ptr = (XPointer)&p->to.addr;
351N/A+ } else {
351N/A+ p->to_is_value = False;
351N/A+ dest_ptr = p->to.addr = (XPointer)_XtHeapAlloc(heap, to->size);
351N/A+ }
351N/A+
351N/A+ if (do_ref & XtCacheXmRefCount) {
351N/A+ gptr = (*(p->replicator))(*(XtPointer *)(to->addr));
351N/A+ src_ptr = (XtPointer)&gptr;
351N/A+ } else {
351N/A+ src_ptr = to->addr;
351N/A+ }
351N/A+
351N/A+ memmove(dest_ptr, src_ptr, to->size);
1276N/A+ }
351N/A+
351N/A+ if ((succeeded && destructor) || do_ref) {
351N/A+ p->ref_count = 1;
1276N/A }
351N/A+
351N/A UNLOCK_PROCESS;
351N/A return p;
351N/A }
1072N/A@@ -431,32 +490,39 @@ CacheEnter(
351N/A static void FreeCacheRec(
351N/A XtAppContext app,
351N/A CachePtr p,
351N/A- CachePtr *prev)
351N/A+ Boolean clean_table)
351N/A {
351N/A LOCK_PROCESS;
351N/A- if (p->has_ext) {
351N/A- if (CEXT(p)->destructor) {
351N/A- Cardinal num_args = p->num_args;
351N/A- XrmValue *args = NULL;
351N/A- XrmValue toc;
351N/A- if (num_args)
351N/A- args = CARGS(p);
351N/A- toc.size = p->to.size;
351N/A- if (p->to_is_value)
351N/A- toc.addr = (XPointer)&p->to.addr;
351N/A- else
351N/A- toc.addr = p->to.addr;
351N/A- (*CEXT(p)->destructor) (app, &toc, CEXT(p)->closure, args,
351N/A- &num_args);
351N/A- }
351N/A- *(CEXT(p)->prev) = p->next;
351N/A- if (p->next && p->next->has_ext)
351N/A- CEXT(p->next)->prev = CEXT(p)->prev;
351N/A- } else {
351N/A- *prev = p->next;
351N/A- if (p->next && p->next->has_ext)
351N/A- CEXT(p->next)->prev = prev;
351N/A+ if (clean_table) {
351N/A+ CachePtr cachep, *cachepp;
351N/A+
351N/A+ cachepp = &cacheHashTable[p->hash & CACHEHASHMASK];
351N/A+ while (cachep = *cachepp) {
351N/A+ if (p == cachep) {
351N/A+ *cachepp = cachep->next;
351N/A+ break;
351N/A+ }
351N/A+ cachepp = &cachep->next;
351N/A+ }
761N/A+ }
351N/A+
351N/A+ if (p->destructor) {
351N/A+ Cardinal num_args=p->num_args;
351N/A+ XrmValue *args=NULL;
351N/A+ XrmValue toc;
351N/A+
351N/A+ if (num_args) {
351N/A+ args = CARGS(p);
351N/A+ }
351N/A+ toc.size = p->to.size;
351N/A+ if (p->to_is_value) {
351N/A+ toc.addr = (XPointer)&p->to.addr;
351N/A+ } else {
351N/A+ toc.addr = p->to.addr;
351N/A+ }
351N/A+ (*p->destructor)(app, &toc, p->closure, args, &num_args);
761N/A }
351N/A+
351N/A if (p->must_be_freed) {
351N/A register int i;
351N/A if (!p->from_is_value)
1072N/A@@ -480,18 +546,18 @@ void _XtCacheFlushTag(
351N/A XtPointer tag)
351N/A {
351N/A int i;
351N/A- register CachePtr *prev;
351N/A register CachePtr rec;
351N/A+ register CachePtr *next_link;
351N/A
351N/A LOCK_PROCESS;
351N/A for (i = CACHEHASHSIZE; --i >= 0;) {
351N/A- prev = &cacheHashTable[i];
351N/A- while ((rec = *prev)) {
351N/A+ next_link = &cacheHashTable[i];
351N/A+ while ((rec = *next_link)) {
351N/A+ next_link = &rec->next;
351N/A if (rec->tag == tag)
351N/A- FreeCacheRec(app, rec, prev);
351N/A- else
351N/A- prev = &rec->next;
351N/A+ FreeCacheRec(app, rec, False);
351N/A }
351N/A+ cacheHashTable[i] = 0;
351N/A }
351N/A UNLOCK_PROCESS;
351N/A }
1072N/A@@ -641,7 +707,12 @@ void XtDirectConvert(
351N/A LOCK_PROCESS;
351N/A /* Try to find cache entry for conversion */
351N/A hash = ((long) converter >> 2) + from->size + *((char *) from->addr);
351N/A- if (from->size > 1) hash += ((char *) from->addr)[1];
351N/A+ if (from->size > 1) {
351N/A+ if (sizeof(long) == 4)
351N/A+ hash += ((char *) from->addr)[1];
351N/A+ else
351N/A+ hash += ((char *) from->addr)[6];
351N/A+ }
351N/A
351N/A for (p = cacheHashTable[hash & CACHEHASHMASK]; p; p = p->next) {
351N/A if ((p->hash == hash)
1072N/A@@ -685,7 +756,7 @@ void XtDirectConvert(
351N/A {
351N/A CacheEnter(&globalHeap, (XtTypeConverter)converter, args, num_args,
351N/A from, to, (to->addr != NULL), hash, False, False,
351N/A- (XtDestructor)NULL, NULL);
351N/A+ (XtDestructor)NULL, NULL, 0);
351N/A }
351N/A UNLOCK_PROCESS;
351N/A }
1072N/A@@ -726,6 +797,7 @@ CallConverter(
351N/A int hash;
351N/A Cardinal i;
351N/A Boolean retval;
351N/A+ XPointer from_addr, gptr;
351N/A
351N/A if (!cP || ((cP->cache_type == XtCacheNone) && !cP->destructor)) {
351N/A XtPointer closure;
1072N/A@@ -738,7 +810,12 @@ CallConverter(
351N/A LOCK_PROCESS;
351N/A /* Try to find cache entry for conversion */
351N/A hash = ((long)(converter) >> 2) + from->size + *((char *) from->addr);
351N/A- if (from->size > 1) hash += ((char *) from->addr)[1];
351N/A+ if (from->size > 1) {
351N/A+ if (sizeof(long) == 4)
351N/A+ hash += ((char *) from->addr)[1];
351N/A+ else
351N/A+ hash += ((char *) from->addr)[6];
351N/A+ }
351N/A
351N/A if (cP->cache_type != XtCacheNone) {
351N/A for (p = cacheHashTable[hash & CACHEHASHMASK]; p; p = p->next){
1072N/A@@ -770,14 +847,18 @@ CallConverter(
351N/A UNLOCK_PROCESS;
351N/A return False;
351N/A }
351N/A- to->size = p->to.size;
351N/A- if (p->to_is_value) {
351N/A- XtMemmove(to->addr, &p->to.addr,
351N/A- to->size);
761N/A+ if (cP->do_ref_count & XtCacheXmRefCount) {
351N/A+ gptr = (*(p->replicator))(p->to.addr);
351N/A+ from_addr = (XPointer)&gptr;
351N/A+ } else if (p->to_is_value) {
351N/A+ from_addr = (XPointer)&p->to.addr;
351N/A } else {
351N/A- (void) memmove((char *)to->addr,
351N/A- (char *)p->to.addr, to->size);
351N/A+ from_addr = p->to.addr;
351N/A }
351N/A+
351N/A+ to->size = p->to.size;
351N/A+ memmove((char *)to->addr, from_addr,
351N/A+ to->size);
351N/A } else { /* old-style call */
351N/A to->size = p->to.size;
351N/A if (p->to_is_value)
1072N/A@@ -787,7 +868,7 @@ CallConverter(
351N/A }
351N/A }
351N/A if (p->is_refcounted) {
351N/A- CEXT(p)->ref_count++;
351N/A+ p->ref_count++;
351N/A if (cache_ref_return)
351N/A *cache_ref_return = (XtCacheRef)p;
351N/A else
1072N/A@@ -810,7 +891,7 @@ CallConverter(
351N/A Heap *heap;
351N/A XtPointer closure = NULL;
351N/A unsigned int supplied_size = to->size;
351N/A- Boolean do_ref = cP->do_ref_count && cache_ref_return;
351N/A+ unsigned short do_ref;
351N/A Boolean do_free = False;
351N/A Boolean retval =
351N/A (*(XtTypeConverter)converter)(dpy, args, &num_args, from, to, &closure);
1072N/A@@ -823,6 +904,8 @@ CallConverter(
351N/A return False;
351N/A }
351N/A
351N/A+ do_ref = cache_ref_return ? cP->do_ref_count : 0;
351N/A+
351N/A if ((cP->cache_type == XtCacheNone) || do_ref) {
351N/A heap = NULL;
351N/A do_free = True;
1072N/A@@ -834,8 +917,12 @@ CallConverter(
351N/A else
351N/A heap = &XtDisplayToApplicationContext(dpy)->heap;
351N/A
351N/A- p = CacheEnter(heap, converter, args, num_args, from, to, retval,
351N/A- hash, do_ref, do_free, cP->destructor, closure);
351N/A+ if (do_ref || !(cP->do_ref_count & XtCacheXmRefCount)) {
351N/A+ p = CacheEnter(heap, converter, args, num_args, from, to, retval,
351N/A+ hash, do_ref, do_free, cP->destructor,
351N/A+ cP->replicator, closure);
351N/A+ }
351N/A+
351N/A if (do_ref)
351N/A *cache_ref_return = (XtCacheRef)p;
351N/A else if (cache_ref_return)
1072N/A@@ -1061,8 +1148,8 @@ void XtAppReleaseCacheRefs(
351N/A LOCK_APP(app);
351N/A LOCK_PROCESS;
351N/A for (r = (CachePtr*)refs; (p = *r); r++) {
351N/A- if (p->is_refcounted && --(CEXT(p)->ref_count) == 0) {
351N/A- FreeCacheRec(app, p, NULL);
351N/A+ if (p->is_refcounted && (--p->ref_count) == 0) {
351N/A+ FreeCacheRec(app, p, True);
351N/A }
351N/A }
351N/A UNLOCK_PROCESS;
1072N/A@@ -1078,7 +1165,6 @@ void XtCallbackReleaseCacheRefList(
351N/A {
351N/A XtAppReleaseCacheRefs( XtWidgetToApplicationContext(widget),
351N/A (XtCacheRef*)closure );
351N/A- XtFree(closure);
351N/A }
351N/A
761N/A
1276N/Adiff --git a/src/Create.c b/src/Create.c
1276N/Aindex da00192..b756223 100644
1276N/A--- a/src/Create.c
1276N/A+++ b/src/Create.c
1072N/A@@ -405,8 +405,7 @@ xtCreate(
761N/A CompileCallbacks(widget);
761N/A
761N/A if (cache_refs != NULL) {
761N/A- XtAddCallback(widget, XtNdestroyCallback,
761N/A- XtCallbackReleaseCacheRefList, (XtPointer)cache_refs );
761N/A+ XtFree(cache_refs);
761N/A }
761N/A
761N/A wsize = widget_class->core_class.widget_size;
1276N/Adiff --git a/src/Display.c b/src/Display.c
1276N/Aindex 4ccf079..72ed668 100644
1276N/A--- a/src/Display.c
1276N/A+++ b/src/Display.c
1072N/A@@ -323,12 +323,15 @@ _XtAppInit(
351N/A * Save away argv and argc so we can set the properties later
351N/A */
351N/A
351N/A- saved_argv = (String *)
351N/A- __XtMalloc( (Cardinal)((*argc_in_out + 1) * sizeof(String)) );
761N/A-
761N/A- for (i = 0 ; i < *argc_in_out ; i++) saved_argv[i] = (*argv_in_out)[i];
761N/A- saved_argv[i] = NULL; /* NULL terminate that sucker. */
761N/A-
351N/A+ if(*argv_in_out != NULL) {
351N/A+ saved_argv = (String *)
351N/A+ __XtMalloc( (Cardinal)((*argc_in_out + 1) * sizeof(String)) );
761N/A+
351N/A+ for (i = 0 ; i < *argc_in_out ; i++) saved_argv[i] = (*argv_in_out)[i];
351N/A+ saved_argv[i] = NULL; /* NULL terminate that sucker. */
351N/A+ } else {
351N/A+ saved_argv = NULL;
351N/A+ }
351N/A
351N/A *app_context_return = XtCreateApplicationContext();
351N/A
1276N/Adiff --git a/src/Event.c b/src/Event.c
1276N/Aindex 11823d6..7c15e83 100644
1276N/A--- a/src/Event.c
1276N/A+++ b/src/Event.c
1072N/A@@ -563,6 +563,14 @@ void XtRegisterDrawable(
351N/A UNLOCK_APP(app);
351N/A }
351N/A
351N/A+/* need this for backward compatability */
1515N/A+void _XtRegisterWindow(
1515N/A+ Window window,
1515N/A+ Widget widget)
351N/A+{
351N/A+ XtRegisterDrawable(XtDisplay(widget), (Drawable)window, widget);
351N/A+}
351N/A+
351N/A void XtUnregisterDrawable(
351N/A Display* display,
351N/A Drawable drawable)
1072N/A@@ -613,6 +621,14 @@ void XtUnregisterDrawable(
351N/A UNLOCK_APP(app);
351N/A }
351N/A
351N/A+/* need this for backward compatability */
1515N/A+void _XtUnregisterWindow(
1515N/A+ register Window window,
1515N/A+ register Widget widget)
351N/A+{
351N/A+ XtUnregisterDrawable(XtDisplay(widget), (Drawable)window);
351N/A+}
351N/A+
351N/A static void ExpandWWTable(
351N/A register WWTable tab)
351N/A {
1276N/Adiff --git a/src/Geometry.c b/src/Geometry.c
1276N/Aindex d64c8e2..c8ddbd6 100644
1276N/A--- a/src/Geometry.c
1276N/A+++ b/src/Geometry.c
1072N/A@@ -330,6 +330,12 @@ _XtMakeGeometryRequest (
351N/A } else {
351N/A returnCode = (*manager)(widget, request, reply);
351N/A }
351N/A+
351N/A+ /* leob fix for bug 4153816 */
351N/A+ if (returnCode == XtGeometryDone && XtIsRealized(widget) &&
351N/A+ (widget->core.width != request->width ||
351N/A+ widget->core.height != request->height) )
351N/A+ return XtGeometryYes;
351N/A }
351N/A
351N/A /*
1276N/Adiff --git a/src/Initialize.c b/src/Initialize.c
1276N/Aindex 9783deb..2a5a8a8 100644
1276N/A--- a/src/Initialize.c
1276N/A+++ b/src/Initialize.c
1276N/A@@ -473,7 +473,7 @@ static String _XtDefaultLanguageProc(
351N/A if (! XSetLocaleModifiers(""))
351N/A XtWarning("X locale modifiers not supported, using default");
351N/A
351N/A- return setlocale(LC_ALL, NULL); /* re-query in case overwritten */
351N/A+ return setlocale(LC_CTYPE, NULL); /* re-query in case overwritten */
351N/A }
351N/A
351N/A XtLanguageProc XtSetLanguageProc(
1276N/A@@ -994,8 +994,13 @@ Widget XtOpenApplication(XtAppContext *app_context_return,
351N/A
351N/A LOCK_APP(app_con);
351N/A XtSetArg(args[num], XtNscreen, DefaultScreenOfDisplay(dpy)); num++;
351N/A- XtSetArg(args[num], XtNargc, saved_argc); num++;
351N/A- XtSetArg(args[num], XtNargv, argv_in_out); num++;
351N/A+ /* only set argc and argv if argv_in_out[0] is not NULL */
351N/A+ if (argv_in_out && argv_in_out[0]) {
351N/A+ XtSetArg(args[num], XtNargc, saved_argc);
351N/A+ num++;
351N/A+ XtSetArg(args[num], XtNargv, argv_in_out);
351N/A+ num++;
351N/A+ }
351N/A
351N/A merged_args = XtMergeArgLists(args_in, num_args_in, args, num);
351N/A num += num_args_in;
1276N/Adiff --git a/src/Makefile.am b/src/Makefile.am
1276N/Aindex cf54a5c..a786d94 100644
1276N/A--- a/src/Makefile.am
1276N/A+++ b/src/Makefile.am
761N/A@@ -74,7 +74,8 @@ DISTCLEANFILES = StringDefs.c
761N/A
761N/A libXt_la_LIBADD = @XT_LIBS@
761N/A
761N/A-libXt_la_LDFLAGS = -version-number 6:0:0 -no-undefined
761N/A+libXt_la_LDFLAGS = -version-number 4:0:0 -no-undefined \
1466N/A+ -M $(top_srcdir)/../mapfile-vers -lc
761N/A
761N/A #
1276N/A # The util directory contains a program that builds some of the sources.
1276N/Adiff --git a/src/NextEvent.c b/src/NextEvent.c
1276N/Aindex b1f7bc7..c9b53db 100644
1276N/A--- a/src/NextEvent.c
1276N/A+++ b/src/NextEvent.c
1072N/A@@ -347,6 +347,51 @@ static void AdjustTimes (
351N/A #endif
351N/A }
351N/A
351N/A+static void CheckAndTrimTimes(XtAppContext app, wait_times_ptr_t wt)
351N/A+{
351N/A+ struct timeval tv;
351N/A+ String pptrs[8];
351N/A+ Cardinal nbr_parms;
761N/A+
351N/A+ pptrs[0] = (String)zero_time.tv_sec;
351N/A+ pptrs[1] = (String)zero_time.tv_usec;
351N/A+ pptrs[2] = (String)wt->wait_time.tv_sec;
351N/A+ pptrs[3] = (String)wt->wait_time.tv_usec;
351N/A+ pptrs[4] = (String)wt->max_wait_time.tv_sec;
351N/A+ pptrs[5] = (String)wt->max_wait_time.tv_usec;
351N/A+ pptrs[6] = (String)wt->cur_time.tv_sec;
351N/A+ pptrs[7] = (String)wt->cur_time.tv_usec;
351N/A+ nbr_parms = 8;
351N/A+ XtAppErrorMsg(app, "communicationError", "select",
351N/A+ XtCXtToolkitError, "Resetting timer values: zero_time=%lu:%lu, "
351N/A+ "wait_time=%lu:%lu, max_wait_time=%lu:%lu, cur_time=%lu:%lu",
351N/A+ pptrs, &nbr_parms);
351N/A+
351N/A+ memset(&zero_time, 0, sizeof(zero_time)); /* Ensure the integrity of */
351N/A+ /* zero_time. */
351N/A+ if (wt->max_wait_time.tv_sec > 99999999) /* Bring max_wait_time back into */
351N/A+ { /* acceptable range if nec. */
351N/A+ wt->max_wait_time.tv_sec &= 0xFFFFF;
351N/A+ wt->max_wait_time.tv_usec = 0; /* (Fractions of a sec are in- */
351N/A+ /* significant at this level.) */
351N/A+ }
351N/A+ if (app->timerQueue != NULL) /* Do the same for the head of */
351N/A+ { /* the timer queue if necessary. */
351N/A+ TIMEDELTA(tv, app->timerQueue->te_timer_value, wt->cur_time);
351N/A+ if (tv.tv_sec > 99999999)
351N/A+ {
351N/A+ pptrs[0] = (String)app->timerQueue->te_timer_value.tv_sec;
351N/A+ pptrs[1] = (String)app->timerQueue->te_timer_value.tv_usec;
351N/A+ nbr_parms = 2;
351N/A+ XtAppErrorMsg(app, "selectError", "timerQueue",
351N/A+ XtCXtToolkitError, "timerQueue value %lu:%lu is invalid",
351N/A+ pptrs, &nbr_parms);
351N/A+ tv.tv_sec &= 0xFFFFF;
351N/A+ tv.tv_usec = 0;
351N/A+ ADD_TIME(app->timerQueue->te_timer_value, wt->cur_time, tv);
351N/A+ }
351N/A+ }
351N/A+}
761N/A
351N/A static int IoWait (
351N/A wait_times_ptr_t wt,
1072N/A@@ -629,20 +674,56 @@ WaitLoop:
351N/A /*
351N/A * interrupt occured recalculate time value and wait again.
351N/A */
351N/A- if (errno == EINTR || errno == EAGAIN) {
351N/A- if (errno == EAGAIN) {
351N/A- errno = 0; /* errno is not self reseting */
351N/A- continue;
351N/A- }
351N/A- errno = 0; /* errno is not self reseting */
761N/A-
761N/A- /* was it interrupted by a signal that we care about? */
761N/A- if (!ignoreSignals && app->signalQueue != NULL) {
761N/A- SignalEventRec *se_ptr = app->signalQueue;
761N/A- while (se_ptr != NULL) {
761N/A- if (se_ptr->se_notice) {
761N/A- if (block && howlong != NULL)
761N/A- AdjustHowLong (howlong, &wt.start_time);
351N/A+ if (errno == EAGAIN) {
351N/A+ errno = 0; /* errno is not self reseting */
351N/A+ continue;
351N/A+ } else if (errno == EBADF) {
351N/A+ /* Bug 4482749 - If we have a bad FD stop monitoring it */
351N/A+ int i;
351N/A+ struct timeval tv={0};
351N/A+ for (i = 0; i < wf.nfds; i++) {
351N/A+ if (FD_ISSET(i, &wf.rmask) || FD_ISSET(i, &wf.wmask) ||
351N/A+ FD_ISSET(i, &wf.emask)) {
351N/A+ if (select(i + 1, &wf.rmask, &wf.wmask, &wf.emask, &tv)
351N/A+ == -1) {
351N/A+ char bad_fd[55];
351N/A+ String param = bad_fd;
351N/A+ Cardinal param_count = 1;
761N/A+
351N/A+ /*
351N/A+ * Get rid of any input procedures on the bad FD
351N/A+ * and regenerate the list of FDs we listen to.
351N/A+ */
351N/A+ while (app->input_list[i] != NULL) {
351N/A+ XtRemoveInput((XtInputId)app->input_list[i]);
351N/A+ }
351N/A+ InitFds (app, ignoreEvents, ignoreInputs, &wf);
351N/A+
351N/A+ sprintf(bad_fd, "%d", errno);
351N/A+ XtAppWarningMsg(app, "communicationError", "select",
351N/A+ XtCXtToolkitError,
351N/A+ "Select failed; error code %s",
351N/A+ &param, &param_count);
351N/A+
351N/A+ sprintf(bad_fd, "EBADF error in select() call for file descriptor %d", i);
351N/A+ XtAppWarning(app, param);
351N/A+
351N/A+ }
351N/A+ }
351N/A+ }
351N/A+
351N/A+ return -1;
351N/A+
351N/A+ } else if (errno == EINTR) {
351N/A+ errno = 0;
351N/A+
351N/A+ /* was it interrupted by a signal that we care about? */
351N/A+ if (!ignoreSignals && app->signalQueue != NULL) {
351N/A+ SignalEventRec *se_ptr = app->signalQueue;
351N/A+ while (se_ptr != NULL) {
351N/A+ if (se_ptr->se_notice) {
351N/A+ if (block && howlong != NULL)
351N/A+ AdjustHowLong (howlong, &wt.start_time);
351N/A #ifdef USE_POLL
761N/A XtStackFree ((XtPointer) wf.fdlist, fdlist);
351N/A #endif
1072N/A@@ -687,17 +768,33 @@ WaitLoop:
351N/A #endif
761N/A nfds = 0;
761N/A }
351N/A- } else {
351N/A- char Errno[12];
351N/A- String param = Errno;
351N/A- Cardinal param_count = 1;
761N/A-
351N/A- sprintf( Errno, "%d", errno);
351N/A- XtAppWarningMsg(app, "communicationError","select",
351N/A- XtCXtToolkitError,"Select failed; error code %s",
351N/A- &param, &param_count);
351N/A- continue;
351N/A- }
761N/A+ } else if (errno == EINVAL) { /* (Can be recovered from if */
761N/A+ struct timeval tv={0};
761N/A+
351N/A+ nfds = Select(wf.nfds, &wf.rmask, &wf.wmask, &wf.emask, &tv);
351N/A+ /* Do a non-blocking select to */
351N/A+ /* eliminate any timeout errors.*/
351N/A+ if (nfds == -1) { /* Now try to sort out the good */
351N/A+ if (errno == EINVAL) { /* and the bad from the ugly. */
351N/A+ char Errno[12]; /* (This is ugly). */
351N/A+ String param = Errno;
351N/A+ Cardinal param_count = 1;
351N/A+
351N/A+ sprintf(Errno, "%d", errno);
351N/A+ XtAppErrorMsg(app, "communicationError", "select",
351N/A+ XtCXtToolkitError, "Select failed; error code %s",
351N/A+ &param, &param_count);
351N/A+ XtAppError(app, "EINVAL error in select() call");
351N/A+ } else { /* If the new error is not about */
351N/A+ /* an invalid select() parameter,*/
351N/A+ continue; /* then simply try again. */
351N/A+ }
351N/A+ } else { /* (Else the error appears to be */
351N/A+ /* in the timeout parameter.) */
351N/A+ CheckAndTrimTimes(app, &wt);
351N/A+ continue;
351N/A+ }
351N/A+ }
351N/A } /* timed out or input available */
351N/A break;
351N/A }
1276N/A@@ -750,6 +847,33 @@ WaitLoop:
351N/A #define SeCallProc(ptr) \
351N/A (*ptr->se_proc) (ptr->se_closure, (XtSignalId*)&ptr);
351N/A
351N/A+#ifdef sun /*SUNSOFT */
351N/A+int _XtwaitForSomething(
351N/A+ _XtBoolean ignoreTimers,
351N/A+ _XtBoolean ignoreInputs,
351N/A+ _XtBoolean ignoreEvents,
351N/A+ _XtBoolean block,
351N/A+ unsigned long *howlong,
351N/A+ XtAppContext app)
351N/A+{
351N/A+#ifdef XTHREADS
351N/A+/* fix for bug 4185875 leob */
351N/A+return _XtWaitForSomething(app,
351N/A+ ignoreEvents, ignoreTimers, ignoreInputs, TRUE,
351N/A+ block,
351N/A+ TRUE,
351N/A+ howlong);
351N/A+#else
351N/A+/* fix for bug 4185875 leob */
351N/A+return _XtWaitForSomething(app,
351N/A+ ignoreEvents, ignoreTimers, ignoreInputs, TRUE,
351N/A+ block,
351N/A+ howlong);
351N/A+#endif
351N/A+
351N/A+}
351N/A+#endif /* SUNSOFT */
351N/A+
351N/A /*
351N/A * Public Routines
351N/A */