Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd235d9b

Browse files
committed
Reset parenthesis level counter upon \r.
1 parent2442e79 commitd235d9b

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

‎src/bin/psql/command.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.70 2002/03/19 02:32:21 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.71 2002/03/27 19:16:13 petere Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -52,7 +52,8 @@
5252
staticbackslashResultexec_command(constchar*cmd,
5353
constchar*options_string,
5454
constchar**continue_parse,
55-
PQExpBufferquery_buf);
55+
PQExpBufferquery_buf,
56+
volatileint*paren_level);
5657

5758
/* different ways for scan_option to handle parameter words */
5859
enumoption_type
@@ -94,7 +95,8 @@ static bool do_shell(const char *command);
9495
backslashResult
9596
HandleSlashCmds(constchar*line,
9697
PQExpBufferquery_buf,
97-
constchar**end_of_cmd)
98+
constchar**end_of_cmd,
99+
volatileint*paren_level)
98100
{
99101
backslashResultstatus=CMD_SKIP_LINE;
100102
char*my_line;
@@ -132,7 +134,7 @@ HandleSlashCmds(const char *line,
132134
my_line[blank_loc]='\0';
133135
}
134136

135-
status=exec_command(my_line,options_string,&continue_parse,query_buf);
137+
status=exec_command(my_line,options_string,&continue_parse,query_buf,paren_level);
136138

137139
if (status==CMD_UNKNOWN)
138140
{
@@ -147,7 +149,7 @@ HandleSlashCmds(const char *line,
147149
new_cmd[1]='\0';
148150

149151
/* use line for options, because my_line was clobbered above */
150-
status=exec_command(new_cmd,line+1,&continue_parse,query_buf);
152+
status=exec_command(new_cmd,line+1,&continue_parse,query_buf,paren_level);
151153

152154
/*
153155
* continue_parse must be relative to my_line for calculation
@@ -192,7 +194,8 @@ static backslashResult
192194
exec_command(constchar*cmd,
193195
constchar*options_string,
194196
constchar**continue_parse,
195-
PQExpBufferquery_buf)
197+
PQExpBufferquery_buf,
198+
volatileint*paren_level)
196199
{
197200
boolsuccess= true;/* indicate here if the command ran ok or
198201
* failed */
@@ -636,6 +639,8 @@ exec_command(const char *cmd,
636639
elseif (strcmp(cmd,"r")==0||strcmp(cmd,"reset")==0)
637640
{
638641
resetPQExpBuffer(query_buf);
642+
if (paren_level)
643+
*paren_level=0;
639644
if (!quiet)
640645
puts(gettext("Query buffer reset (cleared)."));
641646
}

‎src/bin/psql/command.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.13 2001/11/05 17:46:30 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.14 2002/03/27 19:16:13 petere Exp $
77
*/
88
#ifndefCOMMAND_H
99
#defineCOMMAND_H
@@ -28,7 +28,8 @@ typedef enum _backslashResult
2828

2929
backslashResultHandleSlashCmds(constchar*line,
3030
PQExpBufferquery_buf,
31-
constchar**end_of_cmd);
31+
constchar**end_of_cmd,
32+
volatileint*paren_level);
3233

3334
int
3435
process_file(char*filename);

‎src/bin/psql/mainloop.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.46 2002/02/18 05:57:41 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.47 2002/03/27 19:16:13 petere Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"mainloop.h"
@@ -465,7 +465,8 @@ MainLoop(FILE *source)
465465
/* handle backslash command */
466466
slashCmdStatus=HandleSlashCmds(&line[i],
467467
query_buf->len>0 ?query_buf :previous_buf,
468-
&end_of_cmd);
468+
&end_of_cmd,
469+
&paren_level);
469470

470471
success=slashCmdStatus!=CMD_ERROR;
471472

‎src/bin/psql/startup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.54 2001/11/05 17:46:31 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.55 2002/03/27 19:16:13 petere Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -256,7 +256,7 @@ main(int argc, char *argv[])
256256

257257
if ((value=GetVariable(pset.vars,"ECHO"))&&strcmp(value,"all")==0)
258258
puts(options.action_string);
259-
successResult=HandleSlashCmds(options.action_string,NULL,NULL)!=CMD_ERROR
259+
successResult=HandleSlashCmds(options.action_string,NULL,NULL,NULL)!=CMD_ERROR
260260
?EXIT_SUCCESS :EXIT_FAILURE;
261261
}
262262

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp