return matches[list_index++];
}
-/*
- * Attempt to complete on the contents of TEXT. START and END bound the
- * region of rl_line_buffer that contains the word to complete. TEXT is
- * the word to complete. We can use the entire contents of rl_line_buffer
- * in case we want to do some simple parsing. Return the array of matches,
- * or NULL if there aren't any.
- */
-static char **i9e_completer(const char *text, int start, __a_unused int end)
-{
- struct i9e_client_info *ici = i9ep->ici;
-
- if (!ici->completers)
- return NULL;
- /* Complete on command names if this is the first word in the line. */
- if (start == 0)
- return rl_completion_matches(text, command_generator);
- return rl_completion_matches(text, completion_generator);
-}
-
/**
* Prepare writing to stdout.
*
goto again;
}
+/*
+ * Calls either command_generator() or completion_generator() via
+ * rl_completion_matches(). May set rl_attempted_completion_over to instruct
+ * readline to not perform its default completion even if no matches are
+ * returned.
+ */
+static char **attempt_completion(const char *text, int start, __a_unused int end)
+{
+ struct i9e_client_info *ici = i9ep->ici;
+
+ if (!ici->completers)
+ return NULL;
+ /* Complete on command names if this is the first word in the line. */
+ if (start == 0)
+ return rl_completion_matches(text, command_generator);
+ return rl_completion_matches(text, completion_generator);
+}
+
/**
* Register the i9e task and initialize readline.
*
rl_readline_name = "para_i9e";
rl_basic_word_break_characters = " ";
- rl_attempted_completion_function = i9e_completer;
+ rl_attempted_completion_function = attempt_completion;
i9ep->ici = ici;
i9ep->stderr_stream = fdopen(ici->fds[2], "w");
setvbuf(i9ep->stderr_stream, NULL, _IONBF, 0);