From: Christophe CURIS <[email protected]>

This makes both the API and local function const-correct on their
input parameters.
---
 WINGs/WINGs/WINGs.h  |   26 +++++++++++++-------------
 WINGs/wapplication.c |    6 +++---
 WINGs/wappresource.c |   14 +++++++-------
 WINGs/wcolor.c       |    2 +-
 WINGs/wfont.c        |   20 ++++++++++----------
 WINGs/wpixmap.c      |    6 +++---
 6 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h
index 5682dfa..a807996 100644
--- a/WINGs/WINGs/WINGs.h
+++ b/WINGs/WINGs/WINGs.h
@@ -608,15 +608,15 @@ WMRect wmkrect(int x, int y, unsigned int width, unsigned 
int height);
 
 
 
-void WMInitializeApplication(char *applicationName, int *argc, char **argv);
+void WMInitializeApplication(const char *applicationName, int *argc, char 
**argv);
 
-void WMSetResourcePath(char *path);
+void WMSetResourcePath(const char *path);
 
 /* don't free the returned string */
 char* WMGetApplicationName(void);
 
 /* Try to locate resource file. ext may be NULL */
-char* WMPathForResourceOfType(char *resource, char *ext);
+char* WMPathForResourceOfType(const char *resource, const char *ext);
 
 /* ---[ WINGs/widgets.c ]------------------------------------------------- */
 
@@ -654,7 +654,7 @@ void WMSetApplicationIconPixmap(WMScreen *app, WMPixmap 
*icon);
 WMPixmap* WMGetApplicationIconPixmap(WMScreen *app);
 
 /* If color==NULL it will use the default color for panels: ae/aa/ae */
-WMPixmap* WMCreateApplicationIconBlendedPixmap(WMScreen *scr, RColor *color);
+WMPixmap* WMCreateApplicationIconBlendedPixmap(WMScreen *scr, const RColor 
*color);
 
 void WMSetApplicationIconWindow(WMScreen *scr, Window window);
 
@@ -745,7 +745,7 @@ void WMSetViewDragDestinationProcs(WMView *view, 
WMDragDestinationProcs *procs);
 
 Bool WMIsAntialiasingEnabled(WMScreen *scrPtr);
 
-WMFont* WMCreateFont(WMScreen *scrPtr, char *fontName);
+WMFont* WMCreateFont(WMScreen *scrPtr, const char *fontName);
 
 WMFont* WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style);
 
@@ -770,13 +770,13 @@ WMFont* WMSystemFontOfSize(WMScreen *scrPtr, int size);
 WMFont* WMBoldSystemFontOfSize(WMScreen *scrPtr, int size);
 
 void WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
-                  int x, int y, char *text, int length);
+                  int x, int y, const char *text, int length);
 
 void WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color,
                        WMColor *background, WMFont *font, int x, int y,
-                       char *text, int length);
+                       const char *text, int length);
 
-int WMWidthOfString(WMFont *font, char *text, int length);
+int WMWidthOfString(WMFont *font, const char *text, int length);
 
 /* ---[ WINGs/wpixmap.c ]------------------------------------------------- */
 
@@ -798,13 +798,13 @@ WMPixmap* WMCreatePixmapFromXPMData(WMScreen *scrPtr, 
char **data);
 
 WMSize WMGetPixmapSize(WMPixmap *pixmap);
 
-WMPixmap* WMCreatePixmapFromFile(WMScreen *scrPtr, char *fileName);
+WMPixmap* WMCreatePixmapFromFile(WMScreen *scrPtr, const char *fileName);
 
 WMPixmap* WMCreateBlendedPixmapFromRImage(WMScreen *scrPtr, RImage *image,
-                                          RColor *color);
+                                          const RColor *color);
 
-WMPixmap* WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, char *fileName,
-                                        RColor *color);
+WMPixmap* WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, const char *fileName,
+                                        const RColor *color);
 
 void WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y);
 
@@ -846,7 +846,7 @@ WMColor* WMCreateRGBAColor(WMScreen *scr, unsigned short 
red,
                            unsigned short green, unsigned short blue,
                            unsigned short alpha, Bool exact);
 
-WMColor* WMCreateNamedColor(WMScreen *scr, char *name, Bool exact);
+WMColor* WMCreateNamedColor(WMScreen *scr, const char *name, Bool exact);
 
 RColor WMGetRColorFromColor(WMColor *color);
 
