[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/5] REPL: Use null_completion_function as the default
From: |
John Darrington |
Subject: |
[PATCH 2/5] REPL: Use null_completion_function as the default |
Date: |
Fri, 21 Feb 2020 17:36:32 +0100 |
---
ChangeLog | 7 +++++++
src/pk-editor.c | 8 +-------
src/pk-repl.c | 16 ++++++++++++++--
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4950997f..aa236add 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-02-16 John Darrington <address@hidden>
+
+ * src/pk-editor.c (null_complete_function): delete
+ * src/pk-repl.c (null_complete_function): add (move from above)
+ * src/pk-repl.c (poke_getc): Use null_complete_function as the
+ default completer.
+
2020-02-16 John Darrington <address@hidden>
* src/pk-def.c: Explicitly set completer member of struct pk_cmd
diff --git a/src/pk-editor.c b/src/pk-editor.c
index 7ad209d2..728d55e8 100644
--- a/src/pk-editor.c
+++ b/src/pk-editor.c
@@ -129,11 +129,5 @@ pk_cmd_editor (int argc, struct pk_cmd_arg argv[],
uint64_t uflags)
return 1;
}
-static char *
-null_completion_function (const char *x, int state)
-{
- return NULL;
-}
-
struct pk_cmd editor_cmd =
- {"editor", "", "", 0, NULL, pk_cmd_editor, ".editor",
null_completion_function};
+ {"editor", "", "", 0, NULL, pk_cmd_editor, ".editor", NULL};
diff --git a/src/pk-repl.c b/src/pk-repl.c
index 8439aac9..cc1d1b71 100644
--- a/src/pk-repl.c
+++ b/src/pk-repl.c
@@ -145,6 +145,13 @@ poke_completion_function (const char *x, int state)
return NULL;
}
+
+static char *
+null_completion_function (const char *x, int state)
+{
+ return NULL;
+}
+
/* Readline's getc callback.
Use this function to update the completer which
should be used.
@@ -160,8 +167,13 @@ poke_getc (FILE *stream)
if (rl_completion_entry_function == poke_completion_function)
{
struct pk_cmd *cmd = pk_cmd_find (tok);
- if (cmd && cmd->completer)
- rl_completion_entry_function = cmd->completer;
+ if (cmd)
+ {
+ if (cmd->completer)
+ rl_completion_entry_function = cmd->completer;
+ else
+ rl_completion_entry_function = null_completion_function;
+ }
}
free (line_to_point);
--
2.20.1