Bläddra i källkod

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 år sedan
förälder
incheckning
1733b3da6e
1 ändrade filer med 1 tillägg och 1 borttagningar
  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