fixed another psql \e bug (handle newlines as whitespace)

repaired psql option scanning bug (special treatment to \g |pipe)
fixed ipcclean makefile
made configure look for Perl to handle psql help build gracefully
This commit is contained in:
Peter Eisentraut 2000-04-14 23:43:44 +00:00
parent ade95052f8
commit ffc9812451
8 changed files with 456 additions and 484 deletions

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.69 2000/03/31 14:14:31 momjian Exp $
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.70 2000/04/14 23:43:41 petere Exp $
#
# NOTES
# Essentially all Postgres make files include this file and use the
@ -156,7 +156,7 @@ USE_TK= @USE_TK@
WISH= @WISH@
USE_PERL= @USE_PERL@
PERL= perl
PERL= @PERL@
#
# enable native odbc driver support

View File

@ -1,29 +1,25 @@
#-------------------------------------------------------------------------
#
# Makefile.inc--
# Makefile for bin/initdb
# Makefile for bin/ipcclean
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/Makefile,v 1.9 1999/12/08 10:29:46 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/Makefile,v 1.10 2000/04/14 23:43:43 petere Exp $
#
#-------------------------------------------------------------------------
SRCDIR= ../..
include ../../Makefile.global
SEDSCRIPT= \
-e "s^PG_OPT_IPCCLEANPATH_PARAM^$(IPCSDIR)^g"
all: ipcclean
ipcclean:
sed $(SEDSCRIPT) <ipcclean.sh >ipcclean
ipcclean: ipcclean.sh
cp $< $@
install: ipcclean
$(INSTALL) $(INSTL_EXE_OPTS) $+ $(BINDIR)
$(INSTALL) $(INSTL_EXE_OPTS) $^ $(BINDIR)
clean:
rm -f ipcclean

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.21 2000/03/08 01:58:22 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.22 2000/04/14 23:43:44 petere Exp $
#
#-------------------------------------------------------------------------
@ -65,6 +65,7 @@ sql_help.h: $(wildcard $(SRCDIR)/../doc/src/sgml/ref/*.sgml) create_help.pl
$(PERL) create_help.pl sql_help.h
else
sql_help.h:
@echo "*** Perl is needed to build psql help."
endif
.PHONY: submake

View File

@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.28 2000/04/12 17:16:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.29 2000/04/14 23:43:44 petere Exp $
*/
#include "postgres.h"
#include "command.h"
@ -51,7 +51,7 @@ static backslashResult exec_command(const char *cmd,
enum option_type
{
OT_NORMAL, OT_SQLID
OT_NORMAL, OT_SQLID, OT_FILEPIPE
};
static char *scan_option(char **string, enum option_type type, char *quote);
static char *unescape(const unsigned char *source, size_t len);
@ -105,7 +105,7 @@ HandleSlashCmds(const char *line,
*
* Also look for a backslash, so stuff like \p\g works.
*/
blank_loc = strcspn(my_line, " \t\\");
blank_loc = strcspn(my_line, " \t\n\r\\");
if (my_line[blank_loc] == '\\')
{
@ -408,7 +408,7 @@ exec_command(const char *cmd,
/* \g means send query */
else if (strcmp(cmd, "g") == 0)
{
char *fname = scan_option(&string, OT_NORMAL, NULL);
char *fname = scan_option(&string, OT_FILEPIPE, NULL);
if (!fname)
pset.gfname = NULL;
@ -421,7 +421,7 @@ exec_command(const char *cmd,
/* help */
else if (strcmp(cmd, "h") == 0 || strcmp(cmd, "help") == 0)
{
helpSQL(options_string ? &options_string[strspn(options_string, " \t")] : NULL);
helpSQL(options_string ? &options_string[strspn(options_string, " \t\n\r")] : NULL);
/* set pointer to end of line */
if (string)
string += strlen(string);
@ -518,7 +518,7 @@ exec_command(const char *cmd,
/* \o -- set query output */
else if (strcmp(cmd, "o") == 0 || strcmp(cmd, "out") == 0)
{
char *fname = scan_option(&string, OT_NORMAL, NULL);
char *fname = scan_option(&string, OT_FILEPIPE, NULL);
success = setQFout(fname);
free(fname);
@ -676,7 +676,7 @@ exec_command(const char *cmd,
}
else
{
fname = scan_option(&string, OT_NORMAL, NULL);
fname = scan_option(&string, OT_FILEPIPE, NULL);
if (!fname)
{
@ -806,7 +806,7 @@ scan_option(char **string, enum option_type type, char *quote)
options_string = *string;
/* skip leading whitespace */
pos += strspn(options_string + pos, " \t");
pos += strspn(options_string + pos, " \t\n\r");
switch (options_string[pos])
{
@ -845,17 +845,11 @@ scan_option(char **string, enum option_type type, char *quote)
exit(EXIT_FAILURE);
}
if (type == OT_NORMAL)
{
strncpy(return_val, &options_string[pos], jj - pos + 1);
return_val[jj - pos + 1] = '\0';
}
/*
* If this is expected to be an SQL identifier like option
* then we strip out the double quotes
*/
else if (type == OT_SQLID)
if (type == OT_SQLID)
{
unsigned int k,
cc;
@ -877,6 +871,12 @@ scan_option(char **string, enum option_type type, char *quote)
return_val[cc] = '\0';
}
else
{
strncpy(return_val, &options_string[pos], jj - pos + 1);
return_val[jj - pos + 1] = '\0';
}
*string = options_string + jj + 1;
if (quote)
*quote = '"';
@ -1010,7 +1010,7 @@ scan_option(char **string, enum option_type type, char *quote)
const char *value;
char save_char;
token_end = strcspn(&options_string[pos + 1], " \t");
token_end = strcspn(&options_string[pos + 1], " \t\n\r");
save_char = options_string[pos + token_end + 1];
options_string[pos + token_end + 1] = '\0';
value = GetVariable(pset.vars, options_string + pos + 1);
@ -1030,6 +1030,19 @@ scan_option(char **string, enum option_type type, char *quote)
return NULL;
break;
/*
* | could be the beginning of a pipe
* if so, take rest of line as command
*/
case '|':
if (type == OT_FILEPIPE)
{
*string += strlen(options_string + pos);
return xstrdup(options_string + pos);
break;
}
/* fallthrough for other option types */
/*
* A normal word
*/
@ -1038,7 +1051,7 @@ scan_option(char **string, enum option_type type, char *quote)
size_t token_end;
char *cp;
token_end = strcspn(&options_string[pos], " \t");
token_end = strcspn(&options_string[pos], " \t\n\r");
return_val = malloc(token_end + 1);
if (!return_val)
{

View File

@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.13 2000/04/12 17:16:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.14 2000/04/14 23:43:44 petere Exp $
*/
#include "postgres.h"
#include "copy.h"
@ -82,7 +82,7 @@ parse_slash_copy(const char *args)
exit(EXIT_FAILURE);
}
token = strtokx(line, " \t", "\"", '\\', &quote, NULL, pset.encoding);
token = strtokx(line, " \t\n\r", "\"", '\\', &quote, NULL, pset.encoding);
if (!token)
error = true;
else
@ -92,7 +92,7 @@ parse_slash_copy(const char *args)
if (!quote && strcasecmp(token, "binary") == 0)
{
result->binary = true;
token = strtokx(NULL, " \t", "\"", '\\', &quote, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", "\"", '\\', &quote, NULL, pset.encoding);
if (!token)
error = true;
}
@ -107,14 +107,14 @@ parse_slash_copy(const char *args)
if (!error)
{
token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", NULL, '\\', NULL, NULL, pset.encoding);
if (!token)
error = true;
else
{
if (strcasecmp(token, "with") == 0)
{
token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", NULL, '\\', NULL, NULL, pset.encoding);
if (!token || strcasecmp(token, "oids") != 0)
error = true;
else
@ -122,7 +122,7 @@ parse_slash_copy(const char *args)
if (!error)
{
token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", NULL, '\\', NULL, NULL, pset.encoding);
if (!token)
error = true;
}
@ -139,7 +139,7 @@ parse_slash_copy(const char *args)
if (!error)
{
token = strtokx(NULL, " \t", "'", '\\', &quote, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", "'", '\\', &quote, NULL, pset.encoding);
if (!token)
error = true;
else if (!quote && (strcasecmp(token, "stdin") == 0 || strcasecmp(token, "stdout") == 0))
@ -150,21 +150,21 @@ parse_slash_copy(const char *args)
if (!error)
{
token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", NULL, '\\', NULL, NULL, pset.encoding);
if (token)
{
if (strcasecmp(token, "using") == 0)
{
token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", NULL, '\\', NULL, NULL, pset.encoding);
if (!token || strcasecmp(token, "delimiters") != 0)
error = true;
else
{
token = strtokx(NULL, " \t", "'", '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", "'", '\\', NULL, NULL, pset.encoding);
if (token)
{
result->delim = xstrdup(token);
token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", NULL, '\\', NULL, NULL, pset.encoding);
}
else
error = true;
@ -175,17 +175,17 @@ parse_slash_copy(const char *args)
{
if (strcasecmp(token, "with") == 0)
{
token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", NULL, '\\', NULL, NULL, pset.encoding);
if (!token || strcasecmp(token, "null") != 0)
error = true;
else
{
token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", NULL, '\\', NULL, NULL, pset.encoding);
if (!token || strcasecmp(token, "as") != 0)
error = true;
else
{
token = strtokx(NULL, " \t", "'", '\\', NULL, NULL, pset.encoding);
token = strtokx(NULL, " \t\n\r", "'", '\\', NULL, NULL, pset.encoding);
if (token)
result->null = xstrdup(token);
}

View File

@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.28 2000/04/12 17:16:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.29 2000/04/14 23:43:44 petere Exp $
*/
#include "postgres.h"
#include "mainloop.h"
@ -397,7 +397,7 @@ MainLoop(FILE *source)
{
line[i] = '\0';
/* is there anything else on the line? */
if (line[query_start + strspn(line + query_start, " \t")] != '\0')
if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
{
/*
@ -441,7 +441,7 @@ MainLoop(FILE *source)
line[i - prevlen] = '\0'; /* overwrites backslash */
/* is there anything else on the line for the command? */
if (line[query_start + strspn(line + query_start, " \t")] != '\0')
if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
{
/*
@ -499,7 +499,7 @@ MainLoop(FILE *source)
/* Put the rest of the line in the query buffer. */
if (line[query_start + strspn(line + query_start, " \t\n")] != '\0')
if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
{
if (query_buf->len > 0)
appendPQExpBufferChar(query_buf, '\n');

833
src/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -594,10 +594,9 @@ AC_PATH_PROG(tar, tar)
AC_PATH_PROG(split, split)
AC_PATH_PROG(etags, etags)
AC_PATH_PROG(xargs, xargs)
AC_PATH_PROG(ipcs, ipcs)
AC_PATH_PROG(ipcrm, ipcrm)
AC_PATH_PROGS(TR, trbsd tr, NOT_FOUND)
AC_PATH_PROGS(GZCAT, gzcat zcat, gzcat)
AC_CHECK_PROGS(PERL, perl,)
dnl Check tr flags to convert from lower to upper case
TRSTRINGS="`echo ABCdef | $TR '[[a-z]]' '[[A-Z]]' 2>/dev/null | grep ABCDEF`"