From: Bruce Momjian Date: Thu, 22 May 1997 18:55:40 +0000 (+0000) Subject: Fix backslash commands broken when \connect user added. X-Git-Tag: REL9_0_0~28814 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=65ff0feacf98c4b7096a3c5df4dd6efd4ffe5fa2;p=pg-rex%2Fsyncrep.git Fix backslash commands broken when \connect user added. --- diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index 4ff3d59cbd..6f62b57cce 100644 --- a/src/bin/psql/psql.c +++ b/src/bin/psql/psql.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.60 1997/05/21 03:12:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.61 1997/05/22 18:55:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1055,19 +1055,12 @@ HandleSlashCmds(PsqlSettings * settings, * assuming it's not a one-character command. If it's a one-character * command, this is meaningless. */ - char *optarg3; - /* - * Pointer inside the second string to the argument of the slash command - * assuming it's not a one-character command. If it's a one-character - * command, this is meaningless. - */ char *cmd; /* * String: value of the slash command, less the slash and with escape * sequences decoded. */ int blank_loc; - int blank_loc2; /* Offset within of first blank */ cmd = malloc(strlen(line)); /* unescaping better not make string grow. */ @@ -1089,19 +1082,10 @@ HandleSlashCmds(PsqlSettings * settings, optarg = NULL; blank_loc = strcspn(cmd, " \t"); - if (blank_loc == 0) { + if (blank_loc == 0) optarg2 = NULL; - optarg3 = NULL; - } else { + else optarg2 = cmd + blank_loc + strspn(cmd + blank_loc, " \t"); - blank_loc2 = strcspn(optarg2, " \t"); - if (blank_loc2 == 0 || *(optarg2 + blank_loc2) == '\0') - optarg3 = NULL; - else { - optarg3 = optarg2 + blank_loc2 + strspn(optarg2 + blank_loc2, " \t"); - *(optarg2 + blank_loc2) = '\0'; - } - } switch (cmd[0]) { case 'a': /* toggles to align fields on output */ @@ -1124,8 +1108,20 @@ HandleSlashCmds(PsqlSettings * settings, case 'c':{ if (strncmp(cmd, "copy ", strlen("copy ")) == 0) do_copy(optarg2, settings); - else if (strncmp(cmd, "connect ", strlen("connect ")) == 0) + else if (strncmp(cmd, "connect ", strlen("connect ")) == 0) { + char *optarg3; + int blank_loc2; + + blank_loc2 = strcspn(optarg2, " \t"); + if (blank_loc2 == 0 || *(optarg2 + blank_loc2) == '\0') + optarg3 = NULL; + else { + optarg3 = optarg2 + blank_loc2 + + strspn(optarg2 + blank_loc2, " \t"); + *(optarg2 + blank_loc2) = '\0'; + } do_connect(optarg2, optarg3, settings); + } else do_connect(optarg, optarg2, settings); } diff --git a/src/bin/psql/psqlHelp.h b/src/bin/psql/psqlHelp.h index 294c79b416..b41f5a0878 100644 --- a/src/bin/psql/psqlHelp.h +++ b/src/bin/psql/psqlHelp.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: psqlHelp.h,v 1.13 1997/05/17 06:16:34 thomas Exp $ + * $Id: psqlHelp.h,v 1.14 1997/05/22 18:55:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -175,6 +175,6 @@ static struct _helpStruct QL_HELP[] = { "update set =,...= [from ] [where ];"}, { "vacuum", "vacuum the database, i.e. cleans out deleted records, updates statistics", - "vacuum [verbose] [analyze]\n\tor\nvacuum [verbose] table [analyze [(attr1, ... attrN)] ];"}, + "vacuum [verbose] [analyze]\n\tor\nvacuum [verbose] [analyze] table [analyze [(attr1, ... attrN)] ];"}, { NULL, NULL, NULL} /* important to keep a NULL terminator here! */ };