xscreenshot

screen capture tool (mirror)
git clone git://git.2f30.org/xscreenshot
Log | Files | Refs | README | LICENSE

commit bcf725e82616a2ff64e4cc70c529c185440df14d
parent c776bb923767e4ca1fa1e6179cfc37e3d0babc0a
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon, 16 Nov 2015 22:04:24 +0100

xscreenshot: descriptive error message on invalid winid

Diffstat:
Mxscreenshot.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/xscreenshot.c b/xscreenshot.c @@ -35,6 +35,7 @@ main(int argc, char *argv[]) XWindowAttributes attr; uint32_t tmp, w, h; uint16_t rgba[4]; + char *ep; if (!(dpy = XOpenDisplay(NULL))) die("Can't XOpenDisplay"); @@ -44,9 +45,14 @@ main(int argc, char *argv[]) if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-v") == 0) usage(argv); errno = 0; - win = (Window)strtol(argv[1], NULL, 0); - if (errno) - usage(argv); + win = (Window)strtol(argv[1], &ep, 0); + if (errno || argv[1] == ep || *ep != '\0') { + fprintf(stderr, "strtol: invalid number: \"%s\"%s%s\n", + argv[1], + errno ? ": " : "", + errno ? strerror(errno) : ""); + exit(1); + } } else { win = RootWindow(dpy, 0); }