Skip to content

Commit 6dccf44

Browse files
committed
Enforce consistent style for linenoise package
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
1 parent cc7b6ce commit 6dccf44

File tree

6 files changed

+339
-357
lines changed

6 files changed

+339
-357
lines changed

console.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ static bool cmd_maybe(const char *target, const char *src)
645645
return true;
646646
}
647647

648-
void completion(const char *buf, linenoiseCompletions *lc)
648+
void completion(const char *buf, line_completions_t *lc)
649649
{
650650
if (strncmp("option ", buf, 7) == 0) {
651651
param_element_t *plist = param_list;
@@ -659,7 +659,7 @@ void completion(const char *buf, linenoiseCompletions *lc)
659659
strcat(str, "option ");
660660
strcat(str, plist->name);
661661
if (cmd_maybe(str, buf))
662-
linenoiseAddCompletion(lc, str);
662+
line_add_completion(lc, str);
663663

664664
plist = plist->next;
665665
}
@@ -669,7 +669,7 @@ void completion(const char *buf, linenoiseCompletions *lc)
669669
cmd_element_t *clist = cmd_list;
670670
while (clist) {
671671
if (cmd_maybe(clist->name, buf))
672-
linenoiseAddCompletion(lc, clist->name);
672+
line_add_completion(lc, clist->name);
673673

674674
clist = clist->next;
675675
}
@@ -686,9 +686,9 @@ bool run_console(char *infile_name)
686686
char *cmdline;
687687
while (use_linenoise && (cmdline = linenoise(prompt))) {
688688
interpret_cmd(cmdline);
689-
linenoiseHistoryAdd(cmdline); /* Add to the history. */
690-
linenoiseHistorySave(HISTORY_FILE); /* Save the history on disk. */
691-
linenoiseFree(cmdline);
689+
line_history_add(cmdline); /* Add to the history. */
690+
line_history_save(HISTORY_FILE); /* Save the history on disk. */
691+
line_free(cmdline);
692692
while (buf_stack && buf_stack->fd != STDIN_FILENO)
693693
cmd_select(0, NULL, NULL, NULL, NULL);
694694
has_infile = false;

console.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ bool finish_cmd();
6969
bool run_console(char *infile_name);
7070

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

7474
#endif /* LAB0_CONSOLE_H */

0 commit comments

Comments
 (0)