1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

I'm continuing to work on cleaning up code in psql. As things appear

now, my changes seem to work.  Some possible minor bugs got squished
on the way but I can't be sure without more feedback from people who
really put the code to the test.

The new patch mostly simplifies variable handling and reduces code
duplication.  Changes in the command parser eliminate some redundant
variables (boolean state + depth counter), replaces some
"else if" constructs with switches, and so on.  It is meant to be
applied together with my previous patch, although I hope they don't
conflict; I went back to the CVS version for this one.

One more thing I thought should perhaps be changed: an IGNOREEOF
value of n will ignore only n-1 EOFs.  I didn't want to touch this
for fear of breaking existing applications, but it does seem a tad
illogical.

Jeroen T. Vermeulen
This commit is contained in:
Bruce Momjian
2003-03-20 06:43:35 +00:00
parent 1b3d4cefe8
commit add932ee91
10 changed files with 235 additions and 203 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.93 2003/03/19 22:49:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.94 2003/03/20 06:43:35 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@ -669,15 +669,7 @@ exec_command(const char *cmd,
if (!opt0)
{
/* list all variables */
/*
* XXX This is in utter violation of the GetVariable
* abstraction, but I have not bothered to do it better.
*/
struct _variable *ptr;
for (ptr = pset.vars; ptr->next; ptr = ptr->next)
fprintf(stdout, "%s = '%s'\n", ptr->next->name, ptr->next->value);
PrintVariables(pset.vars);
success = true;
}
else
@ -1073,9 +1065,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
save_char = options_string[pos + token_end + 1];
options_string[pos + token_end + 1] = '\0';
value = GetVariable(pset.vars, options_string + pos + 1);
if (!value)
value = "";
return_val = xstrdup(value);
return_val = xstrdup(value ? value : "");
options_string[pos + token_end + 1] = save_char;
*string = &options_string[pos + token_end + 1];
/* XXX should we set *quote to ':' here? */
@ -1287,15 +1277,9 @@ unescape(const unsigned char *source, size_t len)
case '7':
case '8':
case '9':
{
long int l;
char *end;
l = strtol(p, &end, 0);
c = (char) l;
p = end - 1;
c = parse_char((char **)&p);
break;
}
default:
c = *p;
}