slock-git-20161012-control-clear.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
slock-git-20161012-control-clear.diff (844B)
---
1 diff --git a/config.def.h b/config.def.h
2 index 6fba2b6..933152b 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -10,3 +10,6 @@ static const char *colorname[NUMCOLS] = {
6
7 /* treat a cleared input like a wrong password */
8 static const int failonclear = 1;
9 +
10 +/* allow control key to trigger fail on clear */
11 +static const int controlkeyclear = 0;
12 diff --git a/slock.c b/slock.c
13 index 4d7f06f..15552ef 100644
14 --- a/slock.c
15 +++ b/slock.c
16 @@ -180,8 +180,9 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
17 passwd[len--] = '\0';
18 break;
19 default:
20 - if (num && !iscntrl((int)buf[0]) &&
21 - (len + num < sizeof(passwd))) {
22 + if (controlkeyclear && iscntrl((int)buf[0]))
23 + continue;
24 + if (num && (len + num < sizeof(passwd))) {
25 memcpy(passwd + len, buf, num);
26 len += num;
27 }