Introduction
Introduction Statistics Contact Development Disclaimer Help
xscreenshot: descriptive error message on invalid winid - xscreenshot - screen …
git clone git://git.codemadness.org/xscreenshot
Log
Files
Refs
README
LICENSE
---
commit bcf725e82616a2ff64e4cc70c529c185440df14d
parent c776bb923767e4ca1fa1e6179cfc37e3d0babc0a
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 16 Nov 2015 22:04:24 +0100
xscreenshot: descriptive error message on invalid winid
Diffstat:
M xscreenshot.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);
}
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.