]> Savannah Git Hosting - gnulib.git/commitdiff
Avoid wrong configure results with gcc -fsanitize=address.
authorBruno Haible <bruno@clisp.org>
Sat, 20 May 2017 13:26:26 +0000 (15:26 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 20 May 2017 13:26:26 +0000 (15:26 +0200)
This completes the work done on 2016-02-06 on this topic.

* m4/memmem.m4 (gl_FUNC_MEMMEM): Free allocated memory before returning.
* m4/getcwd.m4 (gl_FUNC_GETCWD_NULL): Likewise.
* m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Likewise.
* m4/strstr.m4 (gl_FUNC_STRSTR): Likewise.
* m4/fopen.m4 (gl_FUNC_FOPEN): Close allocated FILE streams before
returning.
* m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Likewise.
* m4/fpurge.m4 (gl_FUNC_FPURGE): Likewise.
* m4/ftello.m4 (gl_FUNC_FTELLO): Likewise.
* m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise.
* m4/signbit.m4 (gl_FLOATTYPE_SIGN_LOCATION): Likewise.
* m4/ungetc.m4 (gl_FUNC_UNGETC_WORKS): Likewise.
* m4/getdelim.m4 (gl_FUNC_GETDELIM): Close allocated FILE streams and
free allocated memory before returning.
* m4/getline.m4 (gl_FUNC_GETLINE): Likewise.
* m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Close allocated DIR
objects before returning.
* m4/iconv.m4 (AM_ICONV_LINK): Close allocated iconv_t handles before
returning.

16 files changed:
ChangeLog
m4/d-ino.m4
m4/fflush.m4
m4/fopen.m4
m4/fpurge.m4
m4/ftello.m4
m4/getcwd.m4
m4/getdelim.m4
m4/getline.m4
m4/iconv.m4
m4/memmem.m4
m4/rmdir-errno.m4
m4/signbit.m4
m4/strcasestr.m4
m4/strstr.m4
m4/ungetc.m4

index 25a0f69f8c34ba0ade0fb55d82f5bce58f04e327..8ebdd7b5d0000c9032e67d61919b36bb4e2bac88 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2017-05-20  Bruno Haible  <bruno@clisp.org>
+
+       Avoid wrong configure results with gcc -fsanitize=address.
+       This completes the work done on 2016-02-06 on this topic.
+       * m4/memmem.m4 (gl_FUNC_MEMMEM): Free allocated memory before returning.
+       * m4/getcwd.m4 (gl_FUNC_GETCWD_NULL): Likewise.
+       * m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Likewise.
+       * m4/strstr.m4 (gl_FUNC_STRSTR): Likewise.
+       * m4/fopen.m4 (gl_FUNC_FOPEN): Close allocated FILE streams before
+       returning.
+       * m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Likewise.
+       * m4/fpurge.m4 (gl_FUNC_FPURGE): Likewise.
+       * m4/ftello.m4 (gl_FUNC_FTELLO): Likewise.
+       * m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise.
+       * m4/signbit.m4 (gl_FLOATTYPE_SIGN_LOCATION): Likewise.
+       * m4/ungetc.m4 (gl_FUNC_UNGETC_WORKS): Likewise.
+       * m4/getdelim.m4 (gl_FUNC_GETDELIM): Close allocated FILE streams and
+       free allocated memory before returning.
+       * m4/getline.m4 (gl_FUNC_GETLINE): Likewise.
+       * m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Close allocated DIR
+       objects before returning.
+       * m4/iconv.m4 (AM_ICONV_LINK): Close allocated iconv_t handles before
+       returning.
+
 2017-05-20  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool: Don't create hard links between gnulib and its testdirs.
index 79731ca7cf7e1e5e90a54f19d5815d593503ce73..65cd4d85809408b9c5d403d57eee12060980a8a0 100644 (file)
@@ -1,4 +1,4 @@
-# serial 15
+# serial 16
 
 dnl From Jim Meyering.
 dnl
@@ -29,11 +29,11 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
                return 1;
              e = readdir (dp);
              if (! e)
-               return 2;
+               { closedir (dp); return 2; }
              if (lstat (e->d_name, &st) != 0)
-               return 3;
+               { closedir (dp); return 3; }
              if (e->d_ino != st.st_ino)
-               return 4;
+               { closedir (dp); return 4; }
              closedir (dp);
              return 0;
            ]])],
