Skip to content

Commit e1aab77

Browse files
committed
Flush before changing binary mode on Windows, for output to reflect prev mode
1 parent f1435ab commit e1aab77

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/io/stm_tests.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ struct
214214
| Output_bytes b -> Res (result unit exn, protect (Out_channel.output_bytes oc) b)
215215
| Output (b,p,l) -> Res (result unit exn, protect (Out_channel.output oc b p) l)
216216
| Output_substring (s,p,l) -> Res (result unit exn, protect (Out_channel.output_substring oc s p) l)
217-
| Set_binary_mode b -> Res (unit, Out_channel.set_binary_mode oc b)
217+
| Set_binary_mode b ->
218+
if Sys.win32 || Sys.cygwin
219+
then Res (unit, (Out_channel.flush oc; Out_channel.set_binary_mode oc b)) (* flush before changing mode *)
220+
else Res (unit, Out_channel.set_binary_mode oc b)
218221
| Set_buffered b -> Res (unit, Out_channel.set_buffered oc b)
219222
| Is_buffered -> Res (bool, Out_channel.is_buffered oc)
220223

0 commit comments

Comments
 (0)