- fixed aliases not being deleted correctly
- added end of file check in parser skip line
master
Alessandro Mauri 4 years ago
parent 1b00896fc7
commit 82b25f1e50
  1. 17
      hkd.c

17
hkd.c

@ -653,11 +653,10 @@ void parse_config_file (void)
hotkey_list_destroy(hotkey_list); hotkey_list_destroy(hotkey_list);
hotkey_list = NULL; hotkey_list = NULL;
while (!eof) { while (!eof) {
// FIXME: incorect line counting, specialli for multiline commands // FIXME: incorect line counting, especially for multiline commands
switch (parse_state) { switch (parse_state) {
// First state // First state
case NORM: case NORM:
// FIXME: never ending cycle of death
// remove whitespaces // remove whitespaces
while (isblank(*bb)) while (isblank(*bb))
bb++; bb++;
@ -677,8 +676,7 @@ void parse_config_file (void)
break; break;
// Skip line (comment) // Skip line (comment)
case LINE_SKIP: case LINE_SKIP:
// FIXME: check end of file for (;(bb - buffer) < file_size && *bb != '\n'; bb++);
for (;*bb != '\n'; bb++);
bb++; bb++;
linenum++; linenum++;
parse_state = NORM; parse_state = NORM;
@ -706,7 +704,6 @@ void parse_config_file (void)
break; break;
// Get keys // Get keys
case GET_KEYS: case GET_KEYS:
// FIXME: check end of file, token_size >= remaining_size
for (token_size = 0; token_size < (file_size - (bb - buffer)) && !(bb[token_size] == ':' || bb[token_size] == '\n'); token_size++); for (token_size = 0; token_size < (file_size - (bb - buffer)) && !(bb[token_size] == ':' || bb[token_size] == '\n'); token_size++);
if (bb[token_size] == '\n') if (bb[token_size] == '\n')
die("Error at line %d: " die("Error at line %d: "
@ -722,7 +719,6 @@ void parse_config_file (void)
break; break;
// Get command // Get command
case GET_CMD: case GET_CMD:
// FIXME: check end of file, token_size >= remaining_size
for (token_size = 0; token_size < (file_size - !(bb - buffer)); token_size++) { for (token_size = 0; token_size < (file_size - !(bb - buffer)); token_size++) {
if (bb[token_size] == ':') if (bb[token_size] == ':')
break; break;
@ -801,14 +797,13 @@ void parse_config_file (void)
} }
munmap(buffer, file_size); munmap(buffer, file_size);
for (struct hotkey_list_e *hkl = hotkey_list, *tmp; hkl; hkl = hkl->next) { for (struct hotkey_list_e *hkl = hotkey_list, *tmp; hkl;) {
if (hkl->fuzzy == ALIAS) {
tmp = hkl; tmp = hkl;
hkl = hkl->next; hkl = hkl->next;
if (tmp->fuzzy == ALIAS)
hotkey_list_remove(hotkey_list, tmp); hotkey_list_remove(hotkey_list, tmp);
} else { else
hotkey_size_mask |= 1 << (hkl->data.kb.size - 1); hotkey_size_mask |= 1 << (tmp->data.kb.size - 1);
}
} }
} }

Loading…
Cancel
Save