develooper Front page | perl.perl5.porters | Postings from November 2000

[ID 20001112.007] sfio's sftell isn't ftell

Thread Next
Nicholas Clark
November 12, 2000 14:40
[ID 20001112.007] sfio's sftell isn't ftell
Message ID:

This is a bug report for perl from,
generated with the help of perlbug 1.32 running under perl v5.7.0.

[Please enter your report here]

sfio's sftell() isn't ftell(). For an unseekable file it returns number
of bytes read/written, rather than -1.

sfio's stdio emulation for ftell is

	return (long)sfseek(sf, (Sfoff_t)0, SEEK_CUR|SF_SHARE);

which does behave in the expected stdio fashion.
(sfio documentation states SF_SHARE ensures an lseek() to verifiy that the
file position is valid)

With the following patch

--- perlsfio.h.orig     Tue Oct 24 19:58:50 2000
+++ perlsfio.h  Sun Nov 12 19:19:26 2000
@@ -35,7 +35,7 @@
 #define PerlIO_fileno(f)               sffileno(f)
 #define PerlIO_clearerr(f)             sfclrerr(f)
 #define PerlIO_flush(f)                        sfsync(f)
-#define PerlIO_tell(f)                 sftell(f)
+#define PerlIO_tell(f)                 sfseek(f,0,1|SF_SHARE)
 #define PerlIO_seek(f,o,w)             sfseek(f,o,w)
 #define PerlIO_rewind(f)               (void) sfseek((f),0L,0)
 #define PerlIO_tmpfile()               sftmp(0)

perl compiled with sfio returns -1 for tell STDIN where STDIN is a tty,
just like perl with stdio.

All regression tests pass. [and always did :-(]

Nicholas Clark

[Please do not change anything below this line]
Site configuration information for perl v5.7.0:

Configured by nick at Sat Oct 21 11:14:10 BST 2000.

Summary of my perl5 (revision 5.0 version 7 subversion 0) configuration:
    osname=linux, osvers=2.2.17-rmk1, archname=armv4l-linux-64int
    uname='linux 2.2.17-rmk1 #5 mon sep 18 19:03:46 bst 2000 armv4l unknown '
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=define uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    cc='/usr/local/bin/gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    cppflags='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='2.95.2 20000516 (release) []', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lsfio -lnsl -lndbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil
    perllibs=-lsfio -lnsl -ldl -lm -lc -lposix -lcrypt -lutil
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.7.0:

Environment for perl v5.7.0:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About