Skip to content

Commit

Permalink
Fix formatting error when reading toml from file
Browse files Browse the repository at this point in the history
  • Loading branch information
chinarjoshi committed Sep 18, 2023
1 parent 3b95777 commit f2b3104
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/file_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@ bool match_line(pcre *re, pcre_extra *extras, int *ovector, char *line,
if (rc == PCRE_ERROR_NOMATCH)
return false;

// Extract alias
int alias_length = ovector[3] - ovector[2];
strncpy(alias, line + ovector[2], alias_length);
alias[alias_length] = '\0';

// Extract command
int command_len = ovector[5] - ovector[4];
if (line[ovector[4]] == '"' || line[ovector[4]] == '\'')
ovector[4]++;
strncpy(command, line + ovector[4], command_len);
while (command[command_len - 1] == '\'' || command[command_len - 1] == '"'
|| command[command_len - 1] == ' ') {
command_len--;
}
command[command_len] = '\0';

// Extract section
if (ovector[6] != -1) {
int section_len = ovector[7] - ovector[6];
strncpy(section, line + ovector[6], section_len);
Expand Down

0 comments on commit f2b3104

Please sign in to comment.