File tree Expand file tree Collapse file tree 4 files changed +20
-8
lines changed
Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 33 *
44 * Copyright (c) 2000-2003, PostgreSQL Global Development Group
55 *
6- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.117 2004/06/18 06:14:04 tgl Exp $
6+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.118 2004/07/11 00:54:55 momjian Exp $
77 */
88#include "postgres_fe.h"
99#include "command.h"
@@ -1197,7 +1197,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
11971197 if (!error )
11981198 {
11991199#endif
1200- stream = fopen (fname , "r" );
1200+ stream = fopen (fname , R_TEXTFILE );
12011201 if (!stream )
12021202 {
12031203 psql_error ("%s: %s\n" , fname , strerror (errno ));
@@ -1262,7 +1262,7 @@ process_file(char *filename)
12621262 if (!filename )
12631263 return false;
12641264
1265- fd = fopen (filename , "r" );
1265+ fd = fopen (filename , R_TEXTFILE );
12661266
12671267 if (!fd )
12681268 {
Original file line number Diff line number Diff line change 33 *
44 * Copyright (c) 2000-2003, PostgreSQL Global Development Group
55 *
6- * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.35 2004/04/19 17:42:58 momjian Exp $
6+ * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.36 2004/07/11 00:54:55 momjian Exp $
77 */
88#ifndef COMMON_H
99#define COMMON_H
@@ -62,4 +62,16 @@ extern char parse_char(char **buf);
6262
6363extern char * expand_tilde (char * * filename );
6464
65+ /*
66+ * WIN32 treats Control-Z as EOF in files opened in text mode.
67+ * Therefore, we open files in binary mode on Win32 so we can read
68+ * literal control-Z. The other affect is that we see CRLF, but
69+ * that is OK because we can already handle those cleanly.
70+ */
71+ #ifndef WIN32
72+ #define R_TEXTFILE "r"
73+ #else
74+ #define R_TEXTFILE "rb"
75+ #endif
76+
6577#endif /* COMMON_H */
Original file line number Diff line number Diff line change 33 *
44 * Copyright (c) 2000-2003, PostgreSQL Global Development Group
55 *
6- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.47 2004/05/07 00:24:58 tgl Exp $
6+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.48 2004/07/11 00:54:55 momjian Exp $
77 */
88#include "postgres_fe.h"
99#include "copy.h"
@@ -516,7 +516,7 @@ do_copy(const char *args)
516516 if (options -> from )
517517 {
518518 if (options -> file )
519- copystream = fopen (options -> file , "r" );
519+ copystream = fopen (options -> file , R_TEXTFILE );
520520 else if (!options -> psql_inout )
521521 copystream = pset .cur_cmd_source ;
522522 else
Original file line number Diff line number Diff line change 3131 * Portions Copyright (c) 1994, Regents of the University of California
3232 *
3333 * IDENTIFICATION
34- * $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.3 2004/05/07 00:24:58 tgl Exp $
34+ * $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.4 2004/07/11 00:54:55 momjian Exp $
3535 *
3636 *-------------------------------------------------------------------------
3737 */
@@ -1284,7 +1284,7 @@ psql_scan_slash_option(PsqlScanState state,
12841284 char buf[512 ];
12851285 size_t result;
12861286
1287- fd = popen (cmd, " r " );
1287+ fd = popen (cmd, R_TEXTFILE );
12881288 if (!fd)
12891289 {
12901290 psql_error (" %s: %s\n " , cmd, strerror (errno));
You can’t perform that action at this time.
0 commit comments