Browse Source

libc: ftell should return position of read pointer

K. Lange 4 years ago
parent
commit
f16fbd458c
1 changed files with 3 additions and 0 deletions
  1. 3 0
      libc/stdio/stdio.c

+ 3 - 0
libc/stdio/stdio.c

@@ -313,6 +313,9 @@ long ftell(FILE * stream) {
 	if (_argv_0 && strcmp(_argv_0, "ld.so") && __libc_debug) {
 		fprintf(stderr, "%s: ftell(%s)\n", _argv_0, stream->_name);
 	}
+	if (stream->read_from || stream->last_read_start) {
+		return stream->last_read_start + stream->read_from;
+	}
 	stream->offset = 0;
 	stream->read_from = 0;
 	stream->available = 0;