From: Christophe CURIS <[email protected]>
This makes both the API and local function const-correct on their
input parameters.
---
WINGs/WINGs/WINGs.h | 24 ++++++++++++------------
WINGs/wbutton.c | 4 ++--
WINGs/wframe.c | 2 +-
WINGs/wlabel.c | 2 +-
WINGs/wlist.c | 14 ++++++++++----
WINGs/wwindow.c | 12 ++++++------
6 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h
index a807996..ba7e536 100644
--- a/WINGs/WINGs/WINGs.h
+++ b/WINGs/WINGs/WINGs.h
@@ -951,20 +951,20 @@ void WMSetBalloonEnabled(WMScreen *scr, Bool flag);
/* ---[ WINGs/wwindow.c ]------------------------------------------------- */
-WMWindow* WMCreateWindow(WMScreen *screen, char *name);
+WMWindow* WMCreateWindow(WMScreen *screen, const char *name);
-WMWindow* WMCreateWindowWithStyle(WMScreen *screen, char *name, int style);
+WMWindow* WMCreateWindowWithStyle(WMScreen *screen, const char *name, int
style);
-WMWindow* WMCreatePanelWithStyleForWindow(WMWindow *owner, char *name,
+WMWindow* WMCreatePanelWithStyleForWindow(WMWindow *owner, const char *name,
int style);
-WMWindow* WMCreatePanelForWindow(WMWindow *owner, char *name);
+WMWindow* WMCreatePanelForWindow(WMWindow *owner, const char *name);
void WMChangePanelOwner(WMWindow *win, WMWindow *newOwner);
-void WMSetWindowTitle(WMWindow *wPtr, char *title);
+void WMSetWindowTitle(WMWindow *wPtr, const char *title);
-void WMSetWindowMiniwindowTitle(WMWindow *win, char *title);
+void WMSetWindowMiniwindowTitle(WMWindow *win, const char *title);
void WMSetWindowMiniwindowImage(WMWindow *win, RImage *image);
@@ -1025,9 +1025,9 @@ void WMSetButtonFont(WMButton *bPtr, WMFont *font);
void WMSetButtonTextAlignment(WMButton *bPtr, WMAlignment alignment);
-void WMSetButtonText(WMButton *bPtr, char *text);
+void WMSetButtonText(WMButton *bPtr, const char *text);
-void WMSetButtonAltText(WMButton *bPtr, char *text);
+void WMSetButtonAltText(WMButton *bPtr, const char *text);
void WMSetButtonTextColor(WMButton *bPtr, WMColor *color);
@@ -1075,7 +1075,7 @@ void WMSetLabelTextAlignment(WMLabel *lPtr, WMAlignment
alignment);
void WMSetLabelRelief(WMLabel *lPtr, WMReliefType relief);
-void WMSetLabelText(WMLabel *lPtr, char *text);
+void WMSetLabelText(WMLabel *lPtr, const char *text);
WMFont* WMGetLabelFont(WMLabel *lPtr);
@@ -1091,7 +1091,7 @@ void WMSetFrameTitlePosition(WMFrame *fPtr,
WMTitlePosition position);
void WMSetFrameRelief(WMFrame *fPtr, WMReliefType relief);
-void WMSetFrameTitle(WMFrame *fPtr, char *title);
+void WMSetFrameTitle(WMFrame *fPtr, const char *title);
/* ---[ WINGs/wtextfield.c ]---------------------------------------------- */
@@ -1170,13 +1170,13 @@ void WMSetListAllowEmptySelection(WMList *lPtr, Bool
flag);
#define WMAddListItem(lPtr, text) WMInsertListItem((lPtr), -1, (text))
-WMListItem* WMInsertListItem(WMList *lPtr, int row, char *text);
+WMListItem* WMInsertListItem(WMList *lPtr, int row, const char *text);
void WMSortListItems(WMList *lPtr);
void WMSortListItemsWithComparer(WMList *lPtr, WMCompareDataProc *func);
-int WMFindRowOfListItemWithTitle(WMList *lPtr, char *title);
+int WMFindRowOfListItemWithTitle(WMList *lPtr, const char *title);
WMListItem* WMGetListItem(WMList *lPtr, int row);
diff --git a/WINGs/wbutton.c b/WINGs/wbutton.c
index 3771684..341bdc8 100644
--- a/WINGs/wbutton.c
+++ b/WINGs/wbutton.c
@@ -309,7 +309,7 @@ void WMSetButtonTextAlignment(WMButton * bPtr, WMAlignment
alignment)
}
}
-void WMSetButtonText(WMButton * bPtr, char *text)
+void WMSetButtonText(WMButton * bPtr, const char *text)
{
if (bPtr->caption)
wfree(bPtr->caption);
@@ -325,7 +325,7 @@ void WMSetButtonText(WMButton * bPtr, char *text)
}
}
-void WMSetButtonAltText(WMButton * bPtr, char *text)
+void WMSetButtonAltText(WMButton * bPtr, const char *text)
{
if (bPtr->altCaption)
wfree(bPtr->altCaption);
diff --git a/WINGs/wframe.c b/WINGs/wframe.c
index b7b30b5..38547e7 100644
--- a/WINGs/wframe.c
+++ b/WINGs/wframe.c
@@ -40,7 +40,7 @@ void WMSetFrameRelief(WMFrame * fPtr, WMReliefType relief)
}
}
-void WMSetFrameTitle(WMFrame * fPtr, char *title)
+void WMSetFrameTitle(WMFrame * fPtr, const char *title)
{
if (fPtr->caption)
wfree(fPtr->caption);
diff --git a/WINGs/wlabel.c b/WINGs/wlabel.c
index 589f4b3..9726cb1 100644
--- a/WINGs/wlabel.c
+++ b/WINGs/wlabel.c
@@ -111,7 +111,7 @@ void WMSetLabelRelief(WMLabel * lPtr, WMReliefType relief)
}
}
-void WMSetLabelText(WMLabel * lPtr, char *text)
+void WMSetLabelText(WMLabel * lPtr, const char *text)
{
if (lPtr->caption)
wfree(lPtr->caption);
diff --git a/WINGs/wlist.c b/WINGs/wlist.c
index e855754..360bb6c 100644
--- a/WINGs/wlist.c
+++ b/WINGs/wlist.c
@@ -179,7 +179,7 @@ void WMSortListItemsWithComparer(WMList * lPtr,
WMCompareDataProc * func)
paintList(lPtr);
}
-WMListItem *WMInsertListItem(WMList * lPtr, int row, char *text)
+WMListItem *WMInsertListItem(WMList * lPtr, int row, const char *text)
{
WMListItem *item;
@@ -635,12 +635,18 @@ static void handleEvents(XEvent * event, void *data)
static int matchTitle(const void *item, const void *title)
{
- return (strcmp(((WMListItem *) item)->text, (char *)title) == 0 ? 1 :
0);
+ return (strcmp(((WMListItem *) item)->text, (const char *)title) == 0 ?
1 : 0);
}
-int WMFindRowOfListItemWithTitle(WMList * lPtr, char *title)
+int WMFindRowOfListItemWithTitle(WMList * lPtr, const char *title)
{
- return WMFindInArray(lPtr->items, matchTitle, title);
+ /*
+ * We explicitely discard the 'const' attribute here because the
+ * call-back function handler must not be made with a const
+ * attribute, but our local call-back function (above) does have
+ * it properly set, so we're consistent
+ */
+ return WMFindInArray(lPtr->items, matchTitle, (char *) title);
}
void WMSelectListItem(WMList * lPtr, int row)
diff --git a/WINGs/wwindow.c b/WINGs/wwindow.c
index 53b98e8..d14b46b 100644
--- a/WINGs/wwindow.c
+++ b/WINGs/wwindow.c
@@ -98,7 +98,7 @@ static void realizeObserver(void *self, WMNotification * not)
realizeWindow(self);
}
-WMWindow *WMCreatePanelWithStyleForWindow(WMWindow * owner, char *name, int
style)
+WMWindow *WMCreatePanelWithStyleForWindow(WMWindow * owner, const char *name,
int style)
{
WMWindow *win;
@@ -108,7 +108,7 @@ WMWindow *WMCreatePanelWithStyleForWindow(WMWindow * owner,
char *name, int styl
return win;
}
-WMWindow *WMCreatePanelForWindow(WMWindow * owner, char *name)
+WMWindow *WMCreatePanelForWindow(WMWindow * owner, const char *name)
{
return WMCreatePanelWithStyleForWindow(owner, name,
WMTitledWindowMask |
WMClosableWindowMask | WMResizableWindowMask);
@@ -123,14 +123,14 @@ void WMChangePanelOwner(WMWindow * win, WMWindow *
newOwner)
}
}
-WMWindow *WMCreateWindow(WMScreen * screen, char *name)
+WMWindow *WMCreateWindow(WMScreen * screen, const char *name)
{
return WMCreateWindowWithStyle(screen, name, WMTitledWindowMask
| WMClosableWindowMask
| WMMiniaturizableWindowMask |
WMResizableWindowMask);
}
-WMWindow *WMCreateWindowWithStyle(WMScreen * screen, char *name, int style)
+WMWindow *WMCreateWindowWithStyle(WMScreen * screen, const char *name, int
style)
{
_Window *win;
@@ -250,7 +250,7 @@ static void setMiniwindow(WMWindow *win, RImage *image)
wfree(data);
}
-void WMSetWindowTitle(WMWindow * win, char *title)
+void WMSetWindowTitle(WMWindow * win, const char *title)
{
if (win->title != NULL)
wfree(win->title);
@@ -598,7 +598,7 @@ void WMSetWindowMiniwindowPixmap(WMWindow * win, WMPixmap *
pixmap)
}
}
-void WMSetWindowMiniwindowTitle(WMWindow * win, char *title)
+void WMSetWindowMiniwindowTitle(WMWindow * win, const char *title)
{
if ((win->miniTitle && !title) || (!win->miniTitle && title)
|| (title && win->miniTitle && strcoll(title, win->miniTitle) !=
0)) {
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].