From ceb49b9130a385bca4ea1821271d725221b68bf9 Mon Sep 17 00:00:00 2001 From: Marcin Cieslak Date: Fri, 31 Aug 2012 01:17:48 +0200 Subject: [PATCH] DtWidget: Improve portability of Motif interface - Add missing includes and prototypes - Improve type compatibility - Use for unofficial libXm headers With this patch, dtpad no longer crashes on startup on FreeBSD/amd64 because of a truncated 64-bit pointer. --- cde/lib/DtWidget/ComboBox.c | 4 ++++ cde/lib/DtWidget/Control.c | 6 ++++-- cde/lib/DtWidget/DialogBox.c | 4 ++-- cde/lib/DtWidget/DtSvcInternal.h | 2 ++ cde/lib/DtWidget/EditAreaData.c | 2 +- cde/lib/DtWidget/EditCalls.c | 1 + cde/lib/DtWidget/Editor.c | 13 +++++++++++-- cde/lib/DtWidget/Icon.c | 27 +++++++++++++++------------ cde/lib/DtWidget/Imakefile | 2 +- cde/lib/DtWidget/MenuButton.c | 7 +++++-- cde/lib/DtWidget/NewCvt.c | 1 + cde/lib/DtWidget/SearchCalls.c | 4 ++++ cde/lib/DtWidget/SpinBox.c | 10 +++++++--- cde/lib/DtWidget/TitleBox.c | 2 ++ 14 files changed, 60 insertions(+), 25 deletions(-) create mode 100644 cde/lib/DtWidget/DtSvcInternal.h diff --git a/cde/lib/DtWidget/ComboBox.c b/cde/lib/DtWidget/ComboBox.c index 8b8d6f7c..6ad6e9a1 100644 --- a/cde/lib/DtWidget/ComboBox.c +++ b/cde/lib/DtWidget/ComboBox.c @@ -109,9 +109,13 @@ express or implied warranty. #include /* for INT_MAX */ #include
#include "ComboBoxP.h" +#include #include +#include #include /* for redirecting utility functions */ #include "DtWidgetI.h" /* for _Dt thread-safety macros */ +/* some unpublished Motif interfaces */ +#include /* * MotifBc diff --git a/cde/lib/DtWidget/Control.c b/cde/lib/DtWidget/Control.c index e937fc39..8722d674 100644 --- a/cde/lib/DtWidget/Control.c +++ b/cde/lib/DtWidget/Control.c @@ -59,12 +59,14 @@ #include #include #include +#include #include
#include
#include #include
#include #include "DtWidgetI.h" +#include "DtSvcInternal.h" /******** Public Function Declarations ********/ @@ -577,7 +579,7 @@ BusyTimeout( else { G_Set (g) = False; - G_BlinkTimer (g) = NULL; + G_BlinkTimer (g) = 0; G_BlinkElapsed (g) = 0; G_Busy (g) = 0; (*call_callback) ((DtIconGadget) g, G_Callback (g), XmCR_BUSY_STOP, NULL); @@ -830,7 +832,7 @@ Initialize( G_ControlType (new) != XmCONTROL_MAIL && G_ControlType (new) != XmCONTROL_MONITOR) { - G_ControlType (new) == XmCONTROL_NONE; + G_ControlType (new) = XmCONTROL_NONE; } if (G_ControlType (new) == XmCONTROL_SWITCH) diff --git a/cde/lib/DtWidget/DialogBox.c b/cde/lib/DtWidget/DialogBox.c index 59f337a2..ff240f36 100644 --- a/cde/lib/DtWidget/DialogBox.c +++ b/cde/lib/DtWidget/DialogBox.c @@ -274,7 +274,7 @@ DtDialogBoxClassRec dtDialogBoxClassRec = { XtInheritTranslations, /* default_translations */ NULL, /* get_resources */ - NULL, /* num_get_resources */ + 0, /* num_get_resources */ NULL, /* get_cont_resources */ 0, /* num_get_cont_resources */ XmInheritParentProcess, /* parent_process */ @@ -788,7 +788,7 @@ CreateChildren( XtSetArg (al[ac], XmNlabelString, string[i]); ac++; } XtSetArg (al[ac], XmNchildType, XmBUTTON); ac++; - sprintf (button_name, "%s_%d\0", M_Name (new), i+1); + sprintf (button_name, "%s_%d", M_Name (new), i+1); btn = XmCreatePushButtonGadget ((Widget)new, button_name, al, ac); XtManageChild (btn); XtAddCallback (btn, XmNactivateCallback, diff --git a/cde/lib/DtWidget/DtSvcInternal.h b/cde/lib/DtWidget/DtSvcInternal.h new file mode 100644 index 00000000..3e4021e1 --- /dev/null +++ b/cde/lib/DtWidget/DtSvcInternal.h @@ -0,0 +1,2 @@ +/* Additional import */ +extern Pixmap _DtGetMask(Screen *screen, char *image_name); diff --git a/cde/lib/DtWidget/EditAreaData.c b/cde/lib/DtWidget/EditAreaData.c index d3ae6f2a..5971383f 100644 --- a/cde/lib/DtWidget/EditAreaData.c +++ b/cde/lib/DtWidget/EditAreaData.c @@ -1266,7 +1266,7 @@ LoadFile( */ loadError = Check4EnoughMemory( file_length ); if (loadError == DtEDITOR_INSUFFICIENT_MEMORY) - returnVal == loadError; + returnVal = loadError; else { /* diff --git a/cde/lib/DtWidget/EditCalls.c b/cde/lib/DtWidget/EditCalls.c index 8d3d6a76..9a9b29ea 100644 --- a/cde/lib/DtWidget/EditCalls.c +++ b/cde/lib/DtWidget/EditCalls.c @@ -49,6 +49,7 @@ #include "EditorP.h" #include "DtWidgetI.h" +#include /* _XmStringSourceGetString */ void _DtEditorResetUndo( diff --git a/cde/lib/DtWidget/Editor.c b/cde/lib/DtWidget/Editor.c index 431dbb5b..09718bd7 100644 --- a/cde/lib/DtWidget/Editor.c +++ b/cde/lib/DtWidget/Editor.c @@ -69,6 +69,7 @@ # define NO_putwc #elif defined(CSRG_BASED) # include +# include #endif /* linux */ #include @@ -88,11 +89,17 @@ #include #include #include +#include +#include +#include +#include +#include /* Need the following for _DtOkString */ #include
#include
+#include
#include "DtWidgetI.h" @@ -762,8 +769,10 @@ static XtActionsRec EditorActionTable[] = { #endif /* _AIX */ #if !(defined(sun) && (_XOPEN_VERSION==3)) +#if !(defined(__FreeBSD__)) # define iswblank(wc) iswctype((wc),blnkclass) # undef getwc /* Use the libc function */ +#endif #if defined(__osf__) || defined(_AIX) /* __osf__ || _AIX */ /* function prototype for wctype() was changed to meet spec1170 */ /* digital compiler flagged warning */ @@ -1344,13 +1353,13 @@ dtEditorClassRec = /* XmForm Part */ { - (int) NULL, /* extension */ + NULL, /* extension */ }, /* DtEditor Part */ { - (int) NULL, /* extension */ + 0, /* extension */ } }; diff --git a/cde/lib/DtWidget/Icon.c b/cde/lib/DtWidget/Icon.c index 62166b37..c1bdb7b4 100644 --- a/cde/lib/DtWidget/Icon.c +++ b/cde/lib/DtWidget/Icon.c @@ -62,7 +62,9 @@ #include
#include
#include "DtWidgetI.h" +#include "DtSvcInternal.h" +#include /* Motif _XmEnterGadget and friends */ /*------------------------------------------------------------- ** Public Interface @@ -527,7 +529,7 @@ static XmBaseClassExtRec iconBaseClassExtRec = { (WidgetClass)&dtIconCacheObjClassRec, /* secondary class */ (XtInitProc)SecondaryObjectCreate, /* creation proc */ (XmGetSecResDataFunc) GetIconClassSecResData, /* getSecResData */ - {NULL}, /* fast subclass */ + {0}, /* fast subclass */ GetValuesPrehook, /* get_values prehook */ GetValuesPosthook, /* get_values posthook */ NULL, /* classPartInitPrehook */ @@ -1717,10 +1719,10 @@ Initialize( G_Armed (new) = False; - G_Mask (new) = NULL; + G_Mask (new) = None; if (G_Pixmap (new) == XmUNSPECIFIED_PIXMAP) - G_Pixmap (new) = NULL; + G_Pixmap (new) = None; if (G_ImageName (new) || G_Pixmap (new)) { @@ -1744,7 +1746,7 @@ Initialize( { /* warning? */ name = NULL; - G_Pixmap (new) = NULL; + G_Pixmap (new) = None; } } @@ -1830,7 +1832,7 @@ Initialize( XmeGetDefaultRenderTable ((Widget)new, XmBUTTON_FONTLIST); G_FontList (new) = XmFontListCopy (G_FontList (new)); - if ((unsigned int)G_String (new) == (unsigned int)XmUNSPECIFIED_STRING) + if (G_String (new) == XmUNSPECIFIED_STRING) G_String (new) = (_XmString) NULL; if (G_String (new)) @@ -2240,7 +2242,7 @@ SetValues( else { name = NULL; - G_Pixmap (new) = NULL; + G_Pixmap (new) = None; w = 0; h = 0; } @@ -2265,7 +2267,7 @@ SetValues( if (G_Pixmap (new) != G_Pixmap (current)) { - if ((G_Pixmap (new) != NULL) && + if ((G_Pixmap (new) != None) && (G_PixmapWidth (new) == w) && (G_PixmapHeight (new) == h)) { @@ -2292,7 +2294,7 @@ SetValues( if (G_Mask(new) != XmUNSPECIFIED_PIXMAP) XmDestroyPixmap (XtScreen(new),G_Mask (current)); XmDestroyPixmap (XtScreen(new),G_Pixmap (current)); - G_Pixmap (new) = NULL; + G_Pixmap (new) = None; G_PixmapWidth (new) = 0; G_PixmapHeight (new) = 0; } @@ -2693,7 +2695,7 @@ BorderUnhighlight( DtIconGadget g) register int window_width; register int window_height; - register highlight_width; + register int highlight_width; CallCallbackProc call_callback; window_width = g->rectangle.width; @@ -2856,6 +2858,7 @@ VisualChange( else return (False); } + return (False); } @@ -3326,8 +3329,8 @@ Draw( if (((G_Behavior (g) == XmICON_BUTTON) && G_Armed (g)) || ((G_Behavior (g) == XmICON_TOGGLE) && - (!G_Set (g) && G_Armed (g)) || - (G_Set (g) && !G_Armed (g)))) + ((!G_Set (g) && G_Armed (g)) || + (G_Set (g) && !G_Armed (g))))) shadow_type = XmSHADOW_IN; else shadow_type = XmSHADOW_OUT; @@ -3719,7 +3722,7 @@ _DtDuplicateIcon( { /* No pixmap to load */ G_ImageName(new) = NULL; - G_Pixmap(new) = NULL; + G_Pixmap(new) = None; G_PixmapWidth(new) = 0; G_PixmapHeight(new) = 0; } diff --git a/cde/lib/DtWidget/Imakefile b/cde/lib/DtWidget/Imakefile index f167e35a..43ad0706 100644 --- a/cde/lib/DtWidget/Imakefile +++ b/cde/lib/DtWidget/Imakefile @@ -10,7 +10,7 @@ XCOMM $XConsortium: Imakefile /main/8 1996/04/21 19:11:16 drk $ #include #ifndef DtWidgetDefines -# define DtWidgetDefines -DI18N_MSG -DXK_MISCELLANY -DMULTIBYTE +# define DtWidgetDefines -DI18N_MSG -DMULTIBYTE #endif DEFINES = DtWidgetDefines #if defined(LinuxArchitecture) diff --git a/cde/lib/DtWidget/MenuButton.c b/cde/lib/DtWidget/MenuButton.c index 931c361a..19ce9106 100644 --- a/cde/lib/DtWidget/MenuButton.c +++ b/cde/lib/DtWidget/MenuButton.c @@ -63,6 +63,9 @@ #include #include #include +#include + +#include /* _XmRecordEvent, _XmSetInDragMode, ... */ #include #include "DtWidgetI.h" @@ -795,7 +798,7 @@ SetValues( Boolean flag = FALSE; Boolean adjustWidth = FALSE; Boolean adjustHeight = FALSE; - unsigned char rowcol_type = NULL; + unsigned char rowcol_type = 0; Display *dpy = XtDisplay(nw); Boolean menu_glyph_changed = FALSE; @@ -911,7 +914,7 @@ Initialize( Boolean adjustWidth = FALSE; Boolean adjustHeight = FALSE; Widget parent = XtParent(new_w); - unsigned char rowcol_type = NULL; + unsigned char rowcol_type = 0; char *name = NULL; if ((XmIsRowColumn (parent))) { diff --git a/cde/lib/DtWidget/NewCvt.c b/cde/lib/DtWidget/NewCvt.c index daf56095..8b0c5427 100644 --- a/cde/lib/DtWidget/NewCvt.c +++ b/cde/lib/DtWidget/NewCvt.c @@ -51,6 +51,7 @@ #include
#include "DtWidgetI.h" +#include extern void _DtRegisterNewConverters( void ) ; diff --git a/cde/lib/DtWidget/SearchCalls.c b/cde/lib/DtWidget/SearchCalls.c index 616ca24d..0444202d 100644 --- a/cde/lib/DtWidget/SearchCalls.c +++ b/cde/lib/DtWidget/SearchCalls.c @@ -48,11 +48,15 @@ #include "EditorP.h" #include #include +#include #include #include #include
+#include
#include "DtWidgetI.h" +#include /* _XmStringSourceGetString */ + #define X_INCLUDE_STRING_H #define XOS_USE_XT_LOCKING #include diff --git a/cde/lib/DtWidget/SpinBox.c b/cde/lib/DtWidget/SpinBox.c index 9b7383f7..4a4178f0 100644 --- a/cde/lib/DtWidget/SpinBox.c +++ b/cde/lib/DtWidget/SpinBox.c @@ -89,10 +89,14 @@ express or implied warranty. */ #include
+#include +#include #include #include "SpinBoxP.h" #include "DtWidgetI.h" +#include /* _XmShellIsExclusive */ + #ifdef I18N_MSG #include #endif @@ -1929,7 +1933,7 @@ SetTextFieldData(DtSpinBoxWidget spin) } else { xm_string = (Items(spin))[Position(spin)]; - if (text = GetTextString(xm_string)) { + if ((text = GetTextString(xm_string))) { XtSetArg(arg, XmNvalue, text); XtSetValues(Text(spin), &arg, 1); XtFree(text); @@ -2201,7 +2205,7 @@ FinishUpDown( DtSpinBoxWidget spin, repeat_delay, timer_dispatch, (XtPointer)spin); /* Try to get Xevent */ - if (arrow_data = (XmArrowButtonCallbackStruct*)arrow_call_data) + if ((arrow_data = (XmArrowButtonCallbackStruct*)arrow_call_data)) last_event = arrow_data->event; /* @@ -2605,7 +2609,7 @@ DtSpinBoxDeletePos( Widget spinw, /* To keep Position of SpinBox up to date */ if (Position(spin) > 0 && - (Position(spin) >= total_items) || pos < Position(spin) ) + ((Position(spin) >= total_items) || pos < Position(spin)) ) Position(spin) = Position(spin) - 1; if (pos < ItemCount(spin)) { diff --git a/cde/lib/DtWidget/TitleBox.c b/cde/lib/DtWidget/TitleBox.c index 263f1bff..5f8959ce 100644 --- a/cde/lib/DtWidget/TitleBox.c +++ b/cde/lib/DtWidget/TitleBox.c @@ -52,11 +52,13 @@ #include #endif /* RiversVersion == _31 */ #include +#include #include
#include
#include
#include "DtWidgetI.h" +#include /* _XmClearShadowType */ -- 2.25.1