From c22df47605e3e5230addea2fc9a531fb0b84339d Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 19:35:02 -0400 Subject: [PATCH 01/13] trim some stray backslashes leftover from nroff, and fix some whitespace in code samples Signed-off-by: Thomas E. Dickey --- specs/Scrollbar.xml | 12 ++-- specs/Template.xml | 68 +++++++++---------- specs/Template_public_header_file.xml | 36 +++++----- specs/Template_widget_source_file.xml | 42 ++++++------ specs/TextActions.xml | 4 +- ...xtActions_default_translation_bindings.xml | 4 +- 6 files changed, 83 insertions(+), 83 deletions(-) diff --git a/specs/Scrollbar.xml b/specs/Scrollbar.xml index e32f5cb..a9f1ff6 100644 --- a/specs/Scrollbar.xml +++ b/specs/Scrollbar.xml @@ -865,16 +865,16 @@ getting a float into an argument list. top = 0.5; if (sizeof(float) > sizeof(XtArgVal)) { /* - \ * If a float is larger than an XtArgVal then pass this - \ * resource value by reference. - \ */ + * If a float is larger than an XtArgVal then pass this + * resource value by reference. + */ XtSetArg(args[0], XtNshown, &top); } else { /* - \ * Convince C not to perform an automatic conversion, which - \ * would truncate 0.5 to 0. - \ */ + * Convince C not to perform an automatic conversion, which + * would truncate 0.5 to 0. + */ XtArgVal * l_top = (XtArgVal *) &top; XtSetArg(args[0], XtNshown, *l_top); } diff --git a/specs/Template.xml b/specs/Template.xml index ebc1c31..6809acb 100644 --- a/specs/Template.xml +++ b/specs/Template.xml @@ -98,7 +98,7 @@ convenience procedures, so we need to add extern Pixel WindowColor1( /* Widget */ ); extern Pixel WindowColor2( /* Widget */ ); -extern Font\ \ WindowFont( /* Widget */ ); +extern Font WindowFont( /* Widget */ ); @@ -244,41 +244,41 @@ static char translations[] = TemplateClassRec templateClassRec = { { /* core fields */ - /* superclass */ (WidgetClass) &widgetClassRec, - /* class_name */ "Template", - /* widget_size */ sizeof(TemplateRec), - /* class_initialize */ NULL, - /* class_part_initialize */ NULL, - /* class_inited */ FALSE, - /* initialize */ NULL, - /* initialize_hook */ NULL, - /* realize */ XtInheritRealize, - /* actions */ actions, - /* num_actions */ XtNumber(actions), - /* resources */ resources, - /* num_resources */ XtNumber(resources), - /* xrm_class */ NULLQUARK, - /* compress_motion */ TRUE, - /* compress_exposure */ TRUE, - /* compress_enterleave */ TRUE, - /* visible_interest */ FALSE, - /* destroy */ NULL, - /* resize */ NULL, - /* expose */ NULL, - /* set_values */ NULL, - /* set_values_hook */ NULL, - /* set_values_almost */ XtInheritSetValuesAlmost, - /* get_values_hook */ NULL, - /* accept_focus */ NULL, - /* version */ XtVersion, - /* callback_private */ NULL, - /* tm_table */ translations, - /* query_geometry */ XtInheritQueryGeometry, - /* display_accelerator */ XtInheritDisplayAccelerator, - /* extension */ NULL + /* superclass */ (WidgetClass) &widgetClassRec, + /* class_name */ "Template", + /* widget_size */ sizeof(TemplateRec), + /* class_initialize */ NULL, + /* class_part_initialize */ NULL, + /* class_inited */ FALSE, + /* initialize */ NULL, + /* initialize_hook */ NULL, + /* realize */ XtInheritRealize, + /* actions */ actions, + /* num_actions */ XtNumber(actions), + /* resources */ resources, + /* num_resources */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ TRUE, + /* compress_enterleave */ TRUE, + /* visible_interest */ FALSE, + /* destroy */ NULL, + /* resize */ NULL, + /* expose */ NULL, + /* set_values */ NULL, + /* set_values_hook */ NULL, + /* set_values_almost */ XtInheritSetValuesAlmost, + /* get_values_hook */ NULL, + /* accept_focus */ NULL, + /* version */ XtVersion, + /* callback_private */ NULL, + /* tm_table */ translations, + /* query_geometry */ XtInheritQueryGeometry, + /* display_accelerator */ XtInheritDisplayAccelerator, + /* extension */ NULL }, { /* template fields */ - /* empty */ 0 + /* empty */ 0 } }; diff --git a/specs/Template_public_header_file.xml b/specs/Template_public_header_file.xml index 969e07c..eced840 100644 --- a/specs/Template_public_header_file.xml +++ b/specs/Template_public_header_file.xml @@ -30,18 +30,18 @@ are: /* Resources: - Name Class RepType Default Value - ---- ----- ------- ------------- - background Background Pixel XtDefaultBackground - border BorderColor Pixel XtDefaultForeground - borderWidth BorderWidth Dimension 1 - destroyCallback Callback Pointer NULL - height Height Dimension 0 - mappedWhenManaged MappedWhenManaged Boolean True - sensitive Sensitive Boolean True - width Width Dimension 0 - x Position Position 0 - y Position Position 0 + Name Class RepType Default Value + ---- ----- ------- ------------- + background Background Pixel XtDefaultBackground + border BorderColor Pixel XtDefaultForeground + borderWidth BorderWidth Dimension 1 + destroyCallback Callback Pointer NULL + height Height Dimension 0 + mappedWhenManaged MappedWhenManaged Boolean True + sensitive Sensitive Boolean True + width Width Dimension 0 + x Position Position 0 + y Position Position 0 */ @@ -84,11 +84,11 @@ convenience procedures, so we need to add /* Resources: ... - callback Callback Callback NULL - drawingColor1 Color Pixel XtDefaultForeground - drawingColor2 Color Pixel XtDefaultForeground - exposeCallback Callback Callback NULL - font Font XFontStruct* XtDefaultFont + callback Callback Callback NULL + drawingColor1 Color Pixel XtDefaultForeground + drawingColor2 Color Pixel XtDefaultForeground + exposeCallback Callback Callback NULL + font Font XFontStruct* XtDefaultFont ... */ @@ -98,7 +98,7 @@ convenience procedures, so we need to add extern Pixel WindowColor1( /* Widget */ ); extern Pixel WindowColor2( /* Widget */ ); -extern Font\ \ WindowFont( /* Widget */ ); +extern Font WindowFont( /* Widget */ ); diff --git a/specs/Template_widget_source_file.xml b/specs/Template_widget_source_file.xml index 05c6935..d446eee 100644 --- a/specs/Template_widget_source_file.xml +++ b/specs/Template_widget_source_file.xml @@ -45,41 +45,41 @@ static char translations[] = TemplateClassRec templateClassRec = { { /* core fields */ - /* superclass */ (WidgetClass) &widgetClassRec, - /* class_name */ "Template", - /* widget_size */ sizeof(TemplateRec), + /* superclass */ (WidgetClass) &widgetClassRec, + /* class_name */ "Template", + /* widget_size */ sizeof(TemplateRec), /* class_initialize */ NULL, - /* class_part_initialize */ NULL, - /* class_inited */ FALSE, - /* initialize */ NULL, + /* class_part_initialize */ NULL, + /* class_inited */ FALSE, + /* initialize */ NULL, /* initialize_hook */ NULL, - /* realize */ XtInheritRealize, - /* actions */ actions, - /* num_actions */ XtNumber(actions), - /* resources */ resources, + /* realize */ XtInheritRealize, + /* actions */ actions, + /* num_actions */ XtNumber(actions), + /* resources */ resources, /* num_resources */ XtNumber(resources), - /* xrm_class */ NULLQUARK, + /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, - /* compress_enterleave */ TRUE, + /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, - /* destroy */ NULL, - /* resize */ NULL, - /* expose */ NULL, - /* set_values */ NULL, + /* destroy */ NULL, + /* resize */ NULL, + /* expose */ NULL, + /* set_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, - /* accept_focus */ NULL, - /* version */ XtVersion, + /* accept_focus */ NULL, + /* version */ XtVersion, /* callback_private */ NULL, - /* tm_table */ translations, + /* tm_table */ translations, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, - /* extension */ NULL + /* extension */ NULL }, { /* template fields */ - /* empty */ 0 + /* empty */ 0 } }; diff --git a/specs/TextActions.xml b/specs/TextActions.xml index 72d71b9..cfa8ca6 100644 --- a/specs/TextActions.xml +++ b/specs/TextActions.xml @@ -948,9 +948,9 @@ Text widget's translations resource. :Meta<Key>]: forward-paragraph() \\n\\ :Meta<Key>[: backward-paragraph() \\n\\ ~Shift Meta<Key>Delete: delete-previous-word() \\n\\ - \ Shift Meta<Key>Delete: backward-kill-word() \\n\\ + Shift Meta<Key>Delete: backward-kill-word() \\n\\ ~Shift Meta<Key>Backspace: delete-previous-word() \\n\\ - \ Shift Meta<Key>Backspace: backward-kill-word() \\n\\ + Shift Meta<Key>Backspace: backward-kill-word() \\n\\ <Key>Right: forward-character() \\n\\ <Key>Left: backward-character() \\n\\ <Key>Down: next-line() \\n\\ diff --git a/specs/TextActions_default_translation_bindings.xml b/specs/TextActions_default_translation_bindings.xml index e9277b1..ae4e56c 100644 --- a/specs/TextActions_default_translation_bindings.xml +++ b/specs/TextActions_default_translation_bindings.xml @@ -56,9 +56,9 @@ Text widget's translations resource. :Meta<Key>]: forward-paragraph() \\n\\ :Meta<Key>[: backward-paragraph() \\n\\ ~Shift Meta<Key>Delete: delete-previous-word() \\n\\ - \ Shift Meta<Key>Delete: backward-kill-word() \\n\\ + Shift Meta<Key>Delete: backward-kill-word() \\n\\ ~Shift Meta<Key>Backspace: delete-previous-word() \\n\\ - \ Shift Meta<Key>Backspace: backward-kill-word() \\n\\ + Shift Meta<Key>Backspace: backward-kill-word() \\n\\ <Key>Right: forward-character() \\n\\ <Key>Left: backward-character() \\n\\ <Key>Down: next-line() \\n\\ -- GitLab From d7a86b4b9017c67fbdabd4e6006fba6689c63ed1 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 19:47:45 -0400 Subject: [PATCH 02/13] quiet some more type-conversion warnings, as well as unused-parameters Signed-off-by: Thomas E. Dickey --- src/AsciiSink.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/AsciiSink.c b/src/AsciiSink.c index 41cac7d..762d92c 100644 --- a/src/AsciiSink.c +++ b/src/AsciiSink.c @@ -580,7 +580,7 @@ AsciiPreparePaint(Widget w, int y, int line, for (i = 0; i < block.length; i++) { unsigned char c = (unsigned char)block.ptr[i]; - if (paint->length + 4 > bufsiz) + if ((paint->length + 4) > (unsigned)bufsiz) paint->text = XtRealloc(paint->text, (Cardinal)(bufsiz += 32)); paint->text[paint->length] = (char)c; if (c == '\n') { @@ -724,8 +724,8 @@ AsciiPreparePaint(Widget w, int y, int line, static int qcmp_paint_struct(_Xconst void *left, _Xconst void *right) { - return (int)((*(XawTextPaintStruct**)left)->property - - (*(XawTextPaintStruct**)right)->property); + return (int)((*(XawTextPaintStruct* _Xconst *)left)->property - + (*(XawTextPaintStruct* _Xconst *)right)->property); } static void @@ -1088,7 +1088,7 @@ DisplayText(Widget w, int x, int y, for (j = 0; pos1 < pos2;) { pos1 = XawTextSourceRead(source, pos1, &blk, (int)(pos2 - pos1)); for (k = 0; k < blk.length; k++) { - if (j >= sizeof(buf) - 4) { /* buffer full, dump the text */ + if ((unsigned)j >= sizeof(buf) - 4) { /* buffer full, dump the text */ if ((x = (int)((unsigned)x + PaintText(w, gc, x, y, (char*)buf, j, clear_bg))) >= max_x) return; @@ -1475,7 +1475,7 @@ FindDistance(Widget w, XawTextPosition fromPos, int fromx, if (blk.length == 0) break; } - c = blk.ptr[i]; + c = (unsigned char)blk.ptr[i]; rWidth += CharWidth(sink, font, fromx + rWidth, c); if (c == XawLF) { idx++; @@ -1603,7 +1603,7 @@ FindPosition(Widget w, XawTextPosition fromPos, int fromx, int width, if (blk.length == 0) break; } - c = blk.ptr[i]; + c = (unsigned char)blk.ptr[i]; lastWidth = rWidth; rWidth += CharWidth(sink, font, fromx + rWidth, c); @@ -1656,7 +1656,7 @@ GetGC(AsciiSinkObject sink) XGCValues values; /* XXX We dont want do share a gc that will change the clip-mask */ - values.clip_x_origin = (int)sink; + values.clip_x_origin = (int)(long)sink; values.clip_mask = None; values.font = sink->ascii_sink.font->fid; values.graphics_exposures = False; @@ -1707,6 +1707,10 @@ XawAsciiSinkInitialize(Widget request, Widget cnew, { AsciiSinkObject sink = (AsciiSinkObject)cnew; + (void)request; + (void)args; + (void)num_args; + if (!sink->ascii_sink.font) XtError("Aborting: no font found\n"); GetGC(sink); @@ -1804,6 +1808,10 @@ XawAsciiSinkSetValues(Widget current, Widget request, Widget cnew, AsciiSinkObject w = (AsciiSinkObject)cnew; AsciiSinkObject old_w = (AsciiSinkObject)current; + (void)request; + (void)args; + (void)num_args; + if (w->ascii_sink.font != old_w->ascii_sink.font || w->text_sink.background != old_w->text_sink.background || w->text_sink.foreground != old_w->text_sink.foreground -- GitLab From 9836ef1ff74744dc8316b762baf9f9f5f70bbd8f Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 19:50:15 -0400 Subject: [PATCH 03/13] change variables to/from char* vs String to reduce compiler warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/DisplayList.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/DisplayList.c b/src/DisplayList.c index 7c90916..d318c99 100644 --- a/src/DisplayList.c +++ b/src/DisplayList.c @@ -140,8 +140,8 @@ XawRunDisplayList(Widget w, _XawDisplayList *list, #define DLEND 1 #define DLNAME 2 #define DLARG 3 -static char * -read_token(char *src, char *dst, Cardinal size, int *status) +static String +read_token(String src, char *dst, Cardinal size, int *status) { int ch; Bool esc, quote; @@ -235,7 +235,9 @@ _XawDisplayList *XawCreateDisplayList(String string, Screen *screen, XawDLProc *proc; char cname[64], fname[64], aname[1024]; Cardinal i; - char *cp, *fp, *lp; + String cp; + String fp; + String lp; int status; xlibc = XawGetDisplayListClass(xlib); -- GitLab From 30a9013124591c253254255dbda16bdd516c2e9a Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 19:54:00 -0400 Subject: [PATCH 04/13] fix a missing struct-initializer, and quiet unused-parameter warnings Signed-off-by: Thomas E. Dickey --- src/Form.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Form.c b/src/Form.c index 786c130..747cd3c 100644 --- a/src/Form.c +++ b/src/Form.c @@ -286,6 +286,9 @@ FormClassRec formClassRec = { /* form */ { Layout, /* layout */ +#ifndef OLDXAW + NULL, +#endif }, }; @@ -329,6 +332,9 @@ _CvtStringToEdgeType(XrmValuePtr args, Cardinal *num_args, XrmQuark q; char name[12]; + (void)args; + (void)num_args; + XmuNCopyISOLatin1Lowered(name, (char*)fromVal->addr, sizeof(name)); q = XrmStringToQuark(name); @@ -361,6 +367,10 @@ CvtEdgeTypeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, static String buffer; Cardinal size; + (void)args; + (void)num_args; + (void)data; + switch (*(XtEdgeType *)fromVal->addr) { case XtChainLeft: buffer = XtEchainLeft; @@ -448,6 +458,10 @@ XawFormInitialize(Widget request, Widget cnew, { FormWidget fw = (FormWidget)cnew; + (void)request; + (void)args; + (void)num_args; + fw->form.old_width = fw->form.old_height = 0; fw->form.no_refigure = False; fw->form.needs_relayout = False; @@ -549,6 +563,9 @@ Layout(FormWidget fw, unsigned int width, unsigned int height, Dimension maxx, maxy; Boolean ret_val; + (void)width; + (void)height; + for (childP = children; childP - children < num_children; childP++) { FormConstraints form = (FormConstraints)(*childP)->core.constraints; form->form.layout_state = LayoutPending; @@ -811,6 +828,8 @@ XawFormGeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry allowed; XtGeometryResult ret_val; + (void)reply; + if ((request->request_mode & (unsigned)~(XtCWQueryOnly | CWWidth | CWHeight)) || !form->form.allow_resize) { /* If GeometryManager is invoked during a SetValues call on a child @@ -943,6 +962,10 @@ XawFormSetValues(Widget current, Widget request, Widget cnew, FormWidget f_old = (FormWidget)current; FormWidget f_new = (FormWidget)cnew; + (void)request; + (void)args; + (void)num_args; + if (f_old->core.background_pixmap != f_new->core.background_pixmap) { XawPixmap *opix, *npix; @@ -966,6 +989,10 @@ XawFormConstraintInitialize(Widget request, Widget cnew, FormConstraints form = (FormConstraints)cnew->core.constraints; FormWidget fw = (FormWidget)cnew->core.parent; + (void)request; + (void)args; + (void)num_args; + #ifndef OLDXAW form->form.virtual_x = XtX(cnew); form->form.virtual_y = XtY(cnew); @@ -990,6 +1017,10 @@ XawFormConstraintSetValues(Widget current, Widget request, Widget cnew, FormConstraints cfc = (FormConstraints)current->core.constraints; FormConstraints nfc = (FormConstraints)cnew->core.constraints; + (void)request; + (void)args; + (void)num_args; + if (cfc->form.top != nfc->form.top || cfc->form.bottom != nfc->form.bottom || cfc->form.left != nfc->form.left || cfc->form.right != nfc->form.right || cfc->form.dx != nfc->form.dx || cfc->form.dy != nfc->form.dy -- GitLab From 5ea7395991b55b0b7ce8cc1dcaafc37e2b8b9d46 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 20:00:26 -0400 Subject: [PATCH 05/13] change a couple of variable-types to reduce compiler warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/TextSink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/TextSink.c b/src/TextSink.c index 758cc2b..660b0c2 100644 --- a/src/TextSink.c +++ b/src/TextSink.c @@ -1148,7 +1148,7 @@ DestroyTextPropertyList(XawTextPropertyList *list) { int i; - for (i = 0; i < list->num_properties; i++) { + for (i = 0; (Cardinal)i < list->num_properties; i++) { if (list->properties[i]->font) XFreeFont(DisplayOfScreen(list->screen), list->properties[i]->font); XtFree((char*)list->properties[i]); @@ -1499,7 +1499,8 @@ XawTextSinkConvertPropertyList(String name, String spec, Screen *screen, XawTextPropertyList **ptr = NULL; XawTextPropertyList *propl, *prev = NULL; XawTextProperty *def_prop = NULL; - String str, tok; + char * str; + String tok; char *tmp; char buffer[BUFSIZ]; -- GitLab From e1fc6483141c483c1b5e1bfb67fc443faaa314e3 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 20:06:00 -0400 Subject: [PATCH 06/13] fix some type/comparison compiler warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/TextPop.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/TextPop.c b/src/TextPop.c index 99c865c..67e7270 100644 --- a/src/TextPop.c +++ b/src/TextPop.c @@ -72,14 +72,14 @@ static char* TEXT_NAME = "text"; #define R_OFFSET 1 -typedef void (*AddFunc)(Widget, char*, Widget); +typedef void (*AddFunc)(Widget, String, Widget); /* * Prototypes */ static void _SetField(Widget, Widget); -static void AddSearchChildren(Widget, char*, Widget); -static void AddInsertFileChildren(Widget, char*, Widget); +static void AddSearchChildren(Widget, String, Widget); +static void AddInsertFileChildren(Widget, String, Widget); static void CenterWidgetOnPoint(Widget, XEvent*); static Widget CreateDialog(Widget, String, String, AddFunc); static void DoInsert(Widget, XtPointer, XtPointer); @@ -92,13 +92,13 @@ static String GetStringRaw(Widget); static void InitializeSearchWidget(struct SearchAndReplace*, XawTextScanDirection, Bool); static Bool InParams(String, String*, unsigned int); -static Bool InsertFileNamed(Widget, char*); +static Bool InsertFileNamed(Widget, String); static void PopdownFileInsert(Widget, XtPointer, XtPointer); static void PopdownSearch(Widget, XtPointer, XtPointer); static Bool Replace(struct SearchAndReplace*, Bool, Bool); static void SearchButton(Widget, XtPointer, XtPointer); -static void SetResource(Widget, char*, XtArgVal); -static Bool SetResourceByName(Widget, char*, char*, XtArgVal); +static void SetResource(Widget, String, XtArgVal); +static Bool SetResourceByName(Widget, String, String, XtArgVal); static void SetSearchLabels(struct SearchAndReplace*, String, String, Bool); static void SetWMProtocolTranslations(Widget); @@ -197,7 +197,7 @@ _XawTextInsertFile(Widget w, XEvent *event, String *params, Cardinal *num_params) { TextWidget ctx = (TextWidget)w; - char *ptr; + String ptr; XawTextEditType edit_mode; Arg args[1]; @@ -299,7 +299,7 @@ DoInsert(Widget w, XtPointer closure, XtPointer call_data) * True if the insert was sucessful, False otherwise. */ static Bool -InsertFileNamed(Widget tw, char *str) +InsertFileNamed(Widget tw, String str) { FILE *file; XawTextBlock text; @@ -318,7 +318,7 @@ InsertFileNamed(Widget tw, char *str) text.format = XawFmt8Bit; fseek(file, 0L, SEEK_SET); - if (fread(text.ptr, 1, (size_t)text.length, file) != text.length) + if (fread(text.ptr, 1, (size_t)text.length, file) != (size_t)text.length) XtErrorMsg("readError", "insertFileNamed", "XawError", "fread returned error", NULL, NULL); @@ -349,7 +349,7 @@ InsertFileNamed(Widget tw, char *str) * Adds all children to the InsertFile dialog widget. */ static void -AddInsertFileChildren(Widget form, char *ptr, Widget tw) +AddInsertFileChildren(Widget form, String ptr, Widget tw) { Arg args[10]; Cardinal num_args; @@ -529,7 +529,8 @@ _XawTextSearch(Widget w, XEvent *event, String *params, Cardinal *num_params) { TextWidget ctx = (TextWidget)w; XawTextScanDirection dir; - char *ptr, buf[BUFSIZ]; + String ptr; + char buf[BUFSIZ]; XawTextEditType edit_mode; Arg args[1]; wchar_t wcs[1]; @@ -634,7 +635,7 @@ InitializeSearchWidget(struct SearchAndReplace *search, * Adds all children to the Search Dialog Widget. */ static void -AddSearchChildren(Widget form, char *ptr, Widget tw) +AddSearchChildren(Widget form, String ptr, Widget tw) { Arg args[10]; Cardinal num_args; @@ -873,7 +874,7 @@ DoSearch(struct SearchAndReplace *search) GetString to get a tame version */ if (pos == XawTextSearchError) { - char *ptr; + String ptr; int len; ptr = GetString(search->search_text); @@ -881,7 +882,7 @@ DoSearch(struct SearchAndReplace *search) snprintf(msg, sizeof(msg), "%s", ptr); ptr = strchr(msg, '\n'); - if (ptr != NULL || sizeof(msg) - 1 < len) { + if (ptr != NULL || sizeof(msg) - 1 < (size_t)len) { if (ptr != NULL) len = (int)(ptr - msg + 4); else @@ -1034,14 +1035,14 @@ Replace(struct SearchAndReplace *search, Bool once_only, Bool show_current) if (new_pos == XawTextSearchError) { if (count == 0) { char msg[37]; - char *ptr; + String ptr; int len; ptr = GetString(search->search_text); len = (int)strlen(ptr); snprintf(msg, sizeof(msg), "%s", ptr); ptr = strchr(msg, '\n'); - if (ptr != NULL || sizeof(msg) - 1 < len) { + if (ptr != NULL || sizeof(msg) - 1 < (size_t)len) { if (ptr != NULL) len = (int)(ptr - msg + 4); else @@ -1258,7 +1259,7 @@ _SetField(Widget cnew, Widget old) * True if sucessful */ static Bool -SetResourceByName(Widget shell, char *name, char *res_name, XtArgVal value) +SetResourceByName(Widget shell, String name, String res_name, XtArgVal value) { Widget temp_widget; char buf[BUFSIZ]; @@ -1285,7 +1286,7 @@ SetResourceByName(Widget shell, char *name, char *res_name, XtArgVal value) * Sets a resource in a widget */ static void -SetResource(Widget w, char *res_name, XtArgVal value) +SetResource(Widget w, String res_name, XtArgVal value) { Arg args[1]; @@ -1475,7 +1476,7 @@ InParams(String str, String *p, unsigned int n) return (False); } -static char *WM_DELETE_WINDOW = "WM_DELETE_WINDOW"; +static const char *WM_DELETE_WINDOW = "WM_DELETE_WINDOW"; static void WMProtocols(Widget w, XEvent *event, String *params, Cardinal *num_params) @@ -1495,7 +1496,7 @@ WMProtocols(Widget w, XEvent *event, String *params, Cardinal *num_params) if ((event->type == ClientMessage && event->xclient.message_type == wm_protocols - && event->xclient.data.l[0] == wm_delete_window + && (Atom)event->xclient.data.l[0] == wm_delete_window && (*num_params == 0 || DO_DELETE_WINDOW)) || (event->type != ClientMessage && DO_DELETE_WINDOW)) { #undef DO_DELETE_WINDOW -- GitLab From 666ecd9890cef9726cd29da7acb3e397ca90442b Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 20:18:45 -0400 Subject: [PATCH 07/13] fix some type/conversion compiler warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/TextAction.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/TextAction.c b/src/TextAction.c index 34457e0..737430b 100644 --- a/src/TextAction.c +++ b/src/TextAction.c @@ -245,7 +245,7 @@ void _XawSourceSetUndoMerge(TextSrcObject, Bool); #ifndef OLDXAW #define MAX_KILL_RINGS 1024 XawTextKillRing *xaw_text_kill_ring; -static XawTextKillRing kill_ring_prev, kill_ring_null = { &kill_ring_prev, }; +static XawTextKillRing kill_ring_prev, kill_ring_null = { &kill_ring_prev, NULL, 0, 0, 0 }; static unsigned num_kill_rings; #endif @@ -421,7 +421,7 @@ _SelectionReceived(Widget w, XtPointer client_data, Atom *selection, fprintf(stderr, "Xaw Text Widget: An attempt was made to insert " "an illegal selection.\n"); - textprop.value = (unsigned char *)" >> ILLEGAL SELECTION << "; + textprop.value = (const unsigned char *)" >> ILLEGAL SELECTION << "; textprop.nitems = strlen((char *) textprop.value); if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count) != Success @@ -2121,7 +2121,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, if (count < ctx->text.left_column) { int bytes = ctx->text.left_column - count; - text.ptr = XawStackAlloc(bytes, buf); + text.ptr = XawStackAlloc((unsigned)bytes, buf); text.length = bytes; for (i = 0; i < bytes; i++) text.ptr[i] = ' '; @@ -2224,7 +2224,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, } count = (count + alnum) >> 1; } - text.ptr = XawStackAlloc(count, buf); + text.ptr = XawStackAlloc((unsigned)count, buf); text.length = count; for (i = 0; i < count; i++) text.ptr[i] = ' '; @@ -2264,7 +2264,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, inc = ii = (count + .5) / (double)i; steps = count; - text.ptr = XawStackAlloc(steps, buf); + text.ptr = XawStackAlloc((unsigned)steps, buf); for (i = 0; i < steps; i++) text.ptr[i] = ' '; tmp = left; @@ -2338,7 +2338,7 @@ Indent(Widget w, XEvent *event, String *params, Cardinal *num_params) StartAction(ctx, event); pos = XawStackAlloc(sizeof(XawTextPosition) * src->textSrc.num_text, posbuf); - for (i = 0; i < src->textSrc.num_text; i++) + for (i = 0; (Cardinal)i < src->textSrc.num_text; i++) pos[i] = ((TextWidget)src->textSrc.text[i])->text.insertPos; if (!GetBlockBoundaries(ctx, &from, &to)) { @@ -2370,7 +2370,7 @@ Indent(Widget w, XEvent *event, String *params, Cardinal *num_params) tmp = from; if (spaces > 0) { - text.ptr = XawStackAlloc(spaces, buf); + text.ptr = XawStackAlloc((unsigned)spaces, buf); for (i = 0; i < spaces; i++) text.ptr[i] = ' '; @@ -2378,7 +2378,7 @@ Indent(Widget w, XEvent *event, String *params, Cardinal *num_params) while (tmp < to) { _XawTextReplace(ctx, tmp, tmp, &text); - for (i = 0; i < src->textSrc.num_text; i++) + for (i = 0; (Cardinal)i < src->textSrc.num_text; i++) if (tmp < pos[i]) pos[i] += spaces; @@ -2407,7 +2407,7 @@ Indent(Widget w, XEvent *event, String *params, Cardinal *num_params) while (tmp < to) { _XawTextReplace(ctx, tmp, tmp + spaces, &text); - for (i = 0; i < src->textSrc.num_text; i++) + for (i = 0; (Cardinal)i < src->textSrc.num_text; i++) if (tmp < pos[i]) { if (tmp + spaces < pos[i]) pos[i] -= spaces; @@ -2445,7 +2445,7 @@ Indent(Widget w, XEvent *event, String *params, Cardinal *num_params) XtFree(rbuf); } - for (i = 0; i < src->textSrc.num_text; i++) { + for (i = 0; (Cardinal)i < src->textSrc.num_text; i++) { TextWidget tw = (TextWidget)src->textSrc.text[i]; tw->text.insertPos = XawMin(XawMax(0, pos[i]), tw->text.lastPos); @@ -2571,7 +2571,7 @@ InsertNewLineAndIndent(Widget w, XEvent *event, String *p, Cardinal *n) XawTextPosition pos1; int length; TextWidget ctx = (TextWidget)w; - String line_to_ip; + char * line_to_ip; StartAction(ctx, event); pos1 = SrcScan(ctx->text.source, ctx->text.insertPos, @@ -2876,10 +2876,10 @@ TextFocusIn(Widget w, XEvent *event, String *p, Cardinal *n) if (display_caret) EndAction(ctx); - for (i = 0; i < num_focus; i++) + for (i = 0; (Cardinal)i < num_focus; i++) if (focus[i].display == XtDisplay(w)) break; - if (i >= num_focus) { + if ((Cardinal)i >= num_focus) { focus = (struct _focus*) XtRealloc((XtPointer)focus, (Cardinal)(sizeof(struct _focus) * (num_focus + 1))); i = (int)num_focus; @@ -2918,16 +2918,16 @@ TextFocusOut(Widget w, XEvent *event, String *p, Cardinal *n) shell = XtParent(shell); } - for (i = 0; i < num_focus; i++) + for (i = 0; (Cardinal)i < num_focus; i++) if (focus[i].display == XtDisplay(w)) break; XGetInputFocus(XtDisplay(w), &window, &revert); if ((XtWindow(shell) == window && - (i < num_focus && focus[i].widget == w)) + ((Cardinal)i < num_focus && focus[i].widget == w)) || event->xfocus.detail == NotifyPointer) return; - if (i < num_focus && focus[i].widget) { + if ((Cardinal)i < num_focus && focus[i].widget) { XtRemoveCallback(focus[i].widget, XtNdestroyCallback, DestroyFocusCallback, (XtPointer)&focus[i]); focus[i].widget = NULL; @@ -3075,7 +3075,7 @@ InsertChar(Widget w, XEvent *event, String *p, Cardinal *n) #endif } else { /* == XawFmt8Bit */ - text.ptr = ptr = XawStackAlloc(text.length * mult, ptrbuf); + text.ptr = ptr = XawStackAlloc((unsigned)(text.length * mult), ptrbuf); for (count = 0; count < mult; count++) { strncpy(ptr, strbuf, (size_t)text.length); ptr += text.length; -- GitLab From ccca832690f7ee56469786d7926e79f219259cea Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 20:21:18 -0400 Subject: [PATCH 08/13] fix some type/conversion compiler warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/Panner.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Panner.c b/src/Panner.c index 8cacde1..94d3b95 100644 --- a/src/Panner.c +++ b/src/Panner.c @@ -67,7 +67,7 @@ static void check_knob(PannerWidget, Bool); static void get_default_size(PannerWidget, Dimension*, Dimension*); static Bool get_event_xy(PannerWidget, XEvent*, int*, int*); static void move_shadow(PannerWidget); -static int parse_page_string(char*, int, int, Bool*); +static int parse_page_string(String, int, int, Bool*); static void rescale(PannerWidget); static void reset_shadow_gc(PannerWidget); static void reset_slider_gc(PannerWidget); @@ -323,6 +323,9 @@ PannerClassRec pannerClassRec = { /* simple */ { XtInheritChangeSensitive, /* change_sensitive */ +#ifndef OLDXAW + NULL, +#endif }, /* panner */ { @@ -563,9 +566,9 @@ get_event_xy(PannerWidget pw, XEvent *event, int *x, int *y) } static int -parse_page_string(char *s, int pagesize, int canvassize, Bool *relative) +parse_page_string(String s, int pagesize, int canvassize, Bool *relative) { - char *cp; + String cp; double val = 1.0; Bool rel = False; -- GitLab From 29144b39e9b7e5bad43b5e6013ecb4cfac049bd5 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 20:25:01 -0400 Subject: [PATCH 09/13] fix some type/conversion compiler warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/Text.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Text.c b/src/Text.c index ff3efb8..b380a8c 100644 --- a/src/Text.c +++ b/src/Text.c @@ -644,7 +644,7 @@ static Boolean CvtJustifyModeToString(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *data) { - static char *buffer; + static String buffer; Cardinal size; switch (*(XawTextJustifyMode *)fromVal->addr) { @@ -1382,8 +1382,8 @@ _BuildLineTable(TextWidget ctx, XawTextPosition position, int line) lt->y = y; ctx->text.clear_to_eol = True; } - if (lt->textWidth != width) { - if (lt->textWidth > width) + if (lt->textWidth != (Cardinal)width) { + if (lt->textWidth > (Cardinal)width) ctx->text.clear_to_eol = True; lt->textWidth = (unsigned)width; } @@ -1805,7 +1805,7 @@ UpdateTextInLine(TextWidget ctx, int line, int x1, int x2) False, &left, &width, &height); if (line == ctx->text.lt.lines) right = -1; - else if (x2 >= (lt->textWidth - (unsigned)from_x)) + else if ((Cardinal)x2 >= (lt->textWidth - (unsigned)from_x)) right = lt[1].position - 1; else { from_x += width; @@ -4151,6 +4151,9 @@ TextClassRec textClassRec = { /* simple */ { XawTextChangeSensitive, /* change_sensitive */ +#ifndef OLDXAW + NULL, +#endif }, /* text */ { -- GitLab From 9b4f070bfb7cbaad22b03d2d38b338e82cbf80c0 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 20:30:02 -0400 Subject: [PATCH 10/13] fix misleading indentation, which gave a compiler warning Signed-off-by: Thomas E. Dickey --- src/StripChart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/StripChart.c b/src/StripChart.c index 4b66c0a..5e51b56 100644 --- a/src/StripChart.c +++ b/src/StripChart.c @@ -387,8 +387,8 @@ repaint_window(StripChartWidget w, int left, int width) lower than min_scale */ if (w->strip_chart.interval != 0 || scale <= w->strip_chart.max_value) scale = (int)(w->strip_chart.max_value + 1); - if (scale < w->strip_chart.min_scale) - scale = w->strip_chart.min_scale; + if (scale < w->strip_chart.min_scale) + scale = w->strip_chart.min_scale; if (scale != w->strip_chart.scale) { w->strip_chart.scale = scale; -- GitLab From 7a6b35790865bd40009eef58d0a4d504b2fce0c8 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 20:33:22 -0400 Subject: [PATCH 11/13] fix some type/conversion warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/StripChart.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/StripChart.c b/src/StripChart.c index 5e51b56..87d0041 100644 --- a/src/StripChart.c +++ b/src/StripChart.c @@ -200,6 +200,13 @@ StripChartClassRec stripChartClassRec = { /* simple */ { XtInheritChangeSensitive, /* change_sensitive */ +#ifndef OLDXAW + NULL +#endif + }, + /* strip_chart_class */ + { + NULL } }; @@ -320,7 +327,7 @@ draw_it(XtPointer client_data, XtIntervalId *id) client_data); if ((w->strip_chart.interval >= XtWidth(w)) || - (w->strip_chart.interval >= NUM_VALUEDATA(w))) + ((Cardinal)w->strip_chart.interval >= NUM_VALUEDATA(w))) MoveChart((StripChartWidget)w, True); /* Get the value, stash the point and draw corresponding line */ @@ -413,7 +420,7 @@ repaint_window(StripChartWidget w, int left, int width) if (next < ++width) width = next; - if (width > NUM_VALUEDATA(w)) + if ((Cardinal)width > NUM_VALUEDATA(w)) width = NUM_VALUEDATA(w); /* Draw data point lines */ -- GitLab From a68226ab5e620a49cfedbe01b437d1ebac2adf9b Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 20:37:07 -0400 Subject: [PATCH 12/13] fix some type/conversion warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/MultiSrc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/MultiSrc.c b/src/MultiSrc.c index 51973e1..bea514d 100644 --- a/src/MultiSrc.c +++ b/src/MultiSrc.c @@ -112,7 +112,7 @@ static FILE *InitStringOrFile(MultiSrcObject, Bool); static void LoadPieces(MultiSrcObject, FILE*, char*); static void RemovePiece(MultiSrcObject, MultiPiece*); static void RemoveOldStringOrFile(MultiSrcObject, Bool); -static String StorePiecesInString(MultiSrcObject); +static char * StorePiecesInString(MultiSrcObject); static Bool WriteToFile(String, String); static void GetDefaultPieceSize(Widget, int, XrmValue*); @@ -234,6 +234,9 @@ MultiSrcClassRec multiSrcClassRec = { Search, /* Search */ XtInheritSetSelection, /* SetSelection */ XtInheritConvertSelection, /* ConvertSelection */ +#ifndef OLDXAW + NULL +#endif }, /* multi_src */ { @@ -841,7 +844,7 @@ XawMultiSrcSetValues(Widget current, Widget request, Widget cnew, if ( !total_reset && old_src->multi_src.piece_size != src->multi_src.piece_size) { - String mb_string = StorePiecesInString(old_src); + char * mb_string = StorePiecesInString(old_src); if (mb_string != 0) { FreeAllPieces(old_src); @@ -1031,13 +1034,13 @@ Bool _XawMultiSaveAsFile(Widget w, _Xconst char* name) { MultiSrcObject src = (MultiSrcObject)w; - String mb_string; + char * mb_string; Bool ret; mb_string = StorePiecesInString(src); if (mb_string != 0) { - ret = WriteToFile(mb_string, (char *)name); + ret = WriteToFile(mb_string, (String)name); XtFree(mb_string); return (ret); @@ -1114,7 +1117,7 @@ WriteToFile(String string, String name) * (or) * NULL: conversion error */ -static String +static char * StorePiecesInString(MultiSrcObject src) { wchar_t *wc_string; @@ -1173,7 +1176,7 @@ InitStringOrFile(MultiSrcObject src, Bool newString) else if (!src->multi_src.use_string_in_place) { int length; - String temp = XtNewString((char *)src->multi_src.string); + char * temp = XtNewString((char *)src->multi_src.string); if (src->multi_src.allocated_string) XtFree((char *)src->multi_src.string); @@ -1240,7 +1243,7 @@ InitStringOrFile(MultiSrcObject src, Bool newString) /* If is_tempfile, allocate a private copy of the text * Unlikely to be changed, just to set allocated_string */ if (newString || src->multi_src.is_tempfile) { - String temp = XtNewString((char *)src->multi_src.string); + char * temp = XtNewString((char *)src->multi_src.string); if (src->multi_src.allocated_string) XtFree((char *)src->multi_src.string); -- GitLab From 70fb870ca41cd2a5f9c46ad0244004bd7f808202 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Jul 2019 21:04:03 -0400 Subject: [PATCH 13/13] fix some compiler warnings in MenuButton.c by changing the menu name from String to char* Signed-off-by: Thomas E. Dickey --- include/X11/Xaw/MenuButtoP.h | 2 +- include/X11/Xaw/SmeBSBP.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/X11/Xaw/MenuButtoP.h b/include/X11/Xaw/MenuButtoP.h index 8ee3195..9aa39bc 100644 --- a/include/X11/Xaw/MenuButtoP.h +++ b/include/X11/Xaw/MenuButtoP.h @@ -61,7 +61,7 @@ extern MenuButtonClassRec menuButtonClassRec; /* New fields for the MenuButton widget */ typedef struct { /* resources */ - String menu_name; + char * menu_name; #ifndef OLDXAW XtPointer pad[4]; /* for future use and keep binary compatability */ #endif diff --git a/include/X11/Xaw/SmeBSBP.h b/include/X11/Xaw/SmeBSBP.h index 3df9b88..299e4ca 100644 --- a/include/X11/Xaw/SmeBSBP.h +++ b/include/X11/Xaw/SmeBSBP.h @@ -74,7 +74,7 @@ typedef struct { #ifndef OLDXAW /* new resources */ - String menu_name; /* name of nested sub menu or NULL */ + char * menu_name; /* name of nested sub menu or NULL */ XtPointer pad[4]; /* for future use and keep binary compatability */ #endif } SmeBSBPart; -- GitLab