Skip to content

Commit

Permalink
options/ansi: fix ftell behaviour after ungetc
Browse files Browse the repository at this point in the history
Fixes the failing GMP tests documented in managarm#1221.
  • Loading branch information
lzcunt committed Jan 28, 2025
1 parent 1fda4e6 commit f1a00e7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion options/ansi/generic/file-io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ int abstract_file::tell(off_t *current_offset) {
if(int e = io_seek(0, SEEK_CUR, &seek_offset); e)
return e;

*current_offset = seek_offset + (off_t(__offset) - off_t(__io_offset));
*current_offset = seek_offset
+ (off_t(__offset) - off_t(__io_offset))
+ (off_t(__unget_ptr) - off_t(__buffer_ptr));
return 0;
}

Expand Down

0 comments on commit f1a00e7

Please sign in to comment.