|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.168 1999/02/03 21:17:44 momjian Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.169 1999/02/07 02:56:53 momjian Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -1753,10 +1753,10 @@ do_shell(const char *command)
|
1753 | 1753 | /*
|
1754 | 1754 | * HandleSlashCmds:
|
1755 | 1755 | *
|
1756 |
| - * Handles all the different commands that start with \ db_ptr is a pointer to |
1757 |
| - * the TgDb* structure line is the current input line prompt_ptr is a pointer |
1758 |
| - * to the prompt string, a pointer is used because the prompt can be used |
1759 |
| - * with a connection to a new database. |
| 1756 | + * Handles all the different commands that start with \ |
| 1757 | + *db_ptr is a pointer tothe TgDb* structure line is the current input |
| 1758 | + *line prompt_ptr is a pointerto the prompt string, a pointer is used |
| 1759 | + *because the prompt can be usedwith a connection to a new database. |
1760 | 1760 | * Returns a status:
|
1761 | 1761 | *0 - send currently constructed query to backend (i.e. we got a \g)
|
1762 | 1762 | *1 - skip processing of this line, continue building up query
|
@@ -2690,22 +2690,45 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
|
2690 | 2690 |
|
2691 | 2691 | if (!in_quote&&query_start[0]=='\\')
|
2692 | 2692 | {
|
2693 |
| -slashCmdStatus=HandleSlashCmds(pset, |
2694 |
| -query_start, |
2695 |
| -query); |
2696 |
| -if (slashCmdStatus==CMD_SKIP_LINE) |
| 2693 | +/* handle \p\g and other backslash combinations */ |
| 2694 | +while (query_start[0]!='\0') |
2697 | 2695 | {
|
2698 |
| -if (query[0]=='\0') |
2699 |
| -paren_level=0; |
2700 |
| -free(line); |
2701 |
| -continue; |
| 2696 | +charhold_char; |
| 2697 | + |
| 2698 | +#ifndefWIN32 |
| 2699 | +/* I believe \w \dos\system\x would cause a problem */ |
| 2700 | +/* do we have '\p\g' or '\p \g' ? */ |
| 2701 | +if (strlen(query_start)>2&& |
| 2702 | +query_start[2+strspn(query_start+2," \t")]=='\\') |
| 2703 | +{ |
| 2704 | +hold_char=query_start[2+strspn(query_start+2," \t")]; |
| 2705 | +query_start[2+strspn(query_start+2," \t")]='\0'; |
| 2706 | +} |
| 2707 | +else/* spread over #endif */ |
| 2708 | +#endif |
| 2709 | +hold_char='\0'; |
| 2710 | + |
| 2711 | +slashCmdStatus=HandleSlashCmds(pset, |
| 2712 | +query_start, |
| 2713 | +query); |
| 2714 | + |
| 2715 | +if (slashCmdStatus==CMD_SKIP_LINE&& !hold_char) |
| 2716 | +{ |
| 2717 | +if (query[0]=='\0') |
| 2718 | +paren_level=0; |
| 2719 | +break; |
| 2720 | +} |
| 2721 | +if (slashCmdStatus==CMD_TERMINATE) |
| 2722 | +break; |
| 2723 | + |
| 2724 | +query_start+=strlen(query_start); |
| 2725 | +if (hold_char) |
| 2726 | +query_start[0]=hold_char; |
2702 | 2727 | }
|
| 2728 | +free(line); |
| 2729 | +/* They did \q, leave the loop */ |
2703 | 2730 | if (slashCmdStatus==CMD_TERMINATE)
|
2704 |
| -{ |
2705 |
| -free(line); |
2706 | 2731 | break;
|
2707 |
| -} |
2708 |
| -free(line); |
2709 | 2732 | }
|
2710 | 2733 | elseif (strlen(query)+strlen(query_start)>MAX_QUERY_BUFFER)
|
2711 | 2734 | {
|
|