From 8b3f2fa09e9241e20926c8171753a271c21ec93d Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 2 Feb 2024 13:56:33 -0500 Subject: first cut of tracking previous return values with ftell()/fseek() as POC --- src/stdio/ftell.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/stdio/ftell.c') diff --git a/src/stdio/ftell.c b/src/stdio/ftell.c index f68c18b2..ad23bf31 100644 --- a/src/stdio/ftell.c +++ b/src/stdio/ftell.c @@ -5,15 +5,21 @@ long int ftell(FILE *stream) { + long int ret = -1L; + SIGNAL_SAFE(0); + ASSERT_STREAM(stream, 0, 0); - (void)stream; - /* TODO */ /* RETURN_SUCCESS(the current file position); RETURN_FAILURE(LITERAL(-1L)); */ - return -1L; + + if (stream->text) { + ADD_PREV(ret, stream->valid_ftell, stream->nvalid_ftell); + } + + return ret; } /*** -- cgit v1.2.1