ソースを参照

Fix bug related to ungetc and ftell()

At least in relibc, each call to ungetc should decrement ftell() by one
also allowing negative ftell() this is not possible on relibc thus gcc
failing to compile (gcc compiles tools that is later used to compile gcc
itself and these tools are the ones that fail)
oddcoder 4 年 前
コミット
1733b3da6e
1 ファイル変更1 行追加1 行削除
  1. 1 1
      src/header/stdio/mod.rs

+ 1 - 1
src/header/stdio/mod.rs

@@ -561,7 +561,7 @@ pub unsafe extern "C" fn ftello(stream: *mut FILE) -> off_t {
         return -1;
     }
 
-    pos - (stream.read_size - stream.read_pos) as off_t
+    pos - (stream.read_size - stream.read_pos) as off_t - stream.unget.len() as off_t
 }
 
 /// Try to lock the file. Returns 0 for success, 1 for failure