Skip to content

Commit

Permalink
Enforce consistent style for linenoise package
Browse files Browse the repository at this point in the history
Since March 2020, Linenoise[1] has not been updated. Here, we enforce
the consistent code style and maintain our own copy of this package.

[1] https://github.com/antirez/linenoise
  • Loading branch information
jserv committed Feb 5, 2023
1 parent cc7b6ce commit 6dccf44
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 357 deletions.
12 changes: 6 additions & 6 deletions console.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ static bool cmd_maybe(const char *target, const char *src)
return true;
}

void completion(const char *buf, linenoiseCompletions *lc)
void completion(const char *buf, line_completions_t *lc)
{
if (strncmp("option ", buf, 7) == 0) {
param_element_t *plist = param_list;
Expand All @@ -659,7 +659,7 @@ void completion(const char *buf, linenoiseCompletions *lc)
strcat(str, "option ");
strcat(str, plist->name);
if (cmd_maybe(str, buf))
linenoiseAddCompletion(lc, str);
line_add_completion(lc, str);

plist = plist->next;
}
Expand All @@ -669,7 +669,7 @@ void completion(const char *buf, linenoiseCompletions *lc)
cmd_element_t *clist = cmd_list;
while (clist) {
if (cmd_maybe(clist->name, buf))
linenoiseAddCompletion(lc, clist->name);
line_add_completion(lc, clist->name);

clist = clist->next;
}
Expand All @@ -686,9 +686,9 @@ bool run_console(char *infile_name)
char *cmdline;
while (use_linenoise && (cmdline = linenoise(prompt))) {
interpret_cmd(cmdline);
linenoiseHistoryAdd(cmdline); /* Add to the history. */
linenoiseHistorySave(HISTORY_FILE); /* Save the history on disk. */
linenoiseFree(cmdline);
line_history_add(cmdline); /* Add to the history. */
line_history_save(HISTORY_FILE); /* Save the history on disk. */
line_free(cmdline);
while (buf_stack && buf_stack->fd != STDIN_FILENO)
cmd_select(0, NULL, NULL, NULL, NULL);
has_infile = false;
Expand Down
2 changes: 1 addition & 1 deletion console.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ bool finish_cmd();
bool run_console(char *infile_name);

/* Callback function to complete command by linenoise */
void completion(const char *buf, linenoiseCompletions *lc);
void completion(const char *buf, line_completions_t *lc);

#endif /* LAB0_CONSOLE_H */
Loading

0 comments on commit 6dccf44

Please sign in to comment.