[PATCH:xkill] Use strcasecmp instead of a tolower loop & strcmp
Matthieu Herrb
matthieu at herrb.eu
Sat Apr 25 00:36:08 PDT 2015
On Thu, Apr 23, 2015 at 10:55:22PM -0700, Alan Coopersmith wrote:
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
Reviewed-by: Matthieu Herrb <matthieu at herrb.eu>
> ---
> xkill.c | 19 ++++---------------
> 1 file changed, 4 insertions(+), 15 deletions(-)
>
> diff --git a/xkill.c b/xkill.c
> index 32cb0cc..2db5847 100644
> --- a/xkill.c
> +++ b/xkill.c
> @@ -55,7 +55,7 @@ static char *ProgramName;
> #define SelectButtonAny (-1)
> #define SelectButtonFirst (-2)
>
> -static int parse_button ( char *s, int *buttonp );
> +static int parse_button ( const char *s, int *buttonp );
> static XID get_window_id ( Display *dpy, int screen, int button, const char *msg );
> static int catch_window_errors ( Display *dpy, XErrorEvent *ev );
> static int kill_all_windows ( Display *dpy, int screenno, Bool top );
> @@ -240,22 +240,11 @@ main(int argc, char *argv[])
> }
>
> static int
> -parse_button(char *s, int *buttonp)
> +parse_button(const char *s, int *buttonp)
> {
> - register char *cp;
> + const char *cp;
>
> - /* lower case name */
> - for (cp = s; *cp; cp++) {
> - if (isascii (*cp) && isupper (*cp)) {
> -#ifdef _tolower
> - *cp = (char) _tolower (*cp);
> -#else
> - *cp = (char) tolower (*cp);
> -#endif /* _tolower */
> - }
> - }
> -
> - if (strcmp (s, "any") == 0) {
> + if (strcasecmp (s, "any") == 0) {
> *buttonp = SelectButtonAny;
> return (1);
> }
> --
> 1.7.9.2
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
--
Matthieu Herrb
More information about the xorg-devel
mailing list