index 1d1f1ba1dd10f8731d6964a05dc1717cfb744e99..7732234ee981307fa7d1fbdc3deaaeda3cd64f0d 100644 (file)
@@ -1,4 +1,4 @@
-# fflush.m4 serial 15
+# fflush.m4 serial 16
 
 # Copyright (C) 2007-2017 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -44,16 +44,16 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
            return 1;
          fd = fileno (f);
          if (fd < 0 || fread (buffer, 1, 5, f) != 5)
-           return 2;
+           { fclose (f); return 2; }
          /* For deterministic results, ensure f read a bigger buffer.  */
          if (lseek (fd, 0, SEEK_CUR) == 5)
-           return 3;
+           { fclose (f); return 3; }
          /* POSIX requires fflush-fseek to set file offset of fd.  This fails
             on BSD systems and on mingw.  */
          if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
-           return 4;
+           { fclose (f); return 4; }
          if (lseek (fd, 0, SEEK_CUR) != 5)
-           return 5;
+           { fclose (f); return 5; }
          /* Verify behaviour of fflush after ungetc. See
             <http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt>  */
          /* Verify behaviour of fflush after a backup ungetc.  This fails on
@@ -62,14 +62,15 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
          ungetc (c, f);
          fflush (f);
          if (fgetc (f) != c)
-           return 6;
+           { fclose (f); return 6; }
          /* Verify behaviour of fflush after a non-backup ungetc.  This fails
             on glibc 2.8 and on BSD systems.  */
          c = fgetc (f);
          ungetc ('@', f);
          fflush (f);
          if (fgetc (f) != c)
-           return 7;
+           { fclose (f); return 7; }
+         fclose (f);
          return 0;
        ]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no],
      [gl_cv_func_fflush_stdin=cross])
index 0d09e4e43bcc43543e941ea871c3916c9d891db7..3772e5066a7ba170772596afede1a85170e34706 100644 (file)
@@ -1,4 +1,4 @@
-# fopen.m4 serial 9
+# fopen.m4 serial 10
 dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -27,7 +27,11 @@ AC_DEFUN([gl_FUNC_FOPEN],
 #include <stdio.h>
 int main ()
 {
-  return fopen ("conftest.sl/", "w") != NULL;
+  FILE *fp = fopen ("conftest.sl/", "w");
+  int result = (fp != NULL);
+  if (fp != NULL)
+    fclose (fp);
+  return result;
 }]])],
             [gl_cv_func_fopen_slash=yes],
             [gl_cv_func_fopen_slash=no],
index 57be1b9e4060e96a2cafd7dc78e82ddf7231cf0f..3533f4b8f38d5dd6bb2727c2bfe4af0228da646a 100644 (file)
@@ -1,4 +1,4 @@
-# fpurge.m4 serial 7
+# fpurge.m4 serial 8
 dnl Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,23 +14,40 @@ AC_DEFUN([gl_FUNC_FPURGE],
     HAVE_FPURGE=1
     # Detect BSD bug.  Only cygwin 1.7 is known to be immune.
     AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
-      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
-]], [FILE *f = fopen ("conftest.txt", "w+");
-        if (!f) return 1;
-        if (fputc ('a', f) != 'a') return 2;
-        rewind (f);
-        if (fgetc (f) != 'a') return 3;
-        if (fgetc (f) != EOF) return 4;
-        if (fpurge (f) != 0) return 5;
-        if (putc ('b', f) != 'b') return 6;
-        if (fclose (f) != 0) return 7;
-        if ((f = fopen ("conftest.txt", "r")) == NULL) return 8;
-        if (fgetc (f) != 'a') return 9;
-        if (fgetc (f) != 'b') return 10;
-        if (fgetc (f) != EOF) return 11;
-        if (fclose (f) != 0) return 12;
-        if (remove ("conftest.txt") != 0) return 13;
-        return 0;])],
+      [AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <stdio.h>
+]],
+            [FILE *f = fopen ("conftest.txt", "w+");
+             if (!f)
+               return 1;
+             if (fputc ('a', f) != 'a')
+               { fclose (f); return 2; }
+             rewind (f);
+             if (fgetc (f) != 'a')
+               { fclose (f); return 3; }
+             if (fgetc (f) != EOF)
+               { fclose (f); return 4; }
+             if (fpurge (f) != 0)
+               { fclose (f); return 5; }
+             if (putc ('b', f) != 'b')
+               { fclose (f); return 6; }
+             if (fclose (f) != 0)
+               return 7;
+             if ((f = fopen ("conftest.txt", "r")) == NULL)
+               return 8;
+             if (fgetc (f) != 'a')
+               { fclose (f); return 9; }
+             if (fgetc (f) != 'b')
+               { fclose (f); return 10; }
+             if (fgetc (f) != EOF)
+               { fclose (f); return 11; }
+             if (fclose (f) != 0)
+               return 12;
+             if (remove ("conftest.txt") != 0)
+               return 13;
+             return 0;
+            ])],
       [gl_cv_func_fpurge_works=yes], [gl_cv_func_fpurge_works=no],
       [gl_cv_func_fpurge_works='guessing no'])])
     if test "x$gl_cv_func_fpurge_works" != xyes; then
