瀏覽代碼

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