From 3a2473affe1e15d6e8d252db7ec5e22fd1683978 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 1 Jun 2019 19:27:15 -0700 Subject: Use _CONST_X_STRING to make libXt declare String as const char * Clears 169 out of 240 -Wdiscarded-qualifiers warnings from gcc 7.3 Signed-off-by: Alan Coopersmith --- BitEdit.c | 2 +- Bitmap.c | 18 +++++++++--------- Bitmap.h | 6 +++--- BitmapP.h | 3 ++- Dialog.c | 4 ++-- Dialog.h | 4 ++-- Makefile.am | 2 ++ 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/BitEdit.c b/BitEdit.c index 64c2e56..a9ec29f 100644 --- a/BitEdit.c +++ b/BitEdit.c @@ -226,7 +226,7 @@ static Boolean image_visible = False; static Pixmap check_mark; static Dialog input_dialog, error_dialog, qsave_dialog; static Time btime; -static String filename = NULL, base_name = NULL, format; +static char *filename = NULL, *base_name = NULL, *format; static char message[80]; diff --git a/Bitmap.c b/Bitmap.c index 8fbead9..af7cac5 100644 --- a/Bitmap.c +++ b/Bitmap.c @@ -648,7 +648,7 @@ BWPutImage(BitmapWidget w, Display *display, Drawable drawable, GC gc, } #endif -static String +static char * StripFilename(_Xconst _XtString filename) { const char *begin = strrchr(filename, '/'); @@ -688,7 +688,7 @@ XmuWriteBitmapDataToFile(_Xconst _XtString filename, file = fopen(filename, "w+"); if (file) { - String new_basename; + char *new_basename; if (!basename || !strcmp(basename, "") || !strcmp(basename, "-")) basename = new_basename = StripFilename(filename); @@ -1227,8 +1227,8 @@ BWWriteFile(Widget w, _Xconst _XtString filename, _Xconst _XtString basename) return status; } -String -BWGetFilename(Widget w, String *str) +_XtString +BWGetFilename(Widget w, _XtString *str) { BitmapWidget BW = (BitmapWidget) w; @@ -1237,11 +1237,11 @@ BWGetFilename(Widget w, String *str) return *str; } -String -BWGetFilepath(Widget w, String *str) +_XtString +BWGetFilepath(Widget w, _XtString *str) { BitmapWidget BW = (BitmapWidget) w; - String end; + _XtString end; *str = XtNewString(BW->bitmap.filename); assert(*str); @@ -1257,8 +1257,8 @@ BWGetFilepath(Widget w, String *str) } -String -BWGetBasename(Widget w, String *str) +_XtString +BWGetBasename(Widget w, _XtString *str) { BitmapWidget BW = (BitmapWidget) w; diff --git a/Bitmap.h b/Bitmap.h index 611f0e0..c0ee8e8 100644 --- a/Bitmap.h +++ b/Bitmap.h @@ -227,8 +227,8 @@ extern Boolean BWQueryChanged ( Widget w ); extern int BWReadFile ( Widget w, _Xconst _XtString filename, _Xconst _XtString basename ); extern int BWWriteFile ( Widget w, _Xconst _XtString filename, _Xconst _XtString basename ); extern String BWUnparseStatus ( Widget w ); -extern String BWGetFilename ( Widget w, String *str ); -extern String BWGetBasename ( Widget w, String *str ); +extern _XtString BWGetFilename ( Widget w, _XtString *str ); +extern _XtString BWGetBasename ( Widget w, _XtString *str ); extern void BWChangeBasename ( Widget w, _Xconst _XtString str ); extern void BWRemoveAllRequests ( Widget w ); extern void BWClearHotSpot ( Widget w ); @@ -250,7 +250,7 @@ extern void BWSwitchStippled ( Widget w ); extern void BWRedrawMark ( Widget w ); extern Boolean BWQueryAxes ( Widget w ); extern void BWHighlightAxes ( Widget w ); -extern String BWGetFilepath ( Widget w, String *str ); +extern _XtString BWGetFilepath ( Widget w, _XtString *str ); extern void BWZoomOut ( Widget w ); extern void BWZoomMarked ( Widget w ); extern void BWRescale ( Widget w, Dimension width, Dimension height ); diff --git a/BitmapP.h b/BitmapP.h index 08e4c65..2ab711e 100644 --- a/BitmapP.h +++ b/BitmapP.h @@ -119,7 +119,8 @@ typedef struct { Dimension margin, squareW, squareH, width, height; XPoint hot; int button_function[5]; - String filename, basename; + _XtString filename; + _XtString basename; /* private state */ String size; Position horizOffset, vertOffset; diff --git a/Dialog.c b/Dialog.c index e2e3ac2..bf00b05 100644 --- a/Dialog.c +++ b/Dialog.c @@ -127,7 +127,7 @@ CreateDialog(Widget top_widget, String name, unsigned long options) } void -PopdownDialog(Dialog popup, String *answer) +PopdownDialog(Dialog popup, _XtString *answer) { if (answer) *answer = XawDialogGetValueString(popup->dialog_widget); @@ -137,7 +137,7 @@ PopdownDialog(Dialog popup, String *answer) unsigned long PopupDialog(Dialog popup, String message, String suggestion, - String *answer, XtGrabKind grab) + _XtString *answer, XtGrabKind grab) { Position popup_x, popup_y, top_x, top_y; Dimension popup_width, popup_height, top_width, top_height, border_width; diff --git a/Dialog.h b/Dialog.h index d5727ff..529918c 100644 --- a/Dialog.h +++ b/Dialog.h @@ -51,5 +51,5 @@ typedef struct { } DialogButton; extern Dialog CreateDialog(Widget, String, unsigned long); -extern unsigned long PopupDialog(Dialog, String, String, String *, XtGrabKind); -extern void PopdownDialog(Dialog, String *); +extern unsigned long PopupDialog(Dialog, String, String, _XtString *, XtGrabKind); +extern void PopdownDialog(Dialog, _XtString *); diff --git a/Makefile.am b/Makefile.am index def4d8b..4e44ade 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,6 +22,8 @@ SUBDIRS=man bin_PROGRAMS = bitmap bmtoa atobm +AM_CPPFLAGS = -D_CONST_X_STRING + bitmap_CFLAGS = $(CWARNFLAGS) $(BITMAP_CFLAGS) bitmap_LDADD = $(BITMAP_LIBS) $(MATH_LIBS) bitmap_SOURCES = \ -- cgit v1.2.3