index 0867c2a6455f5e46ba9baf906feb507ca9cc8192..8a4cdc5308a243f158a0aeca99618f832db47691 100644 (file)
@@ -1,4 +1,4 @@
-# ftello.m4 serial 11
+# ftello.m4 serial 12
 dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -73,7 +73,7 @@ main (void)
   if (fp == NULL)
     return 70;
   if (fwrite ("foogarsh", 1, 8, fp) < 8)
-    return 71;
+    { fclose (fp); return 71; }
   if (fclose (fp))
     return 72;
 
@@ -84,19 +84,19 @@ main (void)
   if (fp == NULL)
     return 73;
   if (fseek (fp, -1, SEEK_END))
-    return 74;
+    { fclose (fp); return 74; }
   if (!(getc (fp) == 'h'))
-    return 1;
+    { fclose (fp); return 1; }
   if (!(getc (fp) == EOF))
-    return 2;
+    { fclose (fp); return 2; }
   if (!(ftell (fp) == 8))
-    return 3;
+    { fclose (fp); return 3; }
   if (!(ftell (fp) == 8))
-    return 4;
+    { fclose (fp); return 4; }
   if (!(putc ('!', fp) == '!'))
-    return 5;
+    { fclose (fp); return 5; }
   if (!(ftell (fp) == 9))
-    return 6;
+    { fclose (fp); return 6; }
   if (!(fclose (fp) == 0))
     return 7;
   fp = fopen (TESTFILE, "r");
@@ -105,9 +105,9 @@ main (void)
   {
     char buf[10];
     if (!(fread (buf, 1, 10, fp) == 9))
-      return 10;
+      { fclose (fp); return 10; }
     if (!(memcmp (buf, "foogarsh!", 9) == 0))
-      return 11;
+      { fclose (fp); return 11; }
   }
   if (!(fclose (fp) == 0))
     return 12;
index ec6b637c50710ddad27a1bfe3e048c1b922e377e..a3f62c46225935bcf4e807eab5eb119e9aa632c5 100644 (file)
@@ -6,7 +6,7 @@
 # with or without modifications, as long as this notice is preserved.
 
 # Written by Paul Eggert.
