forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf00a4f0
committed
Automatically count the number of output lines in psql/help.c.
The hard-wired PageOutput arguments in usage() and sibling functionshave been a perennial maintenance gotcha, and there's no reason tothink we'll ever get any better about that. Let's get rid of thosemagic constants by constructing the output in a buffer where we cancount the newlines before calling PageOutput. (Perhaps this ismicroscopically slower; but none of these functions are performancecritical, and anyway we might well be buying back all the cost byavoiding having to pass most of the data through snprintf.c. I couldnot detect any speed difference in a desultory check.) This alsogets rid of the need to assume that platform-specific variations inthe output are insignificant.While at it, make the code shorter and more abstract by inventinghelper macros HELP0() and HELPN() to encapsulate the specificoutput actions being invoked.Discussion:https://postgr.es/m/365160.1654289490@sss.pgh.pa.us1 parent15b6d21 commitf00a4f0