Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitffc9812

Browse files
committed
fixed another psql \e bug (handle newlines as whitespace)
repaired psql option scanning bug (special treatment to \g |pipe)fixed ipcclean makefilemade configure look for Perl to handle psql help build gracefully
1 parentade9505 commitffc9812

File tree

8 files changed

+456
-484
lines changed

8 files changed

+456
-484
lines changed

‎src/Makefile.global.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.69 2000/03/31 14:14:31 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.70 2000/04/14 23:43:41 petere Exp $
1111
#
1212
# NOTES
1313
# Essentially all Postgres make files include this file and use the
@@ -156,7 +156,7 @@ USE_TK= @USE_TK@
156156
WISH= @WISH@
157157

158158
USE_PERL= @USE_PERL@
159-
PERL=perl
159+
PERL=@PERL@
160160

161161
#
162162
# enable native odbc driver support

‎src/bin/ipcclean/Makefile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
#-------------------------------------------------------------------------
22
#
3-
# Makefile.inc--
4-
# Makefile for bin/initdb
3+
# Makefile for bin/ipcclean
54
#
65
# Copyright (c) 1994, Regents of the University of California
76
#
87
#
98
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/Makefile,v 1.9 1999/12/08 10:29:46 momjian Exp $
9+
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/Makefile,v 1.10 2000/04/14 23:43:43 petere Exp $
1110
#
1211
#-------------------------------------------------------------------------
1312

1413
SRCDIR= ../..
1514
include ../../Makefile.global
1615

17-
SEDSCRIPT=\
18-
-e "s^PG_OPT_IPCCLEANPATH_PARAM^$(IPCSDIR)^g"
19-
2016
all: ipcclean
2117

22-
ipcclean:
23-
sed$(SEDSCRIPT)<ipcclean.sh>ipcclean
18+
ipcclean: ipcclean.sh
19+
cp$<$@
2420

2521
install: ipcclean
26-
$(INSTALL)$(INSTL_EXE_OPTS)$+$(BINDIR)
22+
$(INSTALL)$(INSTL_EXE_OPTS)$^$(BINDIR)
2723

2824
clean:
2925
rm -f ipcclean

