about summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-10-14 20:56:52 +0000
committerJakub Jelinek <jakub@redhat.com>2007-10-14 20:56:52 +0000
commita33c43a5aefbbb2d1e00432ba034d256af0008ae (patch)
tree80aa9060de68814fb13960b308a0faa95fb8ba94 /libio
parent4cee966cabbbd52c38260dff95f5ab43772ba5d9 (diff)
downloadglibc-a33c43a5aefbbb2d1e00432ba034d256af0008ae.tar.gz
glibc-a33c43a5aefbbb2d1e00432ba034d256af0008ae.tar.xz
glibc-a33c43a5aefbbb2d1e00432ba034d256af0008ae.zip
Updated to fedora-glibc-20071014T1847
Diffstat (limited to 'libio')
-rw-r--r--libio/Makefile4
-rw-r--r--libio/__freading.c5
-rw-r--r--libio/ftello.c3
-rw-r--r--libio/tst-ext2.c58
4 files changed, 65 insertions, 5 deletions
diff --git a/libio/Makefile b/libio/Makefile
index 553fbda74a..31fac70cfd 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1995-2002,2003,2004,2006 Free Software Foundation, Inc.
+# Copyright (C) 1995-2002,2003,2004,2006,2007 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -48,7 +48,7 @@ routines	:=							      \
 	libc_fatal fmemopen
 
 tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc   \
-	tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-fopenloc	      \
+	tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 tst-fopenloc \
 	tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf	      \
 	tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof          \
 	tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
diff --git a/libio/__freading.c b/libio/__freading.c
index 37200bba78..43e50bce75 100644
--- a/libio/__freading.c
+++ b/libio/__freading.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -22,5 +22,6 @@ int
 __freading (FILE *fp)
 {
   return ((fp->_flags & _IO_NO_WRITES)
-	  || (fp->_flags & _IO_CURRENTLY_PUTTING) == 0);
+	  || ((fp->_flags & (_IO_CURRENTLY_PUTTING | _IO_NO_READS)) == 0
+	      && fp->_IO_read_base != NULL));
 }
diff --git a/libio/ftello.c b/libio/ftello.c
index e58daacad4..d250e55c04 100644
--- a/libio/ftello.c
+++ b/libio/ftello.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995-2001, 2002, 2003, 2004
+/* Copyright (C) 1993, 1995-2001, 2002, 2003, 2004, 2007
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -63,3 +63,4 @@ ftello (fp)
     }
   return pos;
 }
+libc_hidden_def (ftello)
diff --git a/libio/tst-ext2.c b/libio/tst-ext2.c
new file mode 100644
index 0000000000..ed72efa0c7
--- /dev/null
+++ b/libio/tst-ext2.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <stdio_ext.h>
+
+
+static char *fname;
+
+#define PREPARE(argc, argv) \
+  do {									\
+    int fd = create_temp_file ("tst-ext2", &fname);			\
+    if (fd == -1)							\
+      {									\
+	puts ("cannot create temporary file");				\
+	exit (1);							\
+      }									\
+    close (fd);								\
+  } while (0)
+
+
+static int
+do_test (void)
+{
+  int res = 0;
+
+  FILE *fp;
+
+  fp = fopen (fname, "w");
+  printf ("Initial state for write-only stream: %d %d\n",
+          __freading (fp) != 0, __fwriting (fp) != 0);
+  res |= ((__freading (fp) != 0) != 0
+	  || (__fwriting (fp) != 0) != 1);
+  fclose (fp);
+
+  fp = fopen (fname, "r");
+  printf ("Initial state for read-only stream:  %d %d\n",
+          __freading (fp) != 0, __fwriting (fp) != 0);
+  res |= ((__freading (fp) != 0) != 1
+	  || (__fwriting (fp) != 0) != 0);
+  fclose (fp);
+
+  fp = fopen (fname, "r+");
+  printf ("Initial state for read-write stream: %d %d\n",
+          __freading (fp) != 0, __fwriting (fp) != 0);
+  res |= ((__freading (fp) != 0) != 0
+	  || (__fwriting (fp) != 0) != 0);
+  fclose (fp);
+
+  fp = fopen (fname, "w+");
+  printf ("Initial state for read-write stream: %d %d\n",
+          __freading (fp) != 0, __fwriting (fp) != 0);
+  res |= ((__freading (fp) != 0) != 0
+	  || (__fwriting (fp) != 0) != 0);
+  fclose (fp);
+
+  return res;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"