|
3 | 3 | * |
4 | 4 | * Copyright 2000 by PostgreSQL Global Development Group |
5 | 5 | * |
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 $ |
7 | 7 | */ |
8 | 8 | #include"postgres_fe.h" |
9 | 9 | #include"mainloop.h" |
@@ -300,9 +300,13 @@ MainLoop(FILE *source) |
300 | 300 | /* in quote? */ |
301 | 301 | if (in_quote) |
302 | 302 | { |
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; |
306 | 310 | } |
307 | 311 |
|
308 | 312 | /* in extended comment? */ |
@@ -330,12 +334,10 @@ MainLoop(FILE *source) |
330 | 334 | ADVANCE_1; |
331 | 335 | } |
332 | 336 |
|
333 | | -/* start of quote */ |
334 | | -elseif (!was_bslash&& |
335 | | - (line[i]=='\''||line[i]=='"')) |
| 337 | +/* start of quote? */ |
| 338 | +elseif (line[i]=='\''||line[i]=='"') |
336 | 339 | in_quote=line[i]; |
337 | 340 |
|
338 | | - |
339 | 341 | /* single-line comment? truncate line */ |
340 | 342 | elseif (line[i]=='-'&&line[i+thislen]=='-') |
341 | 343 | { |
@@ -446,6 +448,7 @@ MainLoop(FILE *source) |
446 | 448 | /* remove the backslash */ |
447 | 449 | memmove(line+i-prevlen,line+i,len-i+1); |
448 | 450 | len--; |
| 451 | +i--; |
449 | 452 | } |
450 | 453 |
|
451 | 454 | /* backslash command */ |
|