postgresql/src/bin/psql
Tom Lane d37b816dc9 Adopt a more compact, less error-prone notation for tab completion code.
Replace tests like

    else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
             pg_strcasecmp(prev3_wd, "TRIGGER") == 0 &&
             (pg_strcasecmp(prev_wd, "BEFORE") == 0 ||
              pg_strcasecmp(prev_wd, "AFTER") == 0))

with new notation like this:

    else if (TailMatches4("CREATE", "TRIGGER", MatchAny, "BEFORE|AFTER"))

In addition, provide some macros COMPLETE_WITH_LISTn() to reduce the amount
of clutter needed to specify a small number of predetermined completion
alternatives.

This makes the code substantially more compact: tab-complete.c gets over a
thousand lines shorter in this patch, despite the addition of a couple of
hundred lines of infrastructure for the new notations.  The new way of
specifying match rules seems a whole lot more readable and less
error-prone, too.

There's a lot more that could be done now to make matching faster and more
reliable; for example I suspect that most of the TailMatches() rules should
now be Matches() rules.  That would allow them to be skipped after a single
integer comparison if there aren't the right number of words on the line,
and it would reduce the risk of unintended matches.  But for now, (mostly)
refrain from reworking any match rules in favor of just converting what
we've got into the new notation.

Thomas Munro, reviewed by Michael Paquier, some adjustments by me
2015-12-19 16:03:14 -05:00
..
po Translation updates 2015-06-28 23:56:55 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
Makefile Update copyright for 2015 2015-01-06 11:43:47 -05:00
command.c psql: Support multiple -c and -f options, and allow mixing them. 2015-12-08 14:04:08 -05:00
command.h psql: Support multiple -c and -f options, and allow mixing them. 2015-12-08 14:04:08 -05:00
common.c Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
common.h Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
copy.c Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
copy.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
create_help.pl Update copyright for 2015 2015-01-06 11:43:47 -05:00
describe.c Fix behavior of printTable() and friends with externally-invoked pager. 2015-12-02 18:20:41 -05:00
describe.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
help.c Review program help output for wording and formatting 2015-09-16 00:59:28 -04:00
help.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
input.c Fix improper initialization order for readline. 2015-12-17 16:55:23 -05:00
input.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
large_obj.c Fix behavior of printTable() and friends with externally-invoked pager. 2015-12-02 18:20:41 -05:00
large_obj.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
mainloop.c Fix documentation of psql's ECHO all mode. 2015-01-31 18:35:13 -05:00
mainloop.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
mbprint.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
mbprint.h Fix indentation of \d footers for non-ASCII cases. 2012-03-07 19:25:59 -05:00
nls.mk Add missing source files to nls.mk 2014-07-15 10:10:42 -04:00
print.c Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
print.h Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
prompt.c Add psql PROMPT variable showing the pid of the connected to backend. 2015-07-07 13:40:44 +02:00
prompt.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
psqlrc.sample Improve FILES section of psql reference page. 2014-01-14 19:27:57 -05:00
psqlscan.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
psqlscan.l Remove a couple other vestigial yylex() declarations. 2015-03-29 13:12:28 -04:00
settings.h Rearrange the handling of error context reports. 2015-09-05 11:58:33 -04:00
startup.c Code and docs review for multiple -c and -f options in psql. 2015-12-13 14:52:07 -05:00
stringutils.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
stringutils.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
tab-complete.c Adopt a more compact, less error-prone notation for tab completion code. 2015-12-19 16:03:14 -05:00
tab-complete.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
variables.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
variables.h Update copyright for 2015 2015-01-06 11:43:47 -05:00