diff --git a/WINGs/wapplication.c b/WINGs/wapplication.c
index 974441f..70a51ab 100644
--- a/WINGs/wapplication.c
+++ b/WINGs/wapplication.c
@@ -16,7 +16,7 @@ Bool W_ApplicationInitialized(void)
        return _WINGS_progname != NULL;
 }
 
-void WMInitializeApplication(char *applicationName, int *argc, char **argv)
+void WMInitializeApplication(const char *applicationName, int *argc, char 
**argv)
 {
        int i;
 
@@ -49,7 +49,7 @@ void WMInitializeApplication(char *applicationName, int 
*argc, char **argv)
        W_InitNotificationCenter();
 }
 
-void WMSetResourcePath(char *path)
+void WMSetResourcePath(const char *path)
 {
        if (WMApplication.resourcePath)
                wfree(WMApplication.resourcePath);
@@ -102,7 +102,7 @@ error:
        return NULL;
 }
 
-char *WMPathForResourceOfType(char *resource, char *ext)
+char *WMPathForResourceOfType(const char *resource, const char *ext)
 {
        char *path, *tmp, *appdir;
        int i;
diff --git a/WINGs/wappresource.c b/WINGs/wappresource.c
index cc5dd54..10e0ec4 100644
--- a/WINGs/wappresource.c
+++ b/WINGs/wappresource.c
@@ -77,17 +77,17 @@ WMPixmap *WMGetApplicationIconPixmap(WMScreen * scr)
        return scr->applicationIconPixmap;
 }
 
-WMPixmap *WMCreateApplicationIconBlendedPixmap(WMScreen * scr, RColor * color)
+WMPixmap *WMCreateApplicationIconBlendedPixmap(WMScreen * scr, const RColor * 
color)
 {
        WMPixmap *pix;
 
        if (scr->applicationIconImage) {
-               RColor gray;
-
-               gray.red = 0xae;
-               gray.green = 0xaa;
-               gray.blue = 0xae;
-               gray.alpha = 0xff;
+               static const RColor gray = {
+                       /* red   */ 0xAE,
+                       /* green */ 0xAA,
+                       /* blue  */ 0xAE,
+                       /* alpha */ 0xFF
+               };
 
                if (!color)
                        color = &gray;
diff --git a/WINGs/wcolor.c b/WINGs/wcolor.c
index cb04e63..a02c182 100644
--- a/WINGs/wcolor.c
+++ b/WINGs/wcolor.c
@@ -122,7 +122,7 @@ WMColor *WMCreateRGBAColor(WMScreen * scr, unsigned short 
red, unsigned short gr
        return color;
 }
 
-WMColor *WMCreateNamedColor(WMScreen * scr, char *name, Bool exact)
+WMColor *WMCreateNamedColor(WMScreen * scr, const char *name, Bool exact)
 {
        WMColor *color;
        XColor xcolor;
diff --git a/WINGs/wfont.c b/WINGs/wfont.c
index 62dd7d3..364df5f 100644
--- a/WINGs/wfont.c
+++ b/WINGs/wfont.c
@@ -16,7 +16,7 @@
 
 #define DEFAULT_SIZE WINGsConfiguration.defaultFontSize
 
-static FcPattern *xlfdToFcPattern(char *xlfd)
+static FcPattern *xlfdToFcPattern(const char *xlfd)
 {
        FcPattern *pattern;
        char *fname, *ptr;
@@ -41,7 +41,7 @@ static FcPattern *xlfdToFcPattern(char *xlfd)
        return pattern;
 }
 
-static char *xlfdToFcName(char *xlfd)
+static char *xlfdToFcName(const char *xlfd)
 {
        FcPattern *pattern;
        char *fname;
@@ -64,7 +64,7 @@ static Bool hasProperty(FcPattern * pattern, const char 
*property)
        return False;
 }
 
-static Bool hasPropertyWithStringValue(FcPattern * pattern, const char 
*object, char *value)
+static Bool hasPropertyWithStringValue(FcPattern * pattern, const char 
*object, const char *value)
 {
        FcChar8 *str;
        int id;
@@ -83,7 +83,7 @@ static Bool hasPropertyWithStringValue(FcPattern * pattern, 
const char *object,
        return False;
 }
 
-static char *makeFontOfSize(char *font, int size, char *fallback)
+static char *makeFontOfSize(const char *font, int size, const char *fallback)
 {
        FcPattern *pattern;
        char *result;
@@ -91,7 +91,7 @@ static char *makeFontOfSize(char *font, int size, char 
*fallback)
        if (font[0] == '-') {
                pattern = xlfdToFcPattern(font);
        } else {
-               pattern = FcNameParse((FcChar8 *) font);
+               pattern = FcNameParse((const FcChar8 *) font);
        }
 
        /*FcPatternPrint(pattern); */
@@ -104,7 +104,7 @@ static char *makeFontOfSize(char *font, int size, char 
*fallback)
        }
 
        if (fallback && !hasPropertyWithStringValue(pattern, FC_FAMILY, 
fallback)) {
-               FcPatternAddString(pattern, FC_FAMILY, (FcChar8 *) fallback);
+               FcPatternAddString(pattern, FC_FAMILY, (const FcChar8 *) 
fallback);
        }
 
        /*FcPatternPrint(pattern); */
@@ -115,7 +115,7 @@ static char *makeFontOfSize(char *font, int size, char 
*fallback)
        return result;
 }
 
-WMFont *WMCreateFont(WMScreen * scrPtr, char *fontName)
+WMFont *WMCreateFont(WMScreen * scrPtr, const char *fontName)
 {
        Display *display = scrPtr->display;
        WMFont *font;
@@ -250,7 +250,7 @@ WMFont *WMBoldSystemFontOfSize(WMScreen * scrPtr, int size)
        return font;
 }
 
-int WMWidthOfString(WMFont * font, char *text, int length)
+int WMWidthOfString(WMFont * font, const char *text, int length)
 {
        XGlyphInfo extents;
 
@@ -261,7 +261,7 @@ int WMWidthOfString(WMFont * font, char *text, int length)
        return extents.xOff;    /* don't ask :P */
 }
 
-void WMDrawString(WMScreen * scr, Drawable d, WMColor * color, WMFont * font, 
int x, int y, char *text, int length)
+void WMDrawString(WMScreen * scr, Drawable d, WMColor * color, WMFont * font, 
int x, int y, const char *text, int length)
 {
        XftColor xftcolor;
 
@@ -280,7 +280,7 @@ void WMDrawString(WMScreen * scr, Drawable d, WMColor * 
color, WMFont * font, in
 
 void
 WMDrawImageString(WMScreen * scr, Drawable d, WMColor * color, WMColor * 
background,
-                 WMFont * font, int x, int y, char *text, int length)
+                 WMFont * font, int x, int y, const char *text, int length)
 {
        XftColor textColor;
        XftColor bgColor;
diff --git a/WINGs/wpixmap.c b/WINGs/wpixmap.c
index 3902fc0..55c457b 100644
--- a/WINGs/wpixmap.c
+++ b/WINGs/wpixmap.c
@@ -64,7 +64,7 @@ WMPixmap *WMCreatePixmapFromXPixmaps(WMScreen * scrPtr, 
Pixmap pixmap, Pixmap ma
        return pixPtr;
 }
 
-WMPixmap *WMCreatePixmapFromFile(WMScreen * scrPtr, char *fileName)
+WMPixmap *WMCreatePixmapFromFile(WMScreen * scrPtr, const char *fileName)
 {
        WMPixmap *pixPtr;
        RImage *image;
@@ -101,7 +101,7 @@ WMPixmap *WMCreatePixmapFromRImage(WMScreen * scrPtr, 
RImage * image, int thresh
        return pixPtr;
 }
 
-WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * scrPtr, RImage * image, 
RColor * color)
+WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * scrPtr, RImage * image, 
const RColor * color)
 {
        WMPixmap *pixPtr;
        RImage *copy;
@@ -117,7 +117,7 @@ WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * 
scrPtr, RImage * image, RCo
        return pixPtr;
 }
 
-WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * scrPtr, char *fileName, 
RColor * color)
+WMPixmap *WMCreateBlendedPixmapFromFile(WMScreen * scrPtr, const char 
*fileName, const RColor * color)
 {
        WMPixmap *pixPtr;
        RImage *image;
-- 
1.7.10.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to