Fossil SCM

Get the pipes working on windows.

drh 2021-06-22 13:00 patch-cmd
Commit a534422e89fc2b4802522311271f2d481f583ee7b6deefe0219f315c0540f796
1 file changed +9
--- src/patch.c
+++ src/patch.c
@@ -26,10 +26,12 @@
2626
#if defined(_WIN32)
2727
# include <io.h>
2828
# include <fcntl.h>
2929
# undef popen
3030
# define popen _popen
31
+# undef pclose
32
+# define pclose _pclose
3133
#endif
3234
3335
/*
3436
** Flags passed from the main patch_cmd() routine into subfunctions used
3537
** to implement the various subcommands.
@@ -205,10 +207,14 @@
205207
unsigned char *pData;
206208
pData = sqlite3_serialize(g.db, "patch", &sz, 0);
207209
if( pData==0 ){
208210
fossil_fatal("out of memory");
209211
}
212
+#ifdef _WIN32
213
+ fflush(out);
214
+ _setmode(_fileno(out), _O_BINARY);
215
+#endif
210216
fwrite(pData, sz, 1, out);
211217
sqlite3_free(pData);
212218
fflush(out);
213219
}
214220
}
@@ -226,10 +232,13 @@
226232
Blob buf;
227233
int rc;
228234
int sz;
229235
unsigned char *pData;
230236
blob_init(&buf, 0, 0);
237
+#ifdef _WIN32
238
+ _setmode(_fileno(in), _O_BINARY);
239
+#endif
231240
sz = blob_read_from_channel(&buf, in, -1);
232241
pData = (unsigned char*)blob_buffer(&buf);
233242
db_multi_exec("ATTACH ':memory:' AS patch");
234243
if( g.fSqlTrace ){
235244
fossil_trace("-- deserialize(\"patch\", pData, %lld);\n", sz);
236245
--- src/patch.c
+++ src/patch.c
@@ -26,10 +26,12 @@
26 #if defined(_WIN32)
27 # include <io.h>
28 # include <fcntl.h>
29 # undef popen
30 # define popen _popen
 
 
31 #endif
32
33 /*
34 ** Flags passed from the main patch_cmd() routine into subfunctions used
35 ** to implement the various subcommands.
@@ -205,10 +207,14 @@
205 unsigned char *pData;
206 pData = sqlite3_serialize(g.db, "patch", &sz, 0);
207 if( pData==0 ){
208 fossil_fatal("out of memory");
209 }
 
 
 
 
210 fwrite(pData, sz, 1, out);
211 sqlite3_free(pData);
212 fflush(out);
213 }
214 }
@@ -226,10 +232,13 @@
226 Blob buf;
227 int rc;
228 int sz;
229 unsigned char *pData;
230 blob_init(&buf, 0, 0);
 
 
 
231 sz = blob_read_from_channel(&buf, in, -1);
232 pData = (unsigned char*)blob_buffer(&buf);
233 db_multi_exec("ATTACH ':memory:' AS patch");
234 if( g.fSqlTrace ){
235 fossil_trace("-- deserialize(\"patch\", pData, %lld);\n", sz);
236
--- src/patch.c
+++ src/patch.c
@@ -26,10 +26,12 @@
26 #if defined(_WIN32)
27 # include <io.h>
28 # include <fcntl.h>
29 # undef popen
30 # define popen _popen
31 # undef pclose
32 # define pclose _pclose
33 #endif
34
35 /*
36 ** Flags passed from the main patch_cmd() routine into subfunctions used
37 ** to implement the various subcommands.
@@ -205,10 +207,14 @@
207 unsigned char *pData;
208 pData = sqlite3_serialize(g.db, "patch", &sz, 0);
209 if( pData==0 ){
210 fossil_fatal("out of memory");
211 }
212 #ifdef _WIN32
213 fflush(out);
214 _setmode(_fileno(out), _O_BINARY);
215 #endif
216 fwrite(pData, sz, 1, out);
217 sqlite3_free(pData);
218 fflush(out);
219 }
220 }
@@ -226,10 +232,13 @@
232 Blob buf;
233 int rc;
234 int sz;
235 unsigned char *pData;
236 blob_init(&buf, 0, 0);
237 #ifdef _WIN32
238 _setmode(_fileno(in), _O_BINARY);
239 #endif
240 sz = blob_read_from_channel(&buf, in, -1);
241 pData = (unsigned char*)blob_buffer(&buf);
242 db_multi_exec("ATTACH ':memory:' AS patch");
243 if( g.fSqlTrace ){
244 fossil_trace("-- deserialize(\"patch\", pData, %lld);\n", sz);
245

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button