-# serial 13
+# serial 14
 
 AC_DEFUN([gl_FUNC_GETCWD_NULL],
   [
@@ -37,9 +37,9 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
                if (! f)
                  return 2;
                if (f[0] != '/')
-                 return 3;
+                 { free (f); return 3; }
                if (f[1] != '\0')
-                 return 4;
+                 { free (f); return 4; }
                free (f);
                return 0;
              }
index 24adb94f313b1f157468211e59033f1ef6785766..67afdbab09ac251e1ce2e8c224a0d45db76a9baa 100644 (file)
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 11
+# getdelim.m4 serial 12
 
 dnl Copyright (C) 2005-2007, 2009-2017 Free Software Foundation, Inc.
 dnl
@@ -39,7 +39,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
         size_t siz = 0;
         int len = getdelim (&line, &siz, '\n', in);
         if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
-          return 2;
+          { free (line); fclose (in); return 2; }
       }
       {
         /* Test result for a NULL buffer and a non-zero size.
@@ -47,7 +47,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
         char *line = NULL;
         size_t siz = (size_t)(~0) / 4;
         if (getdelim (&line, &siz, '\n', in) == -1)
-          return 3;
+          { fclose (in); return 3; }
         free (line);
       }
       fclose (in);
index dcea772e568aad0ee33d4bbb2699606bc2ffc679..bd91befab76950c2c0df2094092b21dea1748a42 100644 (file)
@@ -1,4 +1,4 @@
-# getline.m4 serial 27
+# getline.m4 serial 28
 
 dnl Copyright (C) 1998-2003, 2005-2007, 2009-2017 Free Software Foundation,
 dnl Inc.
@@ -46,7 +46,7 @@ AC_DEFUN([gl_FUNC_GETLINE],
         size_t siz = 0;
         int len = getline (&line, &siz, in);
         if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
-          return 2;
+          { free (line); fclose (in); return 2; }
         free (line);
       }
       {
@@ -55,7 +55,7 @@ AC_DEFUN([gl_FUNC_GETLINE],
         char *line = NULL;
         size_t siz = (size_t)(~0) / 4;
         if (getline (&line, &siz, in) == -1)
-          return 3;
+          { fclose (in); return 3; }
         free (line);
       }
       fclose (in);
index bdafc54e3097fc9ac9638cebbd182b57b5c8522f..81ac1a6b45d0a7ad3fc924c0ec2836d0022374d4 100644 (file)
@@ -1,4 +1,4 @@
-# iconv.m4 serial 20
+# iconv.m4 serial 21
 dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -167,15 +167,27 @@ AC_DEFUN([AM_ICONV_LINK],
 #endif
   /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
      provided.  */
-  if (/* Try standardized names.  */
-      iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
-      /* Try IRIX, OSF/1 names.  */
-      && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
-      /* Try AIX names.  */
-      && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
-      /* Try HP-UX names.  */
-      && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
-    result |= 16;
+  {
+    /* Try standardized names.  */
+    iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
+    /* Try IRIX, OSF/1 names.  */
+    iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
+    /* Try AIX names.  */
+    iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
+    /* Try HP-UX names.  */
+    iconv_t cd4 = iconv_open ("utf8", "eucJP");
+    if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
+        && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
+      result |= 16;
+    if (cd1 != (iconv_t)(-1))
+      iconv_close (cd1);
+    if (cd2 != (iconv_t)(-1))
+      iconv_close (cd2);
+    if (cd3 != (iconv_t)(-1))
+      iconv_close (cd3);
+    if (cd4 != (iconv_t)(-1))
+      iconv_close (cd4);
+  }
   return result;
 ]])],
           [am_cv_func_iconv_works=yes], ,
index 9ef4dd494f88835337527140fdeba01206ed4206..334cb665e72016c542b730d348489c58876633f4 100644 (file)
@@ -1,4 +1,4 @@
-# memmem.m4 serial 24
+# memmem.m4 serial 25
 dnl Copyright (C) 2002-2004, 2007-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -113,6 +113,9 @@ static void quit (int sig) { _exit (sig + 128); }
         if (!memmem (haystack, 2 * m + 1, needle, m + 1))
           result |= 1;
       }
+    /* Free allocated memory, in case some sanitizer is watching.  */
+    free (haystack);
+    free (needle);
     return result;
     ]])],
         [gl_cv_func_memmem_works_fast=yes], [gl_cv_func_memmem_works_fast=no],
index c290a4822b4c8b9e272ee6b07395bf4f559a80b0..a389329da0054a087386e9832926ebff4817bf74 100644 (file)
@@ -1,4 +1,4 @@
-# serial 10
+# serial 11
 
 # Copyright (C) 2000-2001, 2005-2006, 2009-2017 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_RMDIR_NOTEMPTY],
           val = errno;
           s = fopen ("confdir2/errno", "w");
           fprintf (s, "%d\n", val);
+          fclose (s);
           return 0;
         }
         ]])],
