From: Christophe CURIS <christophe.cu...@free.fr>

As reported by Milan Čermák, using this variable breaks compilation on
Solaris, because it is a hack which is not standard. To ensure portability,
we now rely on main's argv[0] which is always available.

Signed-off-by: Christophe CURIS <christophe.cu...@free.fr>
---
 util/convertfonts.c | 13 +++++++------
 util/geticonset.c   |  9 +++++----
 util/getstyle.c     | 11 ++++++-----
 util/seticons.c     | 11 ++++++-----
 util/setstyle.c     | 17 +++++++++--------
 util/wdread.c       |  7 ++++---
 util/wdwrite.c      |  9 +++++----
 util/wmgenmenu.c    |  7 ++++---
 util/wmmenugen.c    | 17 +++++++++--------
 util/wmsetbg.c      | 15 ++++++++-------
 util/wxcopy.c       | 31 ++++++++++++++++---------------
 util/wxpaste.c      | 21 +++++++++++----------
 12 files changed, 90 insertions(+), 78 deletions(-)

diff --git a/util/convertfonts.c b/util/convertfonts.c
index dc34f67..1674ced 100644
--- a/util/convertfonts.c
+++ b/util/convertfonts.c
@@ -56,12 +56,12 @@ char *FontOptions[] = {
        NULL
 };
 
