Skip to content

Commit

Permalink
Write more cleanly
Browse files Browse the repository at this point in the history
  • Loading branch information
za3k committed Aug 4, 2022
1 parent 1df13c4 commit ed73b96
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/logkeys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,12 @@ void parse_input_keymap()
if (stdin == NULL)
error(EXIT_FAILURE, errno, "Error opening input keymap '%s'", args.keymap.c_str());

unsigned int i = -1;
unsigned int line_number = 0;
wchar_t func_string[32];
wchar_t line[32];

while (!feof(stdin)) {

if (++i >= sizeof(char_or_func)) break; // only ever read up to 128 keycode bindings (currently N_KEYS_DEFINED are used)

// only ever read up to 128 keycode bindings (currently N_KEYS_DEFINED are used)
for (unsigned int i=0; i <= sizeof(char_or_func)-1 && !feof(stdin); ++i) {
if (is_used_key(i)) {
++line_number;
if(fgetws(line, sizeof(line), stdin) == NULL) {
Expand Down Expand Up @@ -295,7 +292,7 @@ void parse_input_keymap()
error_at_line(EXIT_FAILURE, 0, args.keymap.c_str(), line_number, "Invalid function key string"); // does this ever happen?
wcscpy(func_keys[to_func_keys_index(i)], func_string);
}
} // while (!feof(stdin))
} // for
fclose(stdin);

if (line_number < N_KEYS_DEFINED)
Expand Down

0 comments on commit ed73b96

Please sign in to comment.