Commit 330c6c42 authored by Bruce Momjian's avatar Bruce Momjian

Open files in binary mode on Win32 so control-z isn't seen as EOF.

parent e5ca4bde
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.117 2004/06/18 06:14:04 tgl Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.118 2004/07/11 00:54:55 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
......@@ -1197,7 +1197,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
if (!error)
{
#endif
stream = fopen(fname, "r");
stream = fopen(fname, R_TEXTFILE);
if (!stream)
{
psql_error("%s: %s\n", fname, strerror(errno));
......@@ -1262,7 +1262,7 @@ process_file(char *filename)
if (!filename)
return false;
fd = fopen(filename, "r");
fd = fopen(filename, R_TEXTFILE);
if (!fd)
{
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.35 2004/04/19 17:42:58 momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.36 2004/07/11 00:54:55 momjian Exp $
*/
#ifndef COMMON_H
#define COMMON_H
......@@ -62,4 +62,16 @@ extern char parse_char(char **buf);
extern char *expand_tilde(char **filename);
/*
* WIN32 treats Control-Z as EOF in files opened in text mode.
* Therefore, we open files in binary mode on Win32 so we can read
* literal control-Z. The other affect is that we see CRLF, but
* that is OK because we can already handle those cleanly.
*/
#ifndef WIN32
#define R_TEXTFILE "r"
#else
#define R_TEXTFILE "rb"
#endif
#endif /* COMMON_H */
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.47 2004/05/07 00:24:58 tgl Exp $
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.48 2004/07/11 00:54:55 momjian Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
......@@ -516,7 +516,7 @@ do_copy(const char *args)
if (options->from)
{
if (options->file)
copystream = fopen(options->file, "r");
copystream = fopen(options->file, R_TEXTFILE);
else if (!options->psql_inout)
copystream = pset.cur_cmd_source;
else
......
......@@ -31,7 +31,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.3 2004/05/07 00:24:58 tgl Exp $
* $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.4 2004/07/11 00:54:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1284,7 +1284,7 @@ psql_scan_slash_option(PsqlScanState state,
char buf[512];
size_t result;
fd = popen(cmd, "r");
fd = popen(cmd, R_TEXTFILE);
if (!fd)
{
psql_error("%s: %s\n", cmd, strerror(errno));
......
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