‎src/bin/psql/Makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.21 2000/03/08 01:58:22 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.22 2000/04/14 23:43:44 petere Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -65,6 +65,7 @@ sql_help.h: $(wildcard $(SRCDIR)/../doc/src/sgml/ref/*.sgml) create_help.pl
6565
$(PERL) create_help.pl sql_help.h
6666
else
6767
sql_help.h:
68+
@echo"*** Perl is needed to build psql help."
6869
endif
6970

7071
.PHONY: submake

‎src/bin/psql/command.c

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.28 2000/04/12 17:16:22 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.29 2000/04/14 23:43:44 petere Exp $
77
*/
88
#include"postgres.h"
99
#include"command.h"
@@ -51,7 +51,7 @@ static backslashResult exec_command(const char *cmd,
5151

5252
enumoption_type
5353
{
54-
OT_NORMAL,OT_SQLID
54+
OT_NORMAL,OT_SQLID,OT_FILEPIPE
5555
};
5656
staticchar*scan_option(char**string,enumoption_typetype,char*quote);
5757
staticchar*unescape(constunsignedchar*source,size_tlen);
@@ -105,7 +105,7 @@ HandleSlashCmds(const char *line,
105105
*
106106
* Also look for a backslash, so stuff like \p\g works.
107107
*/
108-
blank_loc=strcspn(my_line," \t\\");
108+
blank_loc=strcspn(my_line," \t\n\r\\");
109109

110110
if (my_line[blank_loc]=='\\')
111111
{
@@ -408,7 +408,7 @@ exec_command(const char *cmd,
408408
/* \g means send query */
409409
elseif (strcmp(cmd,"g")==0)
410410
{
411-
char*fname=scan_option(&string,OT_NORMAL,NULL);
411+
char*fname=scan_option(&string,OT_FILEPIPE,NULL);
412412

413413
if (!fname)
414414
pset.gfname=NULL;
@@ -421,7 +421,7 @@ exec_command(const char *cmd,
421421
/* help */
422422
elseif (strcmp(cmd,"h")==0||strcmp(cmd,"help")==0)
423423
{
424-
helpSQL(options_string ?&options_string[strspn(options_string," \t")] :NULL);
424+
helpSQL(options_string ?&options_string[strspn(options_string," \t\n\r")] :NULL);
425425
/* set pointer to end of line */
426426
if (string)
427427
string+=strlen(string);
@@ -518,7 +518,7 @@ exec_command(const char *cmd,
518518
/* \o -- set query output */
519519
elseif (strcmp(cmd,"o")==0||strcmp(cmd,"out")==0)
520520
{
521-
char*fname=scan_option(&string,OT_NORMAL,NULL);
521+
char*fname=scan_option(&string,OT_FILEPIPE,NULL);
522522

523523
success=setQFout(fname);
524524
free(fname);
@@ -676,7 +676,7 @@ exec_command(const char *cmd,
676676
}
677677
else
678678
{
679-
fname=scan_option(&string,OT_NORMAL,NULL);
679+
fname=scan_option(&string,OT_FILEPIPE,NULL);
680680

681681
if (!fname)
682682
{
@@ -806,7 +806,7 @@ scan_option(char **string, enum option_type type, char *quote)
806806

807807
options_string=*string;
808808
/* skip leading whitespace */
809-
pos+=strspn(options_string+pos," \t");
809+
pos+=strspn(options_string+pos," \t\n\r");
810810

811811
switch (options_string[pos])
812812
{
@@ -845,17 +845,11 @@ scan_option(char **string, enum option_type type, char *quote)
845845
exit(EXIT_FAILURE);
846846
}
847847

848-
if (type==OT_NORMAL)
849-
{
850-
strncpy(return_val,&options_string[pos],jj-pos+1);
851-
return_val[jj-pos+1]='\0';
852-
}
853-
854848
/*
855849
* If this is expected to be an SQL identifier like option
856850
* then we strip out the double quotes
857851
*/
858-
elseif (type==OT_SQLID)
852+
if (type==OT_SQLID)
859853
{
860854
unsignedintk,
861855
cc;
@@ -877,6 +871,12 @@ scan_option(char **string, enum option_type type, char *quote)
877871
return_val[cc]='\0';
878872
}
879873

874+
else
875+
{
876+
strncpy(return_val,&options_string[pos],jj-pos+1);
877+
return_val[jj-pos+1]='\0';
878+
}
879+
880880
*string=options_string+jj+1;
881881
if (quote)
882882
*quote='"';
@@ -1010,7 +1010,7 @@ scan_option(char **string, enum option_type type, char *quote)
10101010
constchar*value;
10111011
charsave_char;
10121012

1013-
token_end=strcspn(&options_string[pos+1]," \t");
1013+
token_end=strcspn(&options_string[pos+1]," \t\n\r");
10141014
save_char=options_string[pos+token_end+1];
10151015
options_string[pos+token_end+1]='\0';
10161016
value=GetVariable(pset.vars,options_string+pos+1);
@@ -1030,6 +1030,19 @@ scan_option(char **string, enum option_type type, char *quote)
10301030
returnNULL;
10311031
break;
10321032

1033+
/*
1034+
* | could be the beginning of a pipe
1035+
* if so, take rest of line as command
1036+
*/
1037+
case'|':
1038+
if (type==OT_FILEPIPE)
1039+
{
1040+
*string+=strlen(options_string+pos);
1041+
returnxstrdup(options_string+pos);
1042+
break;
1043+
}
1044+
/* fallthrough for other option types */
1045+
10331046
/*
10341047
* A normal word
10351048
*/
@@ -1038,7 +1051,7 @@ scan_option(char **string, enum option_type type, char *quote)
10381051
size_ttoken_end;
10391052
char*cp;
10401053

1041-
token_end=strcspn(&options_string[pos]," \t");
1054+
token_end=strcspn(&options_string[pos]," \t\n\r");
10421055
return_val=malloc(token_end+1);
10431056
if (!return_val)
10441057
{

‎src/bin/psql/copy.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.13 2000/04/12 17:16:22 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.14 2000/04/14 23:43:44 petere Exp $
77
*/
88
#include"postgres.h"
99
#include"copy.h"
@@ -82,7 +82,7 @@ parse_slash_copy(const char *args)
8282
exit(EXIT_FAILURE);
8383
}
8484

85-
token=strtokx(line," \t","\"",'\\',&quote,NULL,pset.encoding);
85+
token=strtokx(line," \t\n\r","\"",'\\',&quote,NULL,pset.encoding);
8686
if (!token)
8787
error= true;
8888
else
@@ -92,7 +92,7 @@ parse_slash_copy(const char *args)
9292
if (!quote&&strcasecmp(token,"binary")==0)
9393
{
9494
result->binary= true;
95-
token=strtokx(NULL," \t","\"",'\\',&quote,NULL,pset.encoding);
95+
token=strtokx(NULL," \t\n\r","\"",'\\',&quote,NULL,pset.encoding);
9696
if (!token)
9797
error= true;
9898
}
@@ -107,22 +107,22 @@ parse_slash_copy(const char *args)
107107

108108
if (!error)
109109
{
110-
token=strtokx(NULL," \t",NULL,'\\',NULL,NULL,pset.encoding);
110+
token=strtokx(NULL," \t\n\r",NULL,'\\',NULL,NULL,pset.encoding);
111111
if (!token)
112112
error= true;
113113
else
114114
{
115115
if (strcasecmp(token,"with")==0)
116116
{
117-
token=strtokx(NULL," \t",NULL,'\\',NULL,NULL,pset.encoding);
117+
token=strtokx(NULL," \t\n\r",NULL,'\\',NULL,NULL,pset.encoding);
118118
if (!token||strcasecmp(token,"oids")!=0)
119119
error= true;
120120
else
121121
result->oids= true;
122122

123123
if (!error)
124124
{
125-
token=strtokx(NULL," \t",NULL,'\\',NULL,NULL,pset.encoding);
125+
token=strtokx(NULL," \t\n\r",NULL,'\\',NULL,NULL,pset.encoding);
126126
if (!token)
127127
error= true;
128128
}
@@ -139,7 +139,7 @@ parse_slash_copy(const char *args)
139139

140140
if (!error)
141141
{
142-
token=strtokx(NULL," \t","'",'\\',&quote,NULL,pset.encoding);
142+
token=strtokx(NULL," \t\n\r","'",'\\',&quote,NULL,pset.encoding);
143143
if (!token)
144144
error= true;
145145
elseif (!quote&& (strcasecmp(token,"stdin")==0||strcasecmp(token,"stdout")==0))
@@ -150,21 +150,21 @@ parse_slash_copy(const char *args)
150150

151151
if (!error)
152152
{
153-
token=strtokx(NULL," \t",NULL,'\\',NULL,NULL,pset.encoding);
153+
token=strtokx(NULL," \t\n\r",NULL,'\\',NULL,NULL,pset.encoding);
154154
if (token)
155155
{
156156
if (strcasecmp(token,"using")==0)
157157
{
158-
token=strtokx(NULL," \t",NULL,'\\',NULL,NULL,pset.encoding);
158+
token=strtokx(NULL," \t\n\r",NULL,'\\',NULL,NULL,pset.encoding);
159159
if (!token||strcasecmp(token,"delimiters")!=0)
160160
error= true;
161161
else
162162
{
163-
token=strtokx(NULL," \t","'",'\\',NULL,NULL,pset.encoding);
163+
token=strtokx(NULL," \t\n\r","'",'\\',NULL,NULL,pset.encoding);
164164
if (token)
165165
{
166166
result->delim=xstrdup(token);
167-
token=strtokx(NULL," \t",NULL,'\\',NULL,NULL,pset.encoding);
167+
token=strtokx(NULL," \t\n\r",NULL,'\\',NULL,NULL,pset.encoding);
168168
}
169169
else
170170
error= true;
@@ -175,17 +175,17 @@ parse_slash_copy(const char *args)
175175
{
176176
if (strcasecmp(token,"with")==0)
177177
{
178-
token=strtokx(NULL," \t",NULL,'\\',NULL,NULL,pset.encoding);
178+
token=strtokx(NULL," \t\n\r",NULL,'\\',NULL,NULL,pset.encoding);
179179
if (!token||strcasecmp(token,"null")!=0)
180180
error= true;
181181
else
182182
{
183-
token=strtokx(NULL," \t",NULL,'\\',NULL,NULL,pset.encoding);
183+
token=strtokx(NULL," \t\n\r",NULL,'\\',NULL,NULL,pset.encoding);
184184
if (!token||strcasecmp(token,"as")!=0)
185185
error= true;
186186
else
187187
{
188-
token=strtokx(NULL," \t","'",'\\',NULL,NULL,pset.encoding);
188+
token=strtokx(NULL," \t\n\r","'",'\\',NULL,NULL,pset.encoding);
189189
if (token)
190190
result->null=xstrdup(token);
191191
}

‎src/bin/psql/mainloop.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.28 2000/04/12 17:16:22 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.29 2000/04/14 23:43:44 petere Exp $
77
*/
88
#include"postgres.h"
99
#include"mainloop.h"
@@ -397,7 +397,7 @@ MainLoop(FILE *source)
397397
{
398398
line[i]='\0';
399399
/* is there anything else on the line? */
400-
if (line[query_start+strspn(line+query_start," \t")]!='\0')
400+
if (line[query_start+strspn(line+query_start," \t\n\r")]!='\0')
401401
{
402402

403403
/*
@@ -441,7 +441,7 @@ MainLoop(FILE *source)
441441
line[i-prevlen]='\0';/* overwrites backslash */
442442

443443
/* is there anything else on the line for the command? */
444-
if (line[query_start+strspn(line+query_start," \t")]!='\0')
444+
if (line[query_start+strspn(line+query_start," \t\n\r")]!='\0')
445445
{
446446

447447
/*
@@ -499,7 +499,7 @@ MainLoop(FILE *source)
499499

500500

501501
/* Put the rest of the line in the query buffer. */
502-
if (line[query_start+strspn(line+query_start," \t\n")]!='\0')
502+
if (line[query_start+strspn(line+query_start," \t\n\r")]!='\0')
503503
{
504504
if (query_buf->len>0)
505505
appendPQExpBufferChar(query_buf,'\n');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp