Commit a9f37f16 authored by Peter Eisentraut's avatar Peter Eisentraut

Fixed bug with repeated \e in psql (failed to clear buffers correctly)

parent 39f69bc3
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.25 2000/03/18 22:48:29 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.26 2000/03/27 21:11:37 petere Exp $
*/ */
#include "postgres.h" #include "postgres.h"
#include "command.h" #include "command.h"
...@@ -1442,21 +1442,16 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf) ...@@ -1442,21 +1442,16 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
{ {
/* read file back in */ /* read file back in */
char line[1024]; char line[1024];
size_t result;
resetPQExpBuffer(query_buf); resetPQExpBuffer(query_buf);
do while (fgets(line, 1024, stream))
{ appendPQExpBufferStr(query_buf, line);
result = fread(line, 1, 1024, stream);
if (ferror(stream)) if (ferror(stream))
{ {
psql_error("%s: %s\n", fname, strerror(errno)); psql_error("%s: %s\n", fname, strerror(errno));
error = true; error = true;
break; }
}
appendBinaryPQExpBuffer(query_buf, line, result);
} while (!feof(stream));
appendPQExpBufferChar(query_buf, '\0');
fclose(stream); fclose(stream);
} }
...@@ -1471,6 +1466,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf) ...@@ -1471,6 +1466,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
} }
} }
} }
return !error; return !error;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.26 2000/03/18 18:03:11 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.27 2000/03/27 21:11:37 petere Exp $
*/ */
#include "postgres.h" #include "postgres.h"
#include "mainloop.h" #include "mainloop.h"
...@@ -481,7 +481,7 @@ MainLoop(FILE *source) ...@@ -481,7 +481,7 @@ MainLoop(FILE *source)
/* Put the rest of the line in the query buffer. */ /* Put the rest of the line in the query buffer. */
if (line[query_start + strspn(line + query_start, " \t")] != '\0') if (line[query_start + strspn(line + query_start, " \t\n")] != '\0')
{ {
if (query_buf->len > 0) if (query_buf->len > 0)
appendPQExpBufferChar(query_buf, '\n'); appendPQExpBufferChar(query_buf, '\n');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment