Skip to content

Commit ed73b96

Browse files
committed
Write more cleanly
1 parent 1df13c4 commit ed73b96

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/logkeys.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,12 @@ void parse_input_keymap()
258258
if (stdin == NULL)
259259
error(EXIT_FAILURE, errno, "Error opening input keymap '%s'", args.keymap.c_str());
260260

261-
unsigned int i = -1;
262261
unsigned int line_number = 0;
263262
wchar_t func_string[32];
264263
wchar_t line[32];
265264

266-
while (!feof(stdin)) {
267-
268-
if (++i >= sizeof(char_or_func)) break; // only ever read up to 128 keycode bindings (currently N_KEYS_DEFINED are used)
269-
265+
// only ever read up to 128 keycode bindings (currently N_KEYS_DEFINED are used)
266+
for (unsigned int i=0; i <= sizeof(char_or_func)-1 && !feof(stdin); ++i) {
270267
if (is_used_key(i)) {
271268
++line_number;
272269
if(fgetws(line, sizeof(line), stdin) == NULL) {
@@ -295,7 +292,7 @@ void parse_input_keymap()
295292
error_at_line(EXIT_FAILURE, 0, args.keymap.c_str(), line_number, "Invalid function key string"); // does this ever happen?
296293
wcscpy(func_keys[to_func_keys_index(i)], func_string);
297294
}
298-
} // while (!feof(stdin))
295+
} // for
299296
fclose(stdin);
300297

301298
if (line_number < N_KEYS_DEFINED)

0 commit comments

Comments
 (0)