use die() where it should be used
This commit is contained in:
parent
4d6dfeb1ad
commit
edb657eb96
16
sent.c
16
sent.c
@ -470,13 +470,13 @@ void load(FILE *fp)
|
|||||||
while (fgets(buf, sizeof(buf), fp)) {
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
if ((i+1) * sizeof(*slides) >= size)
|
if ((i+1) * sizeof(*slides) >= size)
|
||||||
if (!(slides = realloc(slides, (size += BUFSIZ))))
|
if (!(slides = realloc(slides, (size += BUFSIZ))))
|
||||||
eprintf("cannot realloc %u bytes:", size);
|
die("cannot realloc %u bytes:", size);
|
||||||
if (*buf == '#')
|
if (*buf == '#')
|
||||||
continue;
|
continue;
|
||||||
if ((p = strchr(buf, '\n')))
|
if ((p = strchr(buf, '\n')))
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if (!(slides[i].text = strdup(buf)))
|
if (!(slides[i].text = strdup(buf)))
|
||||||
eprintf("cannot strdup %u bytes:", strlen(buf)+1);
|
die("cannot strdup %u bytes:", strlen(buf)+1);
|
||||||
if (slides[i].text[0] == '@')
|
if (slides[i].text[0] == '@')
|
||||||
slides[i].img = pngopen(slides[i].text + 1);
|
slides[i].img = pngopen(slides[i].text + 1);
|
||||||
i++;
|
i++;
|
||||||
@ -496,9 +496,9 @@ void advance(const Arg *arg)
|
|||||||
idx = new_idx;
|
idx = new_idx;
|
||||||
xdraw();
|
xdraw();
|
||||||
if (slidecount > idx + 1 && slides[idx + 1].img && !pngread(slides[idx + 1].img))
|
if (slidecount > idx + 1 && slides[idx + 1].img && !pngread(slides[idx + 1].img))
|
||||||
eprintf("could not read image %s", slides[idx + 1].text + 1);
|
die("could not read image %s", slides[idx + 1].text + 1);
|
||||||
if (0 < idx && slides[idx - 1].img && !pngread(slides[idx - 1].img))
|
if (0 < idx && slides[idx - 1].img && !pngread(slides[idx - 1].img))
|
||||||
eprintf("could not read image %s", slides[idx - 1].text + 1);
|
die("could not read image %s", slides[idx - 1].text + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,7 +538,7 @@ void run()
|
|||||||
|
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
eprintf("sent " VERSION " (c) 2014 markus.teich@stusta.mhn.de\n" \
|
die("sent " VERSION " (c) 2014 markus.teich@stusta.mhn.de\n" \
|
||||||
"usage: sent [-f font] FILE1 [FILE2 ...]", argv0);
|
"usage: sent [-f font] FILE1 [FILE2 ...]", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,7 +572,7 @@ void xhints()
|
|||||||
XSizeHints *sizeh = NULL;
|
XSizeHints *sizeh = NULL;
|
||||||
|
|
||||||
if (!(sizeh = XAllocSizeHints()))
|
if (!(sizeh = XAllocSizeHints()))
|
||||||
eprintf("sent: Could not alloc size hints");
|
die("sent: Could not alloc size hints");
|
||||||
|
|
||||||
sizeh->flags = PSize;
|
sizeh->flags = PSize;
|
||||||
sizeh->height = xw.h;
|
sizeh->height = xw.h;
|
||||||
@ -587,7 +587,7 @@ void xinit()
|
|||||||
XTextProperty prop;
|
XTextProperty prop;
|
||||||
|
|
||||||
if (!(xw.dpy = XOpenDisplay(NULL)))
|
if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
eprintf("Can't open display.");
|
die("Can't open display.");
|
||||||
xw.scr = XDefaultScreen(xw.dpy);
|
xw.scr = XDefaultScreen(xw.dpy);
|
||||||
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
||||||
xw.w = DisplayWidth(xw.dpy, xw.scr);
|
xw.w = DisplayWidth(xw.dpy, xw.scr);
|
||||||
@ -607,7 +607,7 @@ void xinit()
|
|||||||
XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
|
XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
|
||||||
|
|
||||||
if(!(d = drw_create(xw.dpy, xw.scr, xw.win, xw.w, xw.h)))
|
if(!(d = drw_create(xw.dpy, xw.scr, xw.win, xw.w, xw.h)))
|
||||||
eprintf("Can't create drawing context.");
|
die("Can't create drawing context.");
|
||||||
sc = drw_scm_create(d, "#000000", "#FFFFFF");
|
sc = drw_scm_create(d, "#000000", "#FFFFFF");
|
||||||
drw_setscheme(d, sc);
|
drw_setscheme(d, sc);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user