Arrange diagnostic messages

Fix error messages to use argv0 instead of fixed “tabbed”.
Break usage message into multiple lines.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
Quentin Rameau 2016-01-03 13:01:14 +01:00 committed by Christoph Lohmann
parent 735bed5824
commit 105855240e

View File

@ -408,7 +408,7 @@ ecalloc(size_t n, size_t size)
void *p; void *p;
if (!(p = calloc(n, size))) if (!(p = calloc(n, size)))
die("tabbed: cannot calloc\n"); die("%s: cannot calloc\n", argv0);
return p; return p;
} }
@ -418,7 +418,7 @@ erealloc(void *o, size_t size)
void *p; void *p;
if (!(p = realloc(o, size))) if (!(p = realloc(o, size)))
die("tabbed: cannot realloc\n"); die("%s: cannot realloc\n", argv0);
return p; return p;
} }
@ -564,7 +564,7 @@ getcolor(const char *colstr)
XColor color; XColor color;
if (!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) if (!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
die("tabbed: cannot allocate color '%s'\n", colstr); die("%s: cannot allocate color '%s'\n", argv0, colstr);
return color.pixel; return color.pixel;
} }
@ -629,7 +629,8 @@ initfont(const char *fontstr)
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
if (missing) { if (missing) {
while (n--) while (n--)
fprintf(stderr, "tabbed: missing fontset: %s\n", missing[n]); fprintf(stderr, "%s: missing fontset: %s\n",
argv0, missing[n]);
XFreeStringList(missing); XFreeStringList(missing);
} }
@ -648,7 +649,7 @@ initfont(const char *fontstr)
dc.font.xfont = NULL; dc.font.xfont = NULL;
if (!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) && if (!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) &&
!(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
die("tabbed: cannot load font: '%s'\n", fontstr); die("%s: cannot load font: '%s'\n", argv0, fontstr);
dc.font.ascent = dc.font.xfont->ascent; dc.font.ascent = dc.font.xfont->ascent;
dc.font.descent = dc.font.xfont->descent; dc.font.descent = dc.font.xfont->descent;
@ -1097,7 +1098,7 @@ void
sigchld(int unused) sigchld(int unused)
{ {
if (signal(SIGCHLD, sigchld) == SIG_ERR) if (signal(SIGCHLD, sigchld) == SIG_ERR)
die("tabbed: cannot install SIGCHLD handler"); die("%s: cannot install SIGCHLD handler", argv0);
while (0 < waitpid(-1, NULL, WNOHANG)); while (0 < waitpid(-1, NULL, WNOHANG));
} }
@ -1112,12 +1113,12 @@ spawn(const Arg *arg)
setsid(); setsid();
if (arg && arg->v) { if (arg && arg->v) {
execvp(((char **)arg->v)[0], (char **)arg->v); execvp(((char **)arg->v)[0], (char **)arg->v);
fprintf(stderr, "tabbed: execvp %s", fprintf(stderr, "%s: execvp %s", argv0,
((char **)arg->v)[0]); ((char **)arg->v)[0]);
} else { } else {
cmd[cmd_append_pos] = NULL; cmd[cmd_append_pos] = NULL;
execvp(cmd[0], cmd); execvp(cmd[0], cmd);
fprintf(stderr, "tabbed: execvp %s", cmd[0]); fprintf(stderr, "%s: execvp %s", argv0, cmd[0]);
} }
perror(" failed"); perror(" failed");
exit(0); exit(0);
@ -1267,8 +1268,8 @@ xerror(Display *dpy, XErrorEvent *ee)
ee->error_code == BadDrawable)) ee->error_code == BadDrawable))
return 0; return 0;
fprintf(stderr, "tabbed: fatal error: request code=%d, error code=%d\n", fprintf(stderr, "%s: fatal error: request code=%d, error code=%d\n",
ee->request_code, ee->error_code); argv0, ee->request_code, ee->error_code);
return xerrorxlib(dpy, ee); /* may call exit */ return xerrorxlib(dpy, ee); /* may call exit */
} }
@ -1288,8 +1289,8 @@ xsettitle(Window w, const char *str)
void void
usage(void) usage(void)
{ {
die("usage: %s [-dfhsv] [-g geometry] [-n name] [-p [s+/-]pos] " die("usage: %s [-dfhsv] [-g geometry] [-n name] [-p [s+/-]pos]\n"
"[-r narg] [-o color] [-O color] [-t color] [-T color] " " [-r narg] [-o color] [-O color] [-t color] [-T color]\n"
" [-u color] [-U color] command...\n", argv0); " [-u color] [-U color] command...\n", argv0);
} }
@ -1351,9 +1352,8 @@ main(int argc, char *argv[])
urgbgcolor = EARGF(usage()); urgbgcolor = EARGF(usage());
break; break;
case 'v': case 'v':
die("tabbed-"VERSION", © 2009-2016" die("tabbed-"VERSION", © 2009-2016 tabbed engineers, "
" tabbed engineers, see LICENSE" "see LICENSE for details.\n");
" for details.\n");
break; break;
default: /* FALLTHROUGH */ default: /* FALLTHROUGH */
case 'h': case 'h':