diff options
author | Bruce Momjian <bruce@momjian.us> | 2003-03-20 06:43:35 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2003-03-20 06:43:35 +0000 |
commit | add932ee91b9ca78c1a0647487cd6d2a680c4f12 (patch) | |
tree | abb208bec97099a408ead6d6c5b0f0929c459a2d /src/bin/psql/command.c | |
parent | 1b3d4cefe8e025a40e3a795f311d4711178366e9 (diff) | |
download | postgresql-add932ee91b9ca78c1a0647487cd6d2a680c4f12.tar.gz postgresql-add932ee91b9ca78c1a0647487cd6d2a680c4f12.zip |
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
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r-- | src/bin/psql/command.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 9f393024b6a..57aaad06558 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -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; } |