1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-13 04:15:50 +01:00

util: removed usage of external '__progname' because it is not portable

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.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-10-26 00:31:42 +02:00
committed by Carlos R. Mafra
parent ff8fc10a65
commit 3de5b8fb42
12 changed files with 90 additions and 78 deletions

View File

@@ -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;
}