aboutsummaryrefslogtreecommitdiff
path: root/system/pcmanfm/patches/0001-avoid-undefined-isdigit-behaviour.patch
blob: ad9a022db997ffe38dbc1ca8281f47c9c0068dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 0619a81f358d85568d990fc78c67e121e55f1c05 Mon Sep 17 00:00:00 2001
From: Michael Weghorn <m.weghorn@posteo.de>
Date: Thu, 27 Dec 2018 11:56:09 +0100
Subject: [PATCH] Avoid undefined 'isdigit()' behaviour

As the C11 standard says in section 7.4, 1),
the 'isdigit()' function is only well-defined
under this precondition:

> The header <ctype.h> declares several functions
> useful for classifying and mapping characters.
> In all cases the argument is an int, the value of
> which shall be representable as an unsigned char or
> shall equal the value of the macro EOF. If the argument
> has any other value, the behavior is undefined.

Therefore avoid to use the 'isdigit()' function here,
since the Gdk key codes and thus the 'keyval'
member from the 'GdkEventKey' do not always fulfill
this requirement and the behaviour is thus undefined.
---
 NEWS           | 5 +++++
 src/main-win.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index d2e6caa..c5b2285 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+Changes on 1.3.2 since 1.3.1:
+
+* Fixed case when some keyboard shortcuts stopped working: Alt+Home, Alt+Up.
+
+
 Changes on 1.3.1 since 1.3.0:
 
 * Allowed bigger sizes of icons and thumbnails as 256*256 appears to be small
diff --git a/src/main-win.c b/src/main-win.c
index 3907dba..49fc53b 100644
--- a/src/main-win.c
+++ b/src/main-win.c
@@ -2465,7 +2465,7 @@ static gboolean on_key_press_event(GtkWidget* w, GdkEventKey* evt)
 
     if(modifier == GDK_MOD1_MASK) /* Alt */
     {
-        if(isdigit(evt->keyval)) /* Alt + 0 ~ 9, nth tab */
+        if(evt->keyval >= '0' && evt->keyval <= '9') /* Alt + 0 ~ 9, nth tab */
         {
             int n;
             if(evt->keyval == '0')
-- 
2.1.4