Browse Source

fixed file_seek in macros (close #3610)

Nicolas Cannasse 10 years ago
parent
commit
99dfcdac63
2 changed files with 3 additions and 2 deletions
  1. 1 0
      extra/CHANGES.txt
  2. 2 2
      interp.ml

+ 1 - 0
extra/CHANGES.txt

@@ -71,6 +71,7 @@
 	macro : changed @:genericBuild macros to prefer ComplexType returns
 	macro : [breaking] extended TAnonymous structures now have AExtend status instead of AClosed
 	macro : added Context.getDefines
+	macro : fixed file_seek from end (position was inversed)
 
 	Deprecations:
 

+ 2 - 2
interp.ml

@@ -1468,10 +1468,10 @@ let std_lib =
 		"file_seek", Fun3 (fun f pos mode ->
 			match f, pos, mode with
 			| VAbstract (AFRead f), VInt pos, VInt mode ->
-				seek_in f (match mode with 0 -> pos | 1 -> pos_in f + pos | 2 -> in_channel_length f - pos | _ -> error());
+				seek_in f (match mode with 0 -> pos | 1 -> pos_in f + pos | 2 -> in_channel_length f + pos | _ -> error());
 				VNull;
 			| VAbstract (AFWrite f), VInt pos, VInt mode ->
-				seek_out f (match mode with 0 -> pos | 1 -> pos_out f + pos | 2 -> out_channel_length f - pos | _ -> error());
+				seek_out f (match mode with 0 -> pos | 1 -> pos_out f + pos | 2 -> out_channel_length f + pos | _ -> error());
 				VNull;
 			| _ -> error()
 		);