Browse Source

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 năm trước cách đây
mục cha
commit
1733b3da6e
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  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