summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-02-22 23:13:45 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-02-22 23:23:52 -0800
commit718640ec0d212e8f3bf20005e35c1091646c9aea (patch)
tree914b6dd2aa92a05d2f72b2b28bf977957320a9b6
parent2e195507f5b17425d02af4dd6a4f151158d715c3 (diff)
Use strtoul instead of open coding it with sscanf
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xkill.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/xkill.c b/xkill.c
index 8ee3431..2e3d7a3 100644
--- a/xkill.c
+++ b/xkill.c
@@ -52,7 +52,6 @@ static char *ProgramName;
#define SelectButtonFirst (-2)
static int parse_button ( char *s, int *buttonp );
-static XID parse_id ( char *s );
static XID get_window_id ( Display *dpy, int screen, int button, char *msg );
static int catch_window_errors ( Display *dpy, XErrorEvent *ev );
static int kill_all_windows ( Display *dpy, int screenno, Bool top );
@@ -113,7 +112,12 @@ main(int argc, char *argv[])
continue;
case 'i': /* -id resourceid */
if (++i >= argc) usage ();
- id = parse_id (argv[i]);
+ id = strtoul (argv[i], NULL, 0);
+ if (id == 0 || id >= 0xFFFFFFFFU) {
+ fprintf (stderr, "%s: invalid id \"%s\"\n",
+ ProgramName, argv[i]);
+ Exit (1, dpy);
+ }
continue;
case 'b': /* -button number */
if (++i >= argc) usage ();
@@ -250,21 +254,6 @@ parse_button(char *s, int *buttonp)
return (1);
}
-
-static XID
-parse_id(char *s)
-{
- XID retval = None;
- char *fmt = "%ld"; /* since XID is long */
-
- if (s) {
- if (*s == '0') s++, fmt = "%lo";
- if (*s == 'x' || *s == 'X') s++, fmt = "%lx";
- sscanf (s, fmt, &retval);
- }
- return (retval);
-}
-
static XID
get_window_id(Display *dpy, int screen, int button, char *msg)
{