Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98e9775

Browse files
committed
Use standard macro for psql binary file open. Add comment explaining
control-z requirement.
1 parentc8c40bb commit98e9775

File tree

5 files changed

+16
-21
lines changed

5 files changed

+16
-21
lines changed

‎src/bin/psql/command.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.118 2004/07/1100:54:55 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.119 2004/07/1113:29:15 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_TEXTFILE);
1200+
stream=fopen(fname,PG_BINARY_R);
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_TEXTFILE);
1265+
fd=fopen(filename,PG_BINARY_R);
12661266

12671267
if (!fd)
12681268
{

‎src/bin/psql/common.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.36 2004/07/1100:54:55 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.37 2004/07/1113:29:15 momjian Exp $
77
*/
88
#ifndefCOMMON_H
99
#defineCOMMON_H
@@ -62,16 +62,4 @@ extern char parse_char(char **buf);
6262

6363
externchar*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-
#ifndefWIN32
72-
#defineR_TEXTFILE"r"
73-
#else
74-
#defineR_TEXTFILE"rb"
75-
#endif
76-
7765
#endif/* COMMON_H */

‎src/bin/psql/copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.48 2004/07/1100:54:55 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.49 2004/07/1113:29:15 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_TEXTFILE);
519+
copystream=fopen(options->file,PG_BINARY_R);
520520
elseif (!options->psql_inout)
521521
copystream=pset.cur_cmd_source;
522522
else

‎src/bin/psql/psqlscan.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Portions Copyright (c) 1994, Regents of the University of California
3232
*
3333
* IDENTIFICATION
34-
* $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.4 2004/07/1100:54:55 momjian Exp $
34+
* $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.5 2004/07/1113:29:15 momjian Exp $
3535
*
3636
*-------------------------------------------------------------------------
3737
*/
@@ -1284,7 +1284,7 @@ psql_scan_slash_option(PsqlScanState state,
12841284
charbuf[512];
12851285
size_tresult;
12861286

1287-
fd =popen(cmd,R_TEXTFILE);
1287+
fd =popen(cmd,PG_BINARY_R);
12881288
if (!fd)
12891289
{
12901290
psql_error("%s: %s\n", cmd,strerror(errno));

‎src/include/c.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/include/c.h,v 1.165 2004/05/21 05:08:03 tgl Exp $
15+
* $PostgreSQL: pgsql/src/include/c.h,v 1.166 2004/07/11 13:29:16 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -671,6 +671,13 @@ typedef NameData *Name;
671671
* ----------------------------------------------------------------
672672
*/
673673

674+
/*
675+
*NOTE: this is also used for opening text files.
676+
* WIN32 treats Control-Z as EOF in files opened in text mode.
677+
* Therefore, we open files in binary mode on Win32 so we can read
678+
* literal control-Z. The other affect is that we see CRLF, but
679+
* that is OK because we can already handle those cleanly.
680+
*/
674681
#if defined(__CYGWIN__)|| defined(WIN32)
675682
#definePG_BINARYO_BINARY
676683
#definePG_BINARY_R "rb"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp