|
3 | 3 | *
|
4 | 4 | * Copyright (c) 2000-2010, PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.157 2010/03/07 17:02:34 mha Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.158 2010/05/08 16:39:51 tgl Exp $ |
7 | 7 | */
|
8 | 8 | #include "postgres_fe.h"
|
9 | 9 |
|
@@ -284,6 +284,7 @@ slashUsage(unsigned short int pager)
|
284 | 284 | /*
|
285 | 285 | * helpSQL -- help with SQL commands
|
286 | 286 | *
|
| 287 | + * Note: we assume caller removed any trailing spaces in "topic". |
287 | 288 | */
|
288 | 289 | void
|
289 | 290 | helpSQL(const char *topic, unsigned short int pager)
|
@@ -352,17 +353,16 @@ helpSQL(const char *topic, unsigned short int pager)
|
352 | 353 | wordlen;
|
353 | 354 | int nl_count = 0;
|
354 | 355 |
|
355 |
| - /* User gets two chances: exact match, then the first word */ |
356 |
| - |
357 |
| - /* First pass : strip trailing spaces and semicolons */ |
| 356 | + /* |
| 357 | + * We first try exact match, then first + second words, then first |
| 358 | + * word only. |
| 359 | + */ |
358 | 360 | len = strlen(topic);
|
359 |
| - while (topic[len - 1] == ' ' || topic[len - 1] == ';') |
360 |
| - len--; |
361 | 361 |
|
362 |
| - for (x = 1; x <= 3; x++) /* Three chances to guess that word... */ |
| 362 | + for (x = 1; x <= 3; x++) |
363 | 363 | {
|
364 | 364 | if (x > 1) /* Nothing on first pass - try the opening
|
365 |
| - * words */ |
| 365 | + * word(s) */ |
366 | 366 | {
|
367 | 367 | wordlen = j = 1;
|
368 | 368 | while (topic[j] != ' ' && j++ < len)
|
@@ -423,7 +423,7 @@ helpSQL(const char *topic, unsigned short int pager)
|
423 | 423 | }
|
424 | 424 |
|
425 | 425 | if (!help_found)
|
426 |
| - fprintf(output, _("No help available for \"%-.*s\".\nTry \\h with no arguments to see available help.\n"), (int) len, topic); |
| 426 | + fprintf(output, _("No help available for \"%s\".\nTry \\h with no arguments to see available help.\n"), topic); |
427 | 427 |
|
428 | 428 | /* Only close if we used the pager */
|
429 | 429 | if (output != stdout)
|
|
0 commit comments