Re: mingw lseek bug

2007-05-28 Thread Bruno Haible
Eric Blake wrote: > Do we want to offer ftello(fp) as the shorter alternative to > lseek(fileno(fp),0,SEEK_CUR) for testing seekability? I don't think we can guarantee that, if we stick to the abstractions laid out by POSIX. The ftello.html page says "The ftell() function shall obtain the curr

new module 'ftell' (was: Re: mingw lseek bug)

2007-05-28 Thread Bruno Haible
Eric Blake wrote: > --- doc/functions/ftell.texi 1 May 2007 15:11:38 - 1.1 > +++ doc/functions/ftell.texi 24 May 2007 16:21:36 - > @@ -4,10 +4,12 @@ > > POSIX specification: @url{http://www.opengroup.org/susv3xsh/ftell.html} > > -Gnulib module: --- > +Gnulib module: ftello >

Re: mingw lseek bug

2007-05-28 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 5/28/2007 7:55 AM: > Thanks for explaining. I thought you were talking about the lseek call > inside fflush, not about an lseek call before it. > > Since loss of data is a severe condition, I'm adding a note about it: Tha

new module 'fseek' (Re: mingw lseek bug)

2007-05-28 Thread Bruno Haible
Eric Blake wrote: > --- doc/functions/fseek.texi 1 May 2007 15:11:38 - 1.1 > +++ doc/functions/fseek.texi 24 May 2007 16:21:36 - > @@ -4,10 +4,12 @@ > > POSIX specification: @url{http://www.opengroup.org/susv3xsh/fseek.html} > > -Gnulib module: --- > +Gnulib module: fseeko >

Re: mingw lseek bug

2007-05-28 Thread Bruno Haible
Eric Blake wrote: > > --- 9,40 > > AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) > > AC_REQUIRE([AC_PROG_CC]) > > AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe], > > ! [if test $cross_compiling = no; then > > !AC_LINK_IFELSE([ > > ! #include /* for off_t */

Re: mingw lseek bug

2007-05-28 Thread Bruno Haible
Eric Blake wrote: > --- doc/functions/fseek.texi 1 May 2007 15:11:38 - 1.1 > +++ doc/functions/fseek.texi 24 May 2007 16:21:36 - > @@ -15,4 +17,7 @@ Portability problems not fixed by Gnulib > @item > On Windows platforms (excluding Cygwin), this function does not set @code > {errn

Re: mingw lseek bug

2007-05-28 Thread Bruno Haible
Eric Blake wrote: > --- doc/functions/lseek.texi 1 May 2007 15:11:38 - 1.1 > +++ doc/functions/lseek.texi 24 May 2007 16:21:36 - > @@ -4,10 +4,12 @@ > > POSIX specification: @url{http://www.opengroup.org/susv3xsh/lseek.html} > > -Gnulib module: --- > +Gnulib module: lseek > >

Re: mingw lseek bug

2007-05-28 Thread Bruno Haible
Eric Blake wrote: > > You said that you got an fflush failure on mingw. Could you please > > show a test program that failed before? > > The m4 test suite detected failures on mingw due to this code that got > invoked prior to the syscmd macro, in an attempt to follow the POSIX rule > that for see

Re: mingw lseek bug

2007-05-28 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 5/28/2007 7:01 AM: > --- 9,40 > AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) > AC_REQUIRE([AC_PROG_CC]) > AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe], > ! [if test $cross_compiling = no;

Re: mingw lseek bug

2007-05-28 Thread Bruno Haible
Eric Blake wrote: > > It should be possible to write a real test. > > ... > > I still don't see a proof that lseek is incorrect on mingw. > > I tested by writing test-lseek.c first, and using > > echo hi | test-lseek && echo failed > > then repeating that test with the benefit of the lseek modul

Re: mingw lseek bug

2007-05-28 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 5/24/2007 6:12 PM: Hi Bruno, >> * tests/test-lseek.c: New file. > > It would be better if it would also test errno. Done like so (and fixing a bug it uncovered in the meantime): 2007-05-28 Eric Blake <[EMAIL PROTECTE

Re: mingw lseek bug

2007-05-24 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 5/24/2007 6:12 PM: > Hi Eric, > > I still don't see a proof that lseek is incorrect on mingw. I tested by writing test-lseek.c first, and using echo hi | test-lseek && echo failed then repeating that test with the benef

Re: mingw lseek bug

2007-05-24 Thread Bruno Haible
Hi Eric, I still don't see a proof that lseek is incorrect on mingw. > +# define lseek(f,o,w) \ > +(GL_LINK_WARNING ("lseek does not fail with ESPIPE on non-seekable " \ > + "files on some systems - " \ > + "use gnulib module lseek for portability"),

Re: mingw lseek bug

2007-05-24 Thread Eric Blake
Eric Blake byu.net> writes: > > But there are other types of devices as well, such as special character > > devices (COM: and consoles). It looks safer to include only the regular > > files: > > GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_DISK. > > At the same time, NUL (correspond

Re: mingw lseek bug

2007-05-24 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 5/24/2007 4:08 AM: >> if (PeekNamedPipe ((HANDLE) _get_osfhandle (fd), NULL, 0, NULL, NULL, >> NULL)) > > But there are other types of devices as well, such as special character > devices (COM: and consoles). It looks sa

Re: mingw lseek bug

2007-05-24 Thread Bruno Haible
Eric Blake wrote: > I just noticed that lseek on mingw returns 0 instead of -1 on pipes. > Which means that gnulib's fflush module thinks the pipe is seekable, and > loses data in the pipe instead of behaving as a no-op as it should in > trying to reposition the pipe's location. Indeed, lseek on p

Re: mingw lseek bug

2007-05-24 Thread Bruno Haible
Brian Dessent wrote: > > However, I'm not sure on mingw how to detect whether an fd is open on a > > regular file vs. a pipe. Any ideas? > > Check out ser-mingw.c from gdb, they have a fair amount of MinGW pipe/fd > handling code there, e.g. > > static int > fd_is_pipe (int fd) > { > if (PeekN

Re: mingw lseek bug

2007-05-23 Thread Brian Dessent
Eric Blake wrote: > However, I'm not sure on mingw how to detect whether an fd is open on a > regular file vs. a pipe. Any ideas? Check out ser-mingw.c from gdb, they have a fair amount of MinGW pipe/fd handling code there, e.g. static int fd_is_pipe (int fd) { if (PeekNamedPipe ((HANDLE) _ge

mingw lseek bug

2007-05-23 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I just noticed that lseek on mingw returns 0 instead of -1 on pipes. Which means that gnulib's fflush module thinks the pipe is seekable, and loses data in the pipe instead of behaving as a no-op as it should in trying to reposition the pipe's location