bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fflush after ungetc


From: Bruno Haible
Subject: Re: fflush after ungetc
Date: Sat, 29 Mar 2008 12:59:34 +0100
User-agent: KMail/1.5.4

Eric Blake wrote:
> Cygwin 1.5.25-11 implements 1a+2a, and does not require an fflush
> replacement by any of the current tests in fflush.m4.  Therefore, cygwin
> fails test-fflush2.c
> ...
> At this point, I would even be happy with a solution that enforces 1a ...

Oops, you are right. My previous commit on this topic was incomplete:
  - My mail [1] said that gnulib implements 1b+2b, but the unit test only
    verifies 2b, not case 1.
  - On glibc systems, the behaviour is 1a+2x (neither of 2a,2b,2c), and
    fflush is not replaced, so the resulting behaviour is 1a+2x, not 1b+2b.
  - On Cygwin 1.5.25-11, as you say, the behaviour is 1a+2a, and fflush is
    not replaced, so the resulting behaviour is 1a+2a, not 1b+2b.

[1] http://lists.gnu.org/archive/html/bug-gnulib/2008-03/msg00132.html

At this point, waiting for a resolution by the Austin Group (Geoff Clare's
mail is an important opinion, but not yet a decision), I prefer to not change
the code, but just disable the test.

Bruno


2008-03-29  Bruno Haible  <address@hidden>

        * tests/test-fflush2.c (main): Temporarily disable the contents of
        this test.
        * m4/fflush.m4 (gl_FUNC_FFLUSH): Add a TODO.
        Reported by Eric Blake.

*** tests/test-fflush2.c.orig   2008-03-29 12:44:08.000000000 +0100
--- tests/test-fflush2.c        2008-03-29 12:43:29.000000000 +0100
***************
*** 48,53 ****
--- 48,62 ----
  int
  main (int argc, char **argv)
  {
+ #if 0
+   /* Check fflush after a backup ungetc() call.  This is case 1 in terms of
+      <http://lists.gnu.org/archive/html/bug-gnulib/2008-03/msg00131.html>.
+      The Austin Group has not yet decided how this should behave.  */
+ #endif
+ #if 0
+   /* Check fflush after a non-backup ungetc() call.  This is case 1 in terms 
of
+      <http://lists.gnu.org/archive/html/bug-gnulib/2008-03/msg00131.html>.
+      The Austin Group has not yet decided how this should behave.  */
    /* Check that fflush after a non-backup ungetc() call discards the ungetc
       buffer.  This is mandated by POSIX
       <http://www.opengroup.org/susv3/functions/ungetc.html>:
***************
*** 73,78 ****
--- 82,88 ----
  
    c = fgetc (stdin);
    ASSERT (c == '/');
+ #endif
  
    return 0;
  }
*** m4/fflush.m4.orig   2008-03-29 12:44:08.000000000 +0100
--- m4/fflush.m4        2008-03-29 12:40:33.000000000 +0100
***************
*** 1,6 ****
! # fflush.m4 serial 4
  
! # Copyright (C) 2007 Free Software Foundation, Inc.
  # This file is free software; the Free Software Foundation
  # gives unlimited permission to copy and/or distribute it,
  # with or without modifications, as long as this notice is preserved.
--- 1,6 ----
! # fflush.m4 serial 5
  
! # Copyright (C) 2007-2008 Free Software Foundation, Inc.
  # This file is free software; the Free Software Foundation
  # gives unlimited permission to copy and/or distribute it,
  # with or without modifications, as long as this notice is preserved.
***************
*** 21,28 ****
  #include <unistd.h>
         ]], [[FILE *f = fopen ("conftest.txt", "r");
         char buffer[10];
!        int fd = fileno (f);
!        if (!f || 0 > fd || fread (buffer, 1, 5, f) != 5)
           return 2;
         /* For deterministic results, ensure f read a bigger buffer.  */
         if (lseek (fd, 0, SEEK_CUR) == 5)
--- 21,31 ----
  #include <unistd.h>
         ]], [[FILE *f = fopen ("conftest.txt", "r");
         char buffer[10];
!        int fd;
!        if (f == NULL)
!          return 1;
!        fd = fileno (f);
!        if (fd < 0 || fread (buffer, 1, 5, f) != 5)
           return 2;
         /* For deterministic results, ensure f read a bigger buffer.  */
         if (lseek (fd, 0, SEEK_CUR) == 5)
***************
*** 30,36 ****
         /* POSIX requires fflush-fseek to set file offset of fd.  */
         if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
           return 4;
!        return !(lseek (fd, 0, SEEK_CUR) == 5);
         ]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no],
       [dnl Pessimistically assume fflush is broken.  This is wrong for
        dnl at least glibc and cygwin; but lib/fflush.c takes this into account.
--- 33,43 ----
         /* POSIX requires fflush-fseek to set file offset of fd.  */
         if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
           return 4;
!        if (lseek (fd, 0, SEEK_CUR) != 5)
!          return 5;
!        /* TODO: Verify behaviour of fflush after ungetc, see
!           
<http://lists.gnu.org/archive/html/bug-gnulib/2008-03/msg00131.html>.  */
!        return 0;
         ]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no],
       [dnl Pessimistically assume fflush is broken.  This is wrong for
        dnl at least glibc and cygwin; but lib/fflush.c takes this into account.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]