aboutsummaryrefslogtreecommitdiffstats
path: root/input-kbd.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2016-02-15 09:53:39 +0100
committerGerd Hoffmann <kraxel@redhat.com>2016-02-15 09:53:46 +0100
commit71253d8cb0a3824df1aa73f47631babf614b2702 (patch)
tree0a0470139898bf2b2d40b4946a87bfe6f46ae363 /input-kbd.c
parent81be8b5dc9245546bf1af297d6e6a580143c5273 (diff)
downloadinput-71253d8cb0a3824df1aa73f47631babf614b2702.tar.gz
input-kbd: allow comments
based on a patch by Preston Crow.
Diffstat (limited to 'input-kbd.c')
-rw-r--r--input-kbd.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/input-kbd.c b/input-kbd.c
index 3f0be52..8dd4e68 100644
--- a/input-kbd.c
+++ b/input-kbd.c
@@ -125,11 +125,21 @@ static void kbd_map_print(FILE *fp, struct kbd_map *map, int complete)
static int kbd_map_parse(FILE *fp, struct kbd_map *map)
{
struct kbd_entry entry;
- char line[80],scancode[80],keycode[80];
+ char line[1024],scancode[80],keycode[80];
+ char *c;
int i;
int idx = 0;
while ((NULL != fgets(line,sizeof(line),fp)) && (idx < map->keys)) {
+ c = strchr(line,'#');
+ if (c)
+ *c = 0;
+ c = line;
+ while (*c == ' ' || *c == '\t')
+ c++;
+ if (!*c || *c == '\n')
+ continue; // Blank or comment line
+
if (2 != sscanf(line," %80s = %80s", scancode, keycode)) {
fprintf(stderr,"parse error: %s",line);
return -1;