index 9d2b0a8db15cc5d11b2c8ca889ec604594327326..f387ee91d66a2cefe2d7b1dcb5d8dc0773c84772 100644 (file)
@@ -1,4 +1,4 @@
-# signbit.m4 serial 13
+# signbit.m4 serial 14
 dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -272,6 +272,7 @@ int main ()
         {
           /* More than one bit difference.  */
           fprintf (fp, "unknown");
+          fclose (fp);
           return 2;
         }
       if (x)
@@ -284,6 +285,7 @@ int main ()
     {
       /* No difference.  */
       fprintf (fp, "unknown");
+      fclose (fp);
       return 3;
     }
   /* Now m = plus.word[k] ^ ~minus.word[k].  */
@@ -292,6 +294,7 @@ int main ()
       /* Oh? The sign bit is set in the positive and cleared in the negative
          numbers?  */
       fprintf (fp, "unknown");
+      fclose (fp);
       return 4;
     }
   for (i = 0; ; i++)
index 7d15c651e1f60e5f7c7dacc36e7a6b8bfa149c99..3af9582ed6f8c4604e340b10260cc6be42bd50a6 100644 (file)
@@ -1,4 +1,4 @@
-# strcasestr.m4 serial 21
+# strcasestr.m4 serial 22
 dnl Copyright (C) 2005, 2007-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -102,6 +102,9 @@ static void quit (int sig) { _exit (sig + 128); }
         if (!strcasestr (haystack, needle))
           result |= 1;
       }
+    /* Free allocated memory, in case some sanitizer is watching.  */
+    free (haystack);
+    free (needle);
     return result;
     ]])],
         [gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no],
index 9f7da641deea720674acf64068733970a61ede50..4b472ee62343bf073f5c4d433c6abb1e0ce7cb03 100644 (file)
@@ -1,4 +1,4 @@
-# strstr.m4 serial 17
+# strstr.m4 serial 18
 dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -99,6 +99,9 @@ static void quit (int sig) { _exit (sig + 128); }
         if (!strstr (haystack, needle))
           result |= 1;
       }
+    /* Free allocated memory, in case some sanitizer is watching.  */
+    free (haystack);
+    free (needle);
     return result;
     ]])],
         [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no],
index 9fd3db9ce578b60ba81bd44f99f03a071bf7f584..72e833490f54a906caa8866fcb745daebbf11e9f 100644 (file)
@@ -1,4 +1,4 @@
-# ungetc.m4 serial 3
+# ungetc.m4 serial 4
 dnl Copyright (C) 2009-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,19 +14,31 @@ AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
     [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 #include <stdio.h>
       ]], [FILE *f;
-           if (!(f = fopen ("conftest.tmp", "w+"))) return 1;
-           if (fputs ("abc", f) < 0) return 2;
+           if (!(f = fopen ("conftest.tmp", "w+")))
+             return 1;
+           if (fputs ("abc", f) < 0)
+             { fclose (f); return 2; }
            rewind (f);
-           if (fgetc (f) != 'a') return 3;
-           if (fgetc (f) != 'b') return 4;
-           if (ungetc ('d', f) != 'd') return 5;
-           if (ftell (f) != 1) return 6;
-           if (fgetc (f) != 'd') return 7;
-           if (ftell (f) != 2) return 8;
-           if (fseek (f, 0, SEEK_CUR) != 0) return 9;
-           if (ftell (f) != 2) return 10;
-           if (fgetc (f) != 'c') return 11;
-           fclose (f); remove ("conftest.tmp");])],
+           if (fgetc (f) != 'a')
+             { fclose (f); return 3; }
+           if (fgetc (f) != 'b')
+             { fclose (f); return 4; }
+           if (ungetc ('d', f) != 'd')
+             { fclose (f); return 5; }
+           if (ftell (f) != 1)
+             { fclose (f); return 6; }
+           if (fgetc (f) != 'd')
+             { fclose (f); return 7; }
+           if (ftell (f) != 2)
+             { fclose (f); return 8; }
+           if (fseek (f, 0, SEEK_CUR) != 0)
+             { fclose (f); return 9; }
+           if (ftell (f) != 2)
+             { fclose (f); return 10; }
+           if (fgetc (f) != 'c')
+             { fclose (f); return 11; }
+           fclose (f);
+           remove ("conftest.tmp");])],
         [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
         [case "$host_os" in
                    # Guess yes on glibc and bionic systems.