Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a9f37f1

Browse files
committed
Fixed bug with repeated \e in psql (failed to clear buffers correctly)
1 parent 39f69bc commit a9f37f1

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/bin/psql/command.c

+10-14
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.25 2000/03/18 22:48:29 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.26 2000/03/27 21:11:37 petere Exp $
77
*/
88
#include "postgres.h"
99
#include "command.h"
@@ -1442,21 +1442,16 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
14421442
{
14431443
/* read file back in */
14441444
char line[1024];
1445-
size_t result;
14461445

14471446
resetPQExpBuffer(query_buf);
1448-
do
1449-
{
1450-
result = fread(line, 1, 1024, stream);
1451-
if (ferror(stream))
1452-
{
1453-
psql_error("%s: %s\n", fname, strerror(errno));
1454-
error = true;
1455-
break;
1456-
}
1457-
appendBinaryPQExpBuffer(query_buf, line, result);
1458-
} while (!feof(stream));
1459-
appendPQExpBufferChar(query_buf, '\0');
1447+
while (fgets(line, 1024, stream))
1448+
appendPQExpBufferStr(query_buf, line);
1449+
1450+
if (ferror(stream))
1451+
{
1452+
psql_error("%s: %s\n", fname, strerror(errno));
1453+
error = true;
1454+
}
14601455

14611456
fclose(stream);
14621457
}
@@ -1471,6 +1466,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
14711466
}
14721467
}
14731468
}
1469+
14741470
return !error;
14751471
}
14761472

src/bin/psql/mainloop.c

+2-2
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.26 2000/03/18 18:03:11 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.27 2000/03/27 21:11:37 petere Exp $
77
*/
88
#include "postgres.h"
99
#include "mainloop.h"
@@ -481,7 +481,7 @@ MainLoop(FILE *source)
481481

482482

483483
/* Put the rest of the line in the query buffer. */
484-
if (line[query_start + strspn(line + query_start, " \t")] != '\0')
484+
if (line[query_start + strspn(line + query_start, " \t\n")] != '\0')
485485
{
486486
if (query_buf->len > 0)
487487
appendPQExpBufferChar(query_buf, '\n');

0 commit comments

Comments
 (0)