From 6ff604a73ac868eea3ce6cf8941dcf0447935b1d Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sat, 1 Sep 2001 12:13:33 +0000 Subject: [PATCH] Strict in the POSIX sence, if file position is unspecified after ungetc() at 0, return that we can't specify it, i.e. error with ESPIPE. (hint from: "Peter S. Housel" ) Back out sinit() addition, not needed after various code simplifications. --- lib/libc/stdio/ftell.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c index 7784c672ab0..e355a202812 100644 --- a/lib/libc/stdio/ftell.c +++ b/lib/libc/stdio/ftell.c @@ -78,17 +78,15 @@ ftello(fp) fpos_t rv; int ret; - /* make sure stdio is set up */ - if (!__sdidinit) - __sinit(); - FLOCKFILE(fp); ret = _ftello(fp, &rv); FUNLOCKFILE(fp); if (ret) return (-1); - if (rv < 0) /* Unspecified value because of ungetc() at 0 */ - rv = 0; + if (rv < 0) { /* Unspecified value because of ungetc() at 0 */ + errno = ESPIPE; + return (-1); + } return (rv); }