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

Commitf94e5bd

Browse files
committed
psql thought that backslash is an escape character inside double quotes.
It isn't.
1 parent5bb46e7 commitf94e5bd

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

‎src/bin/psql/mainloop.c

Lines changed: 11 additions & 8 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.50 2002/09/04 20:31:36 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.51 2002/10/12 23:09:34 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"mainloop.h"
@@ -300,9 +300,13 @@ MainLoop(FILE *source)
300300
/* in quote? */
301301
if (in_quote)
302302
{
303-
/* end of quote */
304-
if (line[i]==in_quote&&bslash_count %2==0)
305-
in_quote='\0';
303+
/*
304+
* end of quote if matching non-backslashed character.
305+
* backslashes don't count for double quotes, though.
306+
*/
307+
if (line[i]==in_quote&&
308+
(bslash_count %2==0||in_quote=='"'))
309+
in_quote=0;
306310
}
307311

308312
/* in extended comment? */
@@ -330,12 +334,10 @@ MainLoop(FILE *source)
330334
ADVANCE_1;
331335
}
332336

333-
/* start of quote */
334-
elseif (!was_bslash&&
335-
(line[i]=='\''||line[i]=='"'))
337+
/* start of quote? */
338+
elseif (line[i]=='\''||line[i]=='"')
336339
in_quote=line[i];
337340

338-
339341
/* single-line comment? truncate line */
340342
elseif (line[i]=='-'&&line[i+thislen]=='-')
341343
{
@@ -446,6 +448,7 @@ MainLoop(FILE *source)
446448
/* remove the backslash */
447449
memmove(line+i-prevlen,line+i,len-i+1);
448450
len--;
451+
i--;
449452
}
450453

451454
/* backslash command */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp