free (words[i].name);
free (words);
}
+
+static int
+compare_words (const void *vp1, const void *vp2)
+{
+ const struct word *w1 = (const struct word *) vp1;
+ const struct word *w2 = (const struct word *) vp2;
+ return strcmp (w1->name, w2->name);
+}
#endif
char *
/* This inhibits ordinary (local filename) completion. */
rl_attempted_completion_over = 1;
+ /* Sort the words so the list is stable over multiple calls. */
+ qsort (words, nr_words, sizeof (struct word), compare_words);
+
/* Complete the string. */
while (index < nr_words) {
struct word *word;