#include "settings.h"
#include "stringutils.h"
-#ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
-#define filename_completion_function rl_filename_completion_function
-#else
-/* missing in some header files */
-extern char *filename_completion_function();
+/*
+ * Ancient versions of libedit provide filename_completion_function()
+ * instead of rl_filename_completion_function(). Likewise for
+ * [rl_]completion_matches().
+ */
+#ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION
+#define rl_filename_completion_function filename_completion_function
#endif
-#ifdef HAVE_RL_COMPLETION_MATCHES
-#define completion_matches rl_completion_matches
+#ifndef HAVE_RL_COMPLETION_MATCHES
+#define rl_completion_matches completion_matches
#endif
/* word break characters */
#define COMPLETE_WITH_QUERY(query) \
do { \
completion_charp = query; \
- matches = completion_matches(text, complete_from_query); \
+ matches = rl_completion_matches(text, complete_from_query); \
} while (0)
#define COMPLETE_WITH_VERSIONED_QUERY(query) \
do { \
completion_vquery = query; \
- matches = completion_matches(text, complete_from_versioned_query); \
+ matches = rl_completion_matches(text, complete_from_versioned_query); \
} while (0)
#define COMPLETE_WITH_SCHEMA_QUERY(query, addon) \
do { \
completion_squery = &(query); \
completion_charp = addon; \
- matches = completion_matches(text, complete_from_schema_query); \
+ matches = rl_completion_matches(text, complete_from_schema_query); \
} while (0)
#define COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(query, addon) \
do { \
completion_squery = query; \
completion_vquery = addon; \
- matches = completion_matches(text, complete_from_versioned_schema_query); \
+ matches = rl_completion_matches(text, complete_from_versioned_schema_query); \
} while (0)
/*
do { \
completion_case_sensitive = (cs); \
completion_charp = (con); \
- matches = completion_matches(text, complete_from_const); \
+ matches = rl_completion_matches(text, complete_from_const); \
} while (0)
#define COMPLETE_WITH_LIST_INT(cs, list) \
do { \
completion_case_sensitive = (cs); \
completion_charpp = (list); \
- matches = completion_matches(text, complete_from_list); \
+ matches = rl_completion_matches(text, complete_from_list); \
} while (0)
#define COMPLETE_WITH_LIST(list) COMPLETE_WITH_LIST_INT(false, list)
completion_info_charp = _completion_table; \
completion_info_charp2 = _completion_schema; \
} \
- matches = completion_matches(text, complete_from_query); \
+ matches = rl_completion_matches(text, complete_from_query); \
} while (0)
#define COMPLETE_WITH_ENUM_VALUE(type) \
completion_info_charp = _completion_type; \
completion_info_charp2 = _completion_schema; \
} \
- matches = completion_matches(text, complete_from_query); \
+ matches = rl_completion_matches(text, complete_from_query); \
} while (0)
#define COMPLETE_WITH_FUNCTION_ARG(function) \
completion_info_charp = _completion_function; \
completion_info_charp2 = _completion_schema; \
} \
- matches = completion_matches(text, complete_from_query); \
+ matches = rl_completion_matches(text, complete_from_query); \
} while (0)
/*
* According to readline spec this gets passed the text entered so far and its
* start and end positions in the readline buffer. The return value is some
* partially obscure list format that can be generated by readline's
- * completion_matches() function, so we don't have to worry about it.
+ * rl_completion_matches() function, so we don't have to worry about it.
*/
static char **
psql_completion(const char *text, int start, int end)
/* CREATE */
/* complete with something you can create */
else if (TailMatches("CREATE"))
- matches = completion_matches(text, create_command_generator);
+ matches = rl_completion_matches(text, create_command_generator);
/* complete with something you can create or replace */
else if (TailMatches("CREATE", "OR", "REPLACE"))
/* DROP, but not DROP embedded in other commands */
/* complete with something you can drop */
else if (Matches("DROP"))
- matches = completion_matches(text, drop_command_generator);
+ matches = rl_completion_matches(text, drop_command_generator);
/* ALTER */
/* ALTER something */
else if (Matches("ALTER"))
- matches = completion_matches(text, alter_command_generator);
+ matches = rl_completion_matches(text, alter_command_generator);
/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx */
else if (TailMatches("ALL", "IN", "TABLESPACE", MatchAny))
COMPLETE_WITH("SET TABLESPACE", "OWNED BY");
Matches("COPY", "BINARY", MatchAny, "FROM|TO"))
{
completion_charp = "";
- matches = completion_matches(text, complete_from_files);
+ matches = rl_completion_matches(text, complete_from_files);
}
/* Handle COPY [BINARY] <sth> FROM|TO filename */
else if (Matches("CREATE", "RULE", MatchAny, "AS") ||
Matches("CREATE", "OR", "REPLACE", "RULE", MatchAny, "AS"))
COMPLETE_WITH("ON");
- /* Complete "CREATE [ OR REPLACE ] RULE <sth> AS ON" with SELECT|UPDATE|INSERT|DELETE */
+
+ /*
+ * Complete "CREATE [ OR REPLACE ] RULE <sth> AS ON" with
+ * SELECT|UPDATE|INSERT|DELETE
+ */
else if (Matches("CREATE", "RULE", MatchAny, "AS", "ON") ||
Matches("CREATE", "OR", "REPLACE", "RULE", MatchAny, "AS", "ON"))
COMPLETE_WITH("SELECT", "UPDATE", "INSERT", "DELETE");
else if (TailMatchesCS("\\h|\\help", MatchAny))
{
if (TailMatches("DROP"))
- matches = completion_matches(text, drop_command_generator);
+ matches = rl_completion_matches(text, drop_command_generator);
else if (TailMatches("ALTER"))
- matches = completion_matches(text, alter_command_generator);
+ matches = rl_completion_matches(text, alter_command_generator);
/*
* CREATE is recognized by tail match elsewhere, so doesn't need to be
"\\s|\\w|\\write|\\lo_import"))
{
completion_charp = "\\";
- matches = completion_matches(text, complete_from_files);
+ matches = rl_completion_matches(text, complete_from_files);
}
/*
}
}
- unquoted_match = filename_completion_function(unquoted_text, state);
+ unquoted_match = rl_filename_completion_function(unquoted_text, state);
if (unquoted_match)
{
/*