forked from msys2/MINGW-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0006-MinGW-w64-open-in-binary-mode.patch
More file actions
232 lines (214 loc) · 8.88 KB
/
Copy path0006-MinGW-w64-open-in-binary-mode.patch
File metadata and controls
232 lines (214 loc) · 8.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
diff -urN flex-2.5.39.orig/configure.ac flex-2.5.39/configure.ac
--- flex-2.5.39.orig/configure.ac 2014-08-15 18:52:13.481354600 +0100
+++ flex-2.5.39/configure.ac 2014-08-15 19:03:21.302157100 +0100
@@ -105,6 +105,24 @@
AC_C_CONST
AC_TYPE_SIZE_T
+# Define FOPEN_MODE_READ and FOPEN_MODE_WRITE strings.
+# Windows needs "rb" and "wb" respectively due to a bug
+# in msvcrt:
+# ftell() is unusable on Windows in the face of text files
+# that use just LF and not Windows-style CR-LF as newlines
+# http://support.microsoft.com/kb/68337
+
+case $host_os in
+ mingw*)
+ BINARY="b"
+ ;;
+ *)
+ BINARY=""
+ ;;
+esac
+AC_DEFINE_UNQUOTED([FOPEN_MODE_READ], "r${BINARY}", On Windows must add 'b' to fopen calls.)
+AC_DEFINE_UNQUOTED([FOPEN_MODE_WRITE], "w${BINARY}", On Windows must add 'b' to fopen calls.)
+
# Checks for library functions.
AC_FUNC_ALLOCA
diff -urN flex-2.5.39.orig/main.c flex-2.5.39/main.c
--- flex-2.5.39.orig/main.c 2014-08-15 18:52:13.465352600 +0100
+++ flex-2.5.39/main.c 2014-08-15 19:07:34.976869700 +0100
@@ -403,7 +403,7 @@
snprintf (pname, nbytes, tablesfile_template, prefix);
}
- if ((tablesout = fopen (tablesfilename, "w")) == NULL)
+ if ((tablesout = fopen (tablesfilename, FOPEN_MODE_WRITE)) == NULL)
lerrsf (_("could not create %s"), tablesfilename);
if (pname)
free (pname);
@@ -420,7 +420,7 @@
flexerror (_("could not write tables header"));
}
- if (skelname && (skelfile = fopen (skelname, "r")) == NULL)
+ if (skelname && (skelfile = fopen (skelname, FOPEN_MODE_READ)) == NULL)
lerrsf (_("can't open skeleton file %s"), skelname);
if (reentrant) {
@@ -1496,7 +1496,7 @@
}
if (backing_up_report) {
- backing_up_file = fopen (backing_name, "w");
+ backing_up_file = fopen (backing_name, FOPEN_MODE_WRITE);
if (backing_up_file == NULL)
lerrsf (_
("could not create backing-up info file %s"),
diff -urN flex-2.5.39.orig/scan.l flex-2.5.39/scan.l
--- flex-2.5.39.orig/scan.l 2014-08-15 18:52:13.477354100 +0100
+++ flex-2.5.39/scan.l 2014-08-15 19:44:56.248975100 +0100
@@ -990,7 +990,7 @@
if ( file && strcmp( file, "-" ) )
{
infilename = copy_string( file );
- yyin = fopen( infilename, "r" );
+ yyin = fopen( infilename, FOPEN_MODE_READ );
if ( yyin == NULL )
lerrsf( _( "can't open %s" ), file );
diff -urN flex-2.5.39.orig/tests/test-include-by-buffer/scanner.l flex-2.5.39/tests/test-include-by-buffer/scanner.l
--- flex-2.5.39.orig/tests/test-include-by-buffer/scanner.l 2014-08-15 18:52:13.552363600 +0100
+++ flex-2.5.39/tests/test-include-by-buffer/scanner.l 2014-08-15 19:44:54.209216100 +0100
@@ -54,7 +54,7 @@
/* recurse */
yytext[yyleng-1]='\0';
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
- if((yyin=fopen(yytext,"r"))==NULL) {
+ if((yyin=fopen(yytext,FOPEN_MODE_READ))==NULL) {
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext);
yyterminate();
}
@@ -90,7 +90,7 @@
fprintf(stderr,"*** Error: Must specifiy one filename.\n");
exit(-1);
}
- if((fp=fopen(argv[1],"r"))==NULL) {
+ if((fp=fopen(argv[1],FOPEN_MODE_READ))==NULL) {
fprintf(stderr,"*** Error: fopen(%s) failed.\n",argv[1]);
exit(-1);
}
diff -urN flex-2.5.39.orig/tests/test-include-by-push/scanner.l flex-2.5.39/tests/test-include-by-push/scanner.l
--- flex-2.5.39.orig/tests/test-include-by-push/scanner.l 2014-08-15 18:52:13.564365200 +0100
+++ flex-2.5.39/tests/test-include-by-push/scanner.l 2014-08-15 19:44:51.649391000 +0100
@@ -48,7 +48,7 @@
[[:alnum:]_.-]+> {
/* recurse */
yytext[yyleng-1]='\0';
- if((yyin=fopen(yytext,"r"))==NULL) {
+ if((yyin=fopen(yytext,FOPEN_MODE_READ))==NULL) {
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext);
yyterminate();
}
@@ -80,7 +80,7 @@
fprintf(stderr,"*** Error: Must specifiy one filename.\n");
exit(-1);
}
- if((fp=fopen(argv[1],"r"))==NULL) {
+ if((fp=fopen(argv[1],FOPEN_MODE_READ))==NULL) {
fprintf(stderr,"*** Error: fopen(%s) failed.\n",argv[1]);
exit(-1);
}
diff -urN flex-2.5.39.orig/tests/test-include-by-reentrant/scanner.l flex-2.5.39/tests/test-include-by-reentrant/scanner.l
--- flex-2.5.39.orig/tests/test-include-by-reentrant/scanner.l 2014-08-15 18:52:13.592368700 +0100
+++ flex-2.5.39/tests/test-include-by-reentrant/scanner.l 2014-08-15 19:44:50.120196800 +0100
@@ -51,7 +51,7 @@
yyscan_t scanner;
FILE * fp;
yytext[yyleng-1]='\0';
- if((fp=fopen(yytext,"r"))==NULL) {
+ if((fp=fopen(yytext,FOPEN_MODE_READ))==NULL) {
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",
yytext);
yyterminate();
@@ -87,7 +87,7 @@
fprintf(stderr,"*** Error: Must specifiy one filename.\n");
exit(-1);
}
- if((fp=fopen(argv[1],"r"))==NULL) {
+ if((fp=fopen(argv[1],FOPEN_MODE_READ))==NULL) {
fprintf(stderr,"*** Error: fopen(%s) failed.\n",argv[1]);
exit(-1);
}
diff -urN flex-2.5.39.orig/tests/test-multiple-scanners-r/main.c flex-2.5.39/tests/test-multiple-scanners-r/main.c
--- flex-2.5.39.orig/tests/test-multiple-scanners-r/main.c 2014-08-15 18:52:13.594869000 +0100
+++ flex-2.5.39/tests/test-multiple-scanners-r/main.c 2014-08-15 19:44:47.219328500 +0100
@@ -35,7 +35,7 @@
S1_lex_init(&scan1);
S2_lex_init(&scan2);
- if((fp = fopen("scanner-1.tables","r")) == 0){
+ if((fp = fopen("scanner-1.tables",FOPEN_MODE_READ)) == 0){
fprintf(stderr,"Could not open scanner-1.tables.\n");
exit(1);
}
@@ -45,7 +45,7 @@
}
fclose(fp);
- if((fp = fopen("scanner-2.tables","r")) == 0){
+ if((fp = fopen("scanner-2.tables",FOPEN_MODE_READ)) == 0){
fprintf(stderr,"Could not open scanner-2.tables.\n");
exit(1);
}
diff -urN flex-2.5.39.orig/tests/test-pthread/scanner.l flex-2.5.39/tests/test-pthread/scanner.l
--- flex-2.5.39.orig/tests/test-pthread/scanner.l 2014-08-15 18:52:13.597869400 +0100
+++ flex-2.5.39/tests/test-pthread/scanner.l 2014-08-15 19:44:48.602004100 +0100
@@ -134,7 +134,7 @@
yylex_init( &scanner );
/*printf("Scanning file %s #%d\n",filenames[next],i); fflush(stdout); */
- if((fp = fopen(filenames[next],"r"))==NULL) {
+ if((fp = fopen(filenames[next],FOPEN_MODE_READ))==NULL) {
perror("fopen");
return NULL;
}
diff -urN flex-2.5.39.orig/tests/test-reject/scanner.l flex-2.5.39/tests/test-reject/scanner.l
--- flex-2.5.39.orig/tests/test-reject/scanner.l 2014-08-15 18:52:13.541862300 +0100
+++ flex-2.5.39/tests/test-reject/scanner.l 2014-08-15 19:44:46.116688500 +0100
@@ -51,7 +51,7 @@
#endif
#ifdef TEST_HAS_TABLES_EXTERNAL
- if((fp = fopen(argv[1],"r"))== NULL)
+ if((fp = fopen(argv[1],FOPEN_MODE_READ))== NULL)
YY_FATAL_ERROR("could not open tables file for reading");
if(yytables_fload(fp M4_YY_CALL_LAST_ARG) < 0)
@@ -61,7 +61,7 @@
#endif
if(argc > 2){
- if((fp = fopen(argv[2],"r"))== NULL)
+ if((fp = fopen(argv[2],FOPEN_MODE_READ))== NULL)
YY_FATAL_ERROR("could not open input file for reading");
yyin = fp;
}
diff -urN flex-2.5.39.orig/tests/test-rescan-nr/scanner.l flex-2.5.39/tests/test-rescan-nr/scanner.l
--- flex-2.5.39.orig/tests/test-rescan-nr/scanner.l 2014-08-15 18:52:13.603370100 +0100
+++ flex-2.5.39/tests/test-rescan-nr/scanner.l 2014-08-15 19:44:44.695508000 +0100
@@ -51,7 +51,7 @@
FILE* fp;
int i;
- if ((fp = fopen(argv[1],"r")) == NULL){
+ if ((fp = fopen(argv[1],FOPEN_MODE_READ)) == NULL){
perror("Failed to open input file.");
return 1;
}
diff -urN flex-2.5.39.orig/tests/test-rescan-r/scanner.l flex-2.5.39/tests/test-rescan-r/scanner.l
--- flex-2.5.39.orig/tests/test-rescan-r/scanner.l 2014-08-15 18:52:13.582867500 +0100
+++ flex-2.5.39/tests/test-rescan-r/scanner.l 2014-08-15 19:46:15.811078200 +0100
@@ -52,7 +52,7 @@
int i;
yyscan_t yyscanner;
- if ((fp = fopen(argv[1],"r")) == NULL){
+ if ((fp = fopen(argv[1],FOPEN_MODE_READ)) == NULL){
perror("Failed to open input file.");
return 1;
}
diff -urN flex-2.5.39.orig/tests/test-table-opts/scanner.l flex-2.5.39/tests/test-table-opts/scanner.l
--- flex-2.5.39.orig/tests/test-table-opts/scanner.l 2014-08-15 18:52:13.570866000 +0100
+++ flex-2.5.39/tests/test-table-opts/scanner.l 2014-08-15 19:44:43.077802600 +0100
@@ -53,7 +53,7 @@
#endif
#ifdef TEST_HAS_TABLES_EXTERNAL
- if((fp = fopen(argv[1],"r"))== NULL)
+ if((fp = fopen(argv[1],FOPEN_MODE_READ))== NULL)
YY_FATAL_ERROR("could not open tables file for reading");
if(yytables_fload(fp M4_YY_CALL_LAST_ARG) < 0)
@@ -63,7 +63,7 @@
#endif
if(argc > 2){
- if((fp = fopen(argv[2],"r"))== NULL)
+ if((fp = fopen(argv[2],FOPEN_MODE_READ))== NULL)
YY_FATAL_ERROR("could not open input file for reading");
yyin = fp;
}