-extern char *__progname;
+static const char *prog_name;
 
 
 static noreturn void print_help(int print_usage, int exitval)
 {
-       printf("Usage: %s [-h] [-v] [--keep-xlfd] <style_file>\n", __progname);
+       printf("Usage: %s [-h] [-v] [--keep-xlfd] <style_file>\n", prog_name);
        if (print_usage) {
                puts("Converts fonts in a style file into fontconfig format");
                puts("");
@@ -92,10 +92,11 @@ int main(int argc, char **argv)
                { NULL,         0,              NULL,           0 }
        };
 
+       prog_name = argv[0];
        while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
                switch(ch) {
                        case 'v':
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                return 0;
                                /* NOTREACHED */
                        case 'h':
@@ -122,7 +123,7 @@ int main(int argc, char **argv)
        }
 
        if (!S_ISREG(st.st_mode)) {             /* maybe symlink too? */
-               fprintf(stderr, "%s: `%s' is not a regular file\n", __progname, 
file);
+               fprintf(stderr, "%s: `%s' is not a regular file\n", prog_name, 
file);
                return 1;
        }
 
@@ -135,12 +136,12 @@ int main(int argc, char **argv)
        style = WMReadPropListFromFile(file);
        if (!style) {
                perror(file);
-               printf("%s: could not load style file\n", __progname);
+               printf("%s: could not load style file\n", prog_name);
                return 1;
        }
 
        if (!WMIsPLDictionary(style)) {
-               printf("%s: '%s' is not a well formatted style file\n", 
__progname, file);
+               printf("%s: '%s' is not a well formatted style file\n", 
prog_name, file);
                return 1;
        }
 
diff --git a/util/geticonset.c b/util/geticonset.c
index 3c9dea8..4505551 100644
--- a/util/geticonset.c
+++ b/util/geticonset.c
@@ -38,11 +38,11 @@
 
 #include "../src/wconfig.h"
 
-extern char *__progname;
+static const char *prog_name;
 
 static noreturn void print_help(int print_usage, int exitval)
 {
-       printf("Usage: %s [-h] [-v] [file]\n", __progname);
+       printf("Usage: %s [-h] [-v] [file]\n", prog_name);
        if (print_usage) {
                puts("Retrieves program icon configuration and output to FILE 
or to stdout");
                puts("");
@@ -65,10 +65,11 @@ int main(int argc, char **argv)
                { NULL,         0,              NULL,           0 }
        };
 
+       prog_name = argv[0];
        while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
                switch(ch) {
                        case 'v':
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                return 0;
                                /* NOTREACHED */
                        case 'h':
@@ -88,7 +89,7 @@ int main(int argc, char **argv)
 
        all_windows = WMReadPropListFromFile(path);
        if (!all_windows) {
-               printf("%s: could not load WindowMaker configuration file 
\"%s\".\n", __progname, path);
+               printf("%s: could not load WindowMaker configuration file 
\"%s\".\n", prog_name, path);
                return 1;
        }
 
diff --git a/util/getstyle.c b/util/getstyle.c
index bf321c3..c39d266 100644
--- a/util/getstyle.c
+++ b/util/getstyle.c
@@ -129,7 +129,7 @@ static char *font_options[] = {
        NULL
 };
 
-extern char *__progname;
+static const char *prog_name;
 
 WMPropList *PixmapPath = NULL;
 
@@ -138,7 +138,7 @@ char *ThemePath = NULL;
 
 static noreturn void print_help(int print_usage, int exitval)
 {
-       printf("Usage: %s [-t] [-p] [-h] [-v] [file]\n", __progname);
+       printf("Usage: %s [-t] [-p] [-h] [-v] [file]\n", prog_name);
        if (print_usage) {
                puts("Retrieves style/theme configuration and outputs to 
~/GNUstep/Library/WindowMaker/Themes/file.themed/style or to stdout");
                puts("");
@@ -299,10 +299,11 @@ int main(int argc, char **argv)
                { NULL,                 0,              NULL,   0 }
        };
 
+       prog_name = argv[0];
        while ((ch = getopt_long(argc, argv, "ptvh", longopts, NULL)) != -1)
                switch(ch) {
                        case 'v':
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                return 0;
                                /* NOTREACHED */
                        case 'h':
@@ -329,7 +330,7 @@ int main(int argc, char **argv)
                style_file = argv[argc - 1];
 
        if (make_pack && !style_file) {
-               printf("%s: you must supply a name for the theme pack\n", 
__progname);
+               printf("%s: you must supply a name for the theme pack\n", 
prog_name);
                return 1;
        }
 
@@ -339,7 +340,7 @@ int main(int argc, char **argv)
 
        prop = WMReadPropListFromFile(path);
        if (!prop) {
-               printf("%s: could not load WindowMaker configuration file 
\"%s\".\n", __progname, path);
+               printf("%s: could not load WindowMaker configuration file 
\"%s\".\n", prog_name, path);
                return 1;
        }
 
diff --git a/util/seticons.c b/util/seticons.c
index bf741fd..4556d90 100644
--- a/util/seticons.c
+++ b/util/seticons.c
@@ -38,11 +38,11 @@
 
 #include "../src/wconfig.h"
 
-extern char *__progname;
+static const char *prog_name;
 
 static noreturn void print_help(int print_usage, int exitval)
 {
-       printf("Usage: %s [-h] [-v] [file]\n", __progname);
+       printf("Usage: %s [-h] [-v] [file]\n", prog_name);
        if (print_usage) {
                puts("Reads icon configuration from FILE and updates Window 
Maker.");
                puts("");
@@ -65,10 +65,11 @@ int main(int argc, char **argv)
                { NULL,         0,              NULL,           0 }
        };
 
+       prog_name = argv[0];
        while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
                switch(ch) {
                        case 'v':
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                return 0;
                                /* NOTREACHED */
                        case 'h':
@@ -91,13 +92,13 @@ int main(int argc, char **argv)
 
        all_windows = WMReadPropListFromFile(path);
        if (!all_windows) {
-               printf("%s: could not load WindowMaker configuration file 
\"%s\".\n", __progname, path);
+               printf("%s: could not load WindowMaker configuration file 
\"%s\".\n", prog_name, path);
                return 1;
        }
 
        iconset = WMReadPropListFromFile(argv[0]);
        if (!iconset) {
-               printf("%s: could not load icon set file \"%s\".\n", 
__progname, argv[0]);
+               printf("%s: could not load icon set file \"%s\".\n", prog_name, 
argv[0]);
                return 1;
        }
 
diff --git a/util/setstyle.c b/util/setstyle.c
index afd7b49..1a18afd 100644
--- a/util/setstyle.c
+++ b/util/setstyle.c
@@ -76,7 +76,7 @@ char *CursorOptions[] = {
        NULL
 };
 
-extern char *__progname;
+static const char *prog_name;
 int ignoreFonts = 0;
 int ignoreCursors = 0;
 
@@ -359,7 +359,7 @@ static void hackStyle(WMPropList * style)
 
 static noreturn void print_help(int print_usage, int exitval)
 {
-       printf("Usage: %s [OPTIONS] FILE\n", __progname);
+       printf("Usage: %s [OPTIONS] FILE\n", prog_name);
        if (print_usage) {
                puts("Reads style/theme configuration from FILE and updates 
Window Maker.");
                puts("");
@@ -392,10 +392,11 @@ int main(int argc, char **argv)
                { NULL,         0,                      NULL,                   
0 }
        };
 
+       prog_name = argv[0];
        while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
                switch(ch) {
                        case 'v':
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                return 0;
                                /* NOTREACHED */
                        case 'h':
@@ -431,7 +432,7 @@ int main(int argc, char **argv)
        prop = WMReadPropListFromFile(path);
        if (!prop) {
                perror(path);
-               printf("%s: could not load WindowMaker configuration file.\n", 
__progname);
+               printf("%s: could not load WindowMaker configuration file.\n", 
prog_name);
                return 1;
        }
 
@@ -450,14 +451,14 @@ int main(int argc, char **argv)
                strncat(buf, "/style", sizeof(buf) - strlen(buf) - 1);
 
                if (stat(buf, &st) != 0 || !S_ISREG(st.st_mode)) {      /* 
maybe symlink too? */
-                       printf("%s: %s: style file not found or not a file\n", 
__progname, buf);
+                       printf("%s: %s: style file not found or not a file\n", 
prog_name, buf);
                        return 1;
                }
 
                style = WMReadPropListFromFile(buf);
                if (!style) {
                        perror(buf);
-                       printf("%s: could not load style file.\n", __progname);
+                       printf("%s: could not load style file.\n", prog_name);
                        return 1;
                }
 
@@ -480,13 +481,13 @@ int main(int argc, char **argv)
                style = WMReadPropListFromFile(file);
                if (!style) {
                        perror(file);
-                       printf("%s:could not load style file.\n", __progname);
+                       printf("%s:could not load style file.\n", prog_name);
                        return 1;
                }
        }
 
        if (!WMIsPLDictionary(style)) {
-               printf("%s: '%s' is not a style file/theme\n", __progname, 
file);
+               printf("%s: '%s' is not a style file/theme\n", prog_name, file);
                return 1;
        }
 
diff --git a/util/wdread.c b/util/wdread.c
index a227817..2351b2d 100644
--- a/util/wdread.c
+++ b/util/wdread.c
@@ -44,11 +44,11 @@
 
 #include "../src/wconfig.h"
 
-extern char *__progname;
+static const char *prog_name;
 
 static noreturn void print_help(int print_usage, int exitval)
 {
-       printf("Usage: %s [OPTIONS] <domain> <key>\n", __progname);
+       printf("Usage: %s [OPTIONS] <domain> <key>\n", prog_name);
        if (print_usage) {
                puts("Read <key> from <domain>'s database");
                puts("");
@@ -70,10 +70,11 @@ int main(int argc, char **argv)
                { NULL,         0,                      NULL,                   
0 }
        };
 
+       prog_name = argv[0];
        while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
                switch(ch) {
                        case 'v':
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                return 0;
                                /* NOTREACHED */
                        case 'h':
diff --git a/util/wdwrite.c b/util/wdwrite.c
index 3578d07..2ff1670 100644
--- a/util/wdwrite.c
+++ b/util/wdwrite.c
@@ -43,11 +43,11 @@
 
 #include "../src/wconfig.h"
 
-extern char *__progname;
+static const char *prog_name;
 
 static noreturn void print_help(int print_usage, int exitval)
 {
-       printf("Usage: %s [OPTIONS] <domain> <key> <value>\n", __progname);
+       printf("Usage: %s [OPTIONS] <domain> <key> <value>\n", prog_name);
        if (print_usage) {
                puts("Write <value> for <key> in <domain>'s database");
                puts("");
@@ -69,10 +69,11 @@ int main(int argc, char **argv)
                { NULL,         0,                      NULL,                   
0 }
        };
 
+       prog_name = argv[0];
        while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
                switch(ch) {
                        case 'v':
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                return 0;
                                /* NOTREACHED */
                        case 'h':
@@ -94,7 +95,7 @@ int main(int argc, char **argv)
        key = WMCreatePLString(argv[1]);
        value = WMCreatePropListFromDescription(argv[2]);
        if (!value) {
-               printf("%s: syntax error in value \"%s\"", __progname, argv[2]);
+               printf("%s: syntax error in value \"%s\"", prog_name, argv[2]);
                return 1;
        }
 
diff --git a/util/wmgenmenu.c b/util/wmgenmenu.c
index 21010f1..e7599ce 100644
--- a/util/wmgenmenu.c
+++ b/util/wmgenmenu.c
@@ -31,7 +31,7 @@ static void find_and_write(const char *group, char 
*list[][2], int this_is_termi
 static void other_window_managers(void);
 static void print_help(int print_usage, int exitval);
 
-extern char *__progname;
+static const char *prog_name;
 
 char *path, *terminal = NULL;
 
@@ -54,10 +54,11 @@ int main(int argc, char *argv[])
                { NULL,                 0,              NULL,   0 }
        };
 
+       prog_name = argv[0];
        while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
                switch (ch) {
                case 'v':
-                       printf("%s (Window Maker %s)\n", __progname, VERSION);
+                       printf("%s (Window Maker %s)\n", prog_name, VERSION);
                        return 0;
                        /* NOTREACHED */
                case 'h':
@@ -500,7 +501,7 @@ static void other_window_managers(void)
 
 noreturn void print_help(int print_usage, int exitval)
 {
-       printf("Usage: %s [-h] [-v]\n", __progname);
+       printf("Usage: %s [-h] [-v]\n", prog_name);
        if (print_usage) {
                puts("Writes a menu structure usable as 
~/GNUstep/Defaults/WMRootMenu to stdout");
                puts("");
diff --git a/util/wmmenugen.c b/util/wmmenugen.c
index 437b989..0c55d51 100644
--- a/util/wmmenugen.c
+++ b/util/wmmenugen.c
@@ -48,7 +48,7 @@ static const char *terminal;
 static fct_parse_menufile *parse;
 static fct_validate_filename *validateFilename;
 
-extern char *__progname;
+static const char *prog_name;
 
 /* Global Variables from wmmenugen.h */
 WMTreeNode *menu;
@@ -60,6 +60,7 @@ int main(int argc, char **argv)
        int i;
        int *previousDepth;
 
+       prog_name = argv[0];
        plMenuNodes = WMCreateArray(8); /* grows on demand */
        menu = (WMTreeNode *)NULL;
        parse = NULL;
@@ -77,7 +78,7 @@ int main(int argc, char **argv)
 
        if (argc < 3) {
                fprintf(stderr, "Usage: %s -parser:<parser> fspec [fpsec...] "
-                       "[-parser:<parser> fspec [fpsec...]...]\n", __progname);
+                       "[-parser:<parser> fspec [fpsec...]...]\n", prog_name);
                fputs(  "Known parsers: xdg wmconfig\n", stderr);
                return 1;
        }
@@ -97,28 +98,28 @@ int main(int argc, char **argv)
                                parse = &parse_wmconfig;
                                validateFilename = &wmconfig_validate_file;
                        } else {
-                               fprintf(stderr, "%s: Unknown parser \"%s\"\n", 
__progname, argv[i] + 8);
+                               fprintf(stderr, "%s: Unknown parser \"%s\"\n", 
prog_name, argv[i] + 8);
                        }
                        continue;
                }
 
                if (parse) {
                        if (stat(argv[i], &st) == -1) {
-                               fprintf(stderr, "%s: unable to stat \"%s\"\n", 
__progname, argv[i]);
+                               fprintf(stderr, "%s: unable to stat \"%s\"\n", 
prog_name, argv[i]);
                        } else if (S_ISREG(st.st_mode)) {
                                parse(argv[i], addWMMenuEntryCallback);
                        } else if (S_ISDIR(st.st_mode)) {
                                nftw(argv[i], dirParseFunc, 16, FTW_PHYS);
                        } else {
-                               fprintf(stderr, "%s: \"%s\" is not a file or 
directory\n", __progname, argv[i]);
+                               fprintf(stderr, "%s: \"%s\" is not a file or 
directory\n", prog_name, argv[i]);
                        }
                } else {
-                       fprintf(stderr, "%s: argument \"%s\" with no valid 
parser\n", __progname, argv[i]);
+                       fprintf(stderr, "%s: argument \"%s\" with no valid 
parser\n", prog_name, argv[i]);
                }
        }
 
        if (!menu) {
-               fprintf(stderr, "%s: parsers failed to create a valid menu\n", 
__progname);
+               fprintf(stderr, "%s: parsers failed to create a valid menu\n", 
prog_name);
                return 1;
        }
 
@@ -127,7 +128,7 @@ int main(int argc, char **argv)
 
        i = WMGetArrayItemCount(plMenuNodes);
        if (i > 2) { /* more than one submenu unprocessed is almost certainly 
an error */
-               fprintf(stderr, "%s: unprocessed levels on the stack. 
fishy.\n", __progname);
+               fprintf(stderr, "%s: unprocessed levels on the stack. 
fishy.\n", prog_name);
                return 1;
        } else if (i > 1 ) { /* possibly the top-level attachment is not yet 
done */
                WMPropList *first, *next;
diff --git a/util/wmsetbg.c b/util/wmsetbg.c
index c25d60b..aee1b56 100644
--- a/util/wmsetbg.c
+++ b/util/wmsetbg.c
@@ -85,7 +85,7 @@ Bool xineStretch = False;
 Pixmap CurrentPixmap = None;
 char *PixmapPath = NULL;
 
-extern char *__progname;
+static const char *prog_name;
 
 typedef struct BackgroundTexture {
        int refcount;
@@ -1152,7 +1152,7 @@ static char *getFullPixmapPath(const char *file)
 
 static void print_help(void)
 {
-       printf("Usage: %s [options] [image]\n", __progname);
+       printf("Usage: %s [options] [image]\n", prog_name);
        puts("Sets the workspace background to the specified image or a texture 
and");
        puts("optionally update Window Maker configuration");
        puts("");
@@ -1247,6 +1247,7 @@ int main(int argc, char **argv)
 
        WMInitializeApplication("wmsetbg", &argc, argv);
 
+       prog_name = argv[0];
        for (i = 1; i < argc; i++) {
                if (strcmp(argv[i], "-helper") == 0) {
                        helperMode = 1;
@@ -1324,7 +1325,7 @@ int main(int argc, char **argv)
                                quit(1);
                        }
                } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], 
"--version") == 0) {
-                       printf("%s (Window Maker %s)\n", __progname, VERSION);
+                       printf("%s (Window Maker %s)\n", prog_name, VERSION);
                        quit(0);
                } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], 
"--help") == 0) {
                        print_help();
@@ -1332,14 +1333,14 @@ int main(int argc, char **argv)
                } else if (argv[i][0] != '-') {
                        image_name = argv[i];
                } else {
-                       printf("%s: invalid argument '%s'\n", __progname, 
argv[i]);
-                       printf("Try '%s --help' for more information\n", 
__progname);
+                       printf("%s: invalid argument '%s'\n", prog_name, 
argv[i]);
+                       printf("Try '%s --help' for more information\n", 
prog_name);
                        quit(1);
                }
        }
        if (!image_name && !texture && !helperMode) {
-               printf("%s: you must specify a image file name or a texture\n", 
__progname);
-               printf("Try '%s --help' for more information\n", __progname);
+               printf("%s: you must specify a image file name or a texture\n", 
prog_name);
+               printf("Try '%s --help' for more information\n", prog_name);
                quit(1);
        }
 
diff --git a/util/wxcopy.c b/util/wxcopy.c
index d7e01b6..256c45b 100644
--- a/util/wxcopy.c
+++ b/util/wxcopy.c
@@ -31,11 +31,11 @@
 #define LINESIZE       (4*1024)
 #define MAXDATA                (64*1024)
 
-extern char *__progname;
+static const char *prog_name;
 
 static void print_help(void)
 {
-       printf("Usage: %s [OPTIONS] [FILE]\n", __progname);
+       printf("Usage: %s [OPTIONS] [FILE]\n", prog_name);
        puts("Copies data from FILE or stdin into X cut buffer.");
        puts("");
        puts("  -display <display>              display to use");
@@ -70,37 +70,38 @@ int main(int argc, char **argv)
        int limit_check = 1;
        int clear_selection = 0;
 
+       prog_name = argv[0];
        for (i = 1; i < argc; i++) {
                if (argv[i][0] == '-') {
                        if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], 
"--help") == 0) {
                                print_help();
                                exit(0);
                        } else if (strcmp(argv[i], "-v") == 0 || 
strcmp(argv[i], "--version") == 0) {
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                exit(0);
                        } else if (strcmp(argv[i], "-cutbuffer") == 0 || 
strcmp(argv[i], "--cutbuffer") == 0) {
                                if (i < argc - 1) {
                                        i++;
                                        if (sscanf(argv[i], "%i", &buffer) != 
1) {
                                                fprintf(stderr, "%s: could not 
convert '%s' to int\n",
-                                                       __progname, argv[i]);
+                                                       prog_name, argv[i]);
                                                exit(1);
                                        }
                                        if (buffer < 0 || buffer > 7) {
-                                               fprintf(stderr, "%s: invalid 
buffer number %i\n", __progname, buffer);
+                                               fprintf(stderr, "%s: invalid 
buffer number %i\n", prog_name, buffer);
                                                exit(1);
                                        }
                                } else {
-                                       printf("%s: missing argument for 
'%s'\n", __progname, argv[i]);
-                                       printf("Try '%s --help' for more 
information\n", __progname);
+                                       printf("%s: missing argument for 
'%s'\n", prog_name, argv[i]);
+                                       printf("Try '%s --help' for more 
information\n", prog_name);
                                        exit(1);
                                }
                        } else if (strcmp(argv[i], "-display") == 0) {
                                if (i < argc - 1) {
                                        display_name = argv[++i];
                                } else {
-                                       printf("%s: missing argument for 
'%s'\n", __progname, argv[i]);
-                                       printf("Try '%s --help' for more 
information\n", __progname);
+                                       printf("%s: missing argument for 
'%s'\n", prog_name, argv[i]);
+                                       printf("Try '%s --help' for more 
information\n", prog_name);
                                        exit(1);
                                }
                        } else if (strcmp(argv[i], "-clearselection") == 0
@@ -109,8 +110,8 @@ int main(int argc, char **argv)
                        } else if (strcmp(argv[i], "-nolimit") == 0 || 
strcmp(argv[i], "--no-limit") == 0) {
                                limit_check = 0;
                        } else {
-                               printf("%s: invalid argument '%s'\n", 
__progname, argv[i]);
-                               printf("Try '%s --help' for more 
information\n", __progname);
+                               printf("%s: invalid argument '%s'\n", 
prog_name, argv[i]);
+                               printf("Try '%s --help' for more 
information\n", prog_name);
                                exit(1);
                        }
                } else {
@@ -124,7 +125,7 @@ int main(int argc, char **argv)
 
                        snprintf(line, sizeof(line),
                                 "%s: could not open \"%s\"",
-                                __progname, filename);
+                                prog_name, filename);
                        perror(line);
                        exit(1);
                }
@@ -133,7 +134,7 @@ int main(int argc, char **argv)
        dpy = XOpenDisplay(display_name);
        XSetErrorHandler(errorHandler);
        if (!dpy) {
-               fprintf(stderr, "%s: could not open display \"%s\"\n", 
__progname, XDisplayName(display_name));
+               fprintf(stderr, "%s: could not open display \"%s\"\n", 
prog_name, XDisplayName(display_name));
                exit(1);
        }
 
@@ -218,7 +219,7 @@ int main(int argc, char **argv)
                        nbuf = buf;
                }
                if (!nbuf) {
-                       fprintf(stderr, "%s: out of memory\n", __progname);
+                       fprintf(stderr, "%s: out of memory\n", prog_name);
                        exit(1);
                }
                buf = nbuf;
@@ -232,7 +233,7 @@ int main(int argc, char **argv)
                        fprintf
                            (stderr,
                             "%s: too much data in input - more than %d bytes\n"
-                            "  use the -nolimit argument to remove the limit 
check.\n", __progname, MAXDATA);
+                            "  use the -nolimit argument to remove the limit 
check.\n", prog_name, MAXDATA);
                        exit(1);
                }
        }
diff --git a/util/wxpaste.c b/util/wxpaste.c
index 9605787..9b1f3cb 100644
--- a/util/wxpaste.c
+++ b/util/wxpaste.c
@@ -35,11 +35,11 @@
 
 #define MAXDATA                (4*1024*1024)
 
-extern char *__progname;
+static const char *prog_name;
 
 static void print_help(void)
 {
-       printf("Usage: %s [OPTIONS] [FILE]\n", __progname);
+       printf("Usage: %s [OPTIONS] [FILE]\n", prog_name);
        puts("Copies data from X selection or cutbuffer to FILE or stdout.");
        puts("");
        puts("  -display display         display to use");
@@ -157,13 +157,14 @@ int main(int argc, char **argv)
        char *display_name = "";
        char *selection_name = NULL;
 
+       prog_name = argv[0];
        for (i = 1; i < argc; i++) {
                if (argv[i][0] == '-') {
                        if (argv[i][1] == 'h' || strcmp(argv[i], "--help") == 
0) {
                                print_help();
                                exit(0);
                        } else if (argv[i][1] == 'v' || strcmp(argv[i], 
"--version") == 0) {
-                               printf("%s (Window Maker %s)\n", __progname, 
VERSION);
+                               printf("%s (Window Maker %s)\n", prog_name, 
VERSION);
                                exit(0);
                        } else if (strcmp(argv[i], "-selection") == 0 || 
strcmp(argv[i], "--selection") == 0) {
                                if (i < argc - 1) {
@@ -183,28 +184,28 @@ int main(int argc, char **argv)
                                        i++;
                                        if (sscanf(argv[i], "%i", &buffer) != 
1) {
                                                fprintf(stderr, "%s: could not 
convert \"%s\" to int\n",
-                                                       __progname, argv[i]);
+                                                       prog_name, argv[i]);
                                                exit(1);
                                        }
                                        if (buffer < 0 || buffer > 7) {
-                                               fprintf(stderr, "%s: invalid 
buffer number %i\n", __progname, buffer);
+                                               fprintf(stderr, "%s: invalid 
buffer number %i\n", prog_name, buffer);
                                                exit(1);
                                        }
                                } else {
-                                       fprintf(stderr, "%s: invalid argument 
'%s'\n", __progname, argv[i]);
-                                       fprintf(stderr, "Try '%s --help' for 
more information.\n", __progname);
+                                       fprintf(stderr, "%s: invalid argument 
'%s'\n", prog_name, argv[i]);
+                                       fprintf(stderr, "Try '%s --help' for 
more information.\n", prog_name);
                                        exit(1);
                                }
                        }
                } else {
-                       fprintf(stderr, "%s: invalid argument '%s'\n", 
__progname, argv[i]);
-                       fprintf(stderr, "Try '%s --help' for more 
information.\n", __progname);
+                       fprintf(stderr, "%s: invalid argument '%s'\n", 
prog_name, argv[i]);
+                       fprintf(stderr, "Try '%s --help' for more 
information.\n", prog_name);
                        exit(1);
                }
        }
        dpy = XOpenDisplay(display_name);
        if (!dpy) {
-               fprintf(stderr, "%s: could not open display \"%s\"\n", 
__progname, XDisplayName(display_name));
+               fprintf(stderr, "%s: could not open display \"%s\"\n", 
prog_name, XDisplayName(display_name));
                exit(1);
        }
 
-- 
2.1.1


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to