static backslashResult exec_command(const char *cmd,
const char *options_string,
const char **continue_parse,
- PQExpBuffer query_buf);
+ PQExpBuffer query_buf,
+ volatile int *paren_level);
/* different ways for scan_option to handle parameter words */
enum option_type
backslashResult
HandleSlashCmds(const char *line,
PQExpBuffer query_buf,
- const char **end_of_cmd)
+ const char **end_of_cmd,
+ volatile int *paren_level)
{
backslashResult status = CMD_SKIP_LINE;
char *my_line;
my_line[blank_loc] = '\0';
}
- status = exec_command(my_line, options_string, &continue_parse, query_buf);
+ status = exec_command(my_line, options_string, &continue_parse, query_buf, paren_level);
if (status == CMD_UNKNOWN)
{
new_cmd[1] = '\0';
/* use line for options, because my_line was clobbered above */
- status = exec_command(new_cmd, line + 1, &continue_parse, query_buf);
+ status = exec_command(new_cmd, line + 1, &continue_parse, query_buf, paren_level);
/*
* continue_parse must be relative to my_line for calculation
exec_command(const char *cmd,
const char *options_string,
const char **continue_parse,
- PQExpBuffer query_buf)
+ PQExpBuffer query_buf,
+ volatile int *paren_level)
{
bool success = true; /* indicate here if the command ran ok or
* failed */
else if (strcmp(cmd, "r") == 0 || strcmp(cmd, "reset") == 0)
{
resetPQExpBuffer(query_buf);
+ if (paren_level)
+ *paren_level = 0;
if (!quiet)
puts(gettext("Query buffer reset (cleared)."));
}
if ((value = GetVariable(pset.vars, "ECHO")) && strcmp(value, "all") == 0)
puts(options.action_string);
- successResult = HandleSlashCmds(options.action_string, NULL, NULL) != CMD_ERROR
+ successResult = HandleSlashCmds(options.action_string, NULL, NULL, NULL) != CMD_ERROR
? EXIT_SUCCESS : EXIT_FAILURE;
}