summaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-01-12 14:37:24 +0000
committerJakub Jelinek <jakub@redhat.com>2007-01-12 14:37:24 +0000
commit00e3dec8025c93ccde8ed810657e7f2115ddc8cb (patch)
tree30b8f6bdb08d364b986ae3ec3ec7664c520f0ad9 /libio
parentd6220e9ee38c1c9285221b023346201ec5f511b3 (diff)
downloadglibc-00e3dec8025c93ccde8ed810657e7f2115ddc8cb.tar
glibc-00e3dec8025c93ccde8ed810657e7f2115ddc8cb.tar.gz
glibc-00e3dec8025c93ccde8ed810657e7f2115ddc8cb.tar.bz2
glibc-00e3dec8025c93ccde8ed810657e7f2115ddc8cb.zip
* nis/nis_table.c (nis_list): If __follow_path fails in the new
code, make sure the nis_freeresult call doesn't crash and that the result is reported correctly. * nis/nis_table.c (nis_list): Handle FOLLOW_PATH | ALL_RESULTS when callback is NULL. * nis/Versions (libnss_nisplus): Add _nss_nisplus_initgroups_dyn@@GLIBC_PRIVATE. * nis/Makefile (libnss_nisplus-routines): Add nisplus-initgroups. * nis/nss_nisplus/nisplus-grp.c (tablename_val, tablename_len, _nss_create_tablename): Rename to... (grp_tablename_val, grp_tablename_len, _nss_grp_create_tablename): ... these. No longer static. (internal_setgrent): Adjust users. (_nss_nisplus_getgrnam_r, _nss_nisplus_getgrgid_r): Likewise. Don't use locking around _nss_grp_create_tablename call. * nis/nss_nisplus/nisplus-initgroups.c: New file.
Diffstat (limited to 'libio')
-rw-r--r--libio/Banner1
-rw-r--r--libio/Makefile3
-rw-r--r--libio/fileops.c11
-rw-r--r--libio/genops.c2
-rw-r--r--libio/libio.h1
-rw-r--r--libio/stdio.c10
-rw-r--r--libio/stdio.h41
-rw-r--r--libio/vswprintf.c2
-rw-r--r--libio/wfiledoalloc.c32
-rw-r--r--libio/wgenops.c8
-rw-r--r--libio/wmemstream.c2
-rw-r--r--libio/wstrops.c6
12 files changed, 68 insertions, 51 deletions
diff --git a/libio/Banner b/libio/Banner
new file mode 100644
index 0000000000..8ec3141927
--- /dev/null
+++ b/libio/Banner
@@ -0,0 +1 @@
+GNU libio by Per Bothner
diff --git a/libio/Makefile b/libio/Makefile
index 553fbda74a..0529744e3d 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -57,8 +57,7 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \
tst-memstream1 tst-memstream2 \
tst-wmemstream1 tst-wmemstream2 \
- bug-memstream1 bug-wmemstream1 \
- tst-setvbuf1
+ bug-memstream1 bug-wmemstream1
test-srcs = test-freopen
all: # Make this the default target; it will be defined in Rules.
diff --git a/libio/fileops.c b/libio/fileops.c
index dbd7a7a8f2..cf7fd65421 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -174,8 +174,14 @@ _IO_new_file_close_it (fp)
close_status = _IO_SYSCLOSE (fp);
/* Free buffer. */
+ if (fp->_mode <= 0)
+ {
+ INTUSE(_IO_setb) (fp, NULL, NULL, 0);
+ _IO_setg (fp, NULL, NULL, NULL);
+ _IO_setp (fp, NULL, NULL);
+ }
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
- if (fp->_mode > 0)
+ else
{
if (_IO_have_wbackup (fp))
INTUSE(_IO_free_wbackup_area) (fp);
@@ -184,9 +190,6 @@ _IO_new_file_close_it (fp)
_IO_wsetp (fp, NULL, NULL);
}
#endif
- INTUSE(_IO_setb) (fp, NULL, NULL, 0);
- _IO_setg (fp, NULL, NULL, NULL);
- _IO_setp (fp, NULL, NULL);
INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);
fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
diff --git a/libio/genops.c b/libio/genops.c
index 8d62da7781..5f223524a0 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -367,7 +367,7 @@ __uflow (fp)
#endif
if (fp->_mode == 0)
- _IO_fwide (fp, -1);
+ _IO_fwide (fp, -11);
if (_IO_in_put_mode (fp))
if (INTUSE(_IO_switch_to_get_mode) (fp) == EOF)
return EOF;
diff --git a/libio/libio.h b/libio/libio.h
index 428e035540..6f9c418c31 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -142,7 +142,6 @@
#ifdef _LIBC
# define _IO_FLAGS2_FORTIFY 4
#endif
-#define _IO_FLAGS2_USER_WBUF 8
/* These are "formatting flags" matching the iostream fmtflags enum values. */
#define _IO_SKIPWS 01
diff --git a/libio/stdio.c b/libio/stdio.c
index b2baf65be3..8dc24ed98f 100644
--- a/libio/stdio.c
+++ b/libio/stdio.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993,1994,1996,1997,2000,2002,2006
- Free Software Foundation, Inc.
+/* Copyright (C) 1993,1994,1996,1997,2000,2002 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
@@ -41,9 +40,14 @@ _IO_FILE *stderr = (FILE *) &_IO_2_1_stderr_;
#undef _IO_stderr
#ifdef _LIBC
# define AL(name) AL2 (name, _IO_##name)
-# define AL2(name, al) \
+# if defined HAVE_VISIBILITY_ATTRIBUTE
+# define AL2(name, al) \
extern __typeof (name) al __attribute__ ((alias (#name), \
visibility ("hidden")))
+# else
+# define AL2(name, al) \
+ extern __typeof (name) al __attribute__ ((alias (#name)))
+# endif
AL(stdin);
AL(stdout);
AL(stderr);
diff --git a/libio/stdio.h b/libio/stdio.h
index 3738e6d3b6..5e74305638 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -166,27 +166,27 @@ __BEGIN_NAMESPACE_STD
This function is a possible cancellation points and therefore not
marked with __THROW. */
#ifndef __USE_FILE_OFFSET64
-extern FILE *tmpfile (void) __wur;
+extern FILE *tmpfile (void);
#else
# ifdef __REDIRECT
-extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
+extern FILE *__REDIRECT (tmpfile, (void), tmpfile64);
# else
# define tmpfile tmpfile64
# endif
#endif
#ifdef __USE_LARGEFILE64
-extern FILE *tmpfile64 (void) __wur;
+extern FILE *tmpfile64 (void);
#endif
/* Generate a temporary filename. */
-extern char *tmpnam (char *__s) __THROW __wur;
+extern char *tmpnam (char *__s) __THROW;
__END_NAMESPACE_STD
#ifdef __USE_MISC
/* This is the reentrant variant of `tmpnam'. The only difference is
that it does not allow S to be NULL. */
-extern char *tmpnam_r (char *__s) __THROW __wur;
+extern char *tmpnam_r (char *__s) __THROW;
#endif
@@ -199,7 +199,7 @@ extern char *tmpnam_r (char *__s) __THROW __wur;
P_tmpdir is tried and finally "/tmp". The storage for the filename
is allocated by `malloc'. */
extern char *tempnam (__const char *__dir, __const char *__pfx)
- __THROW __attribute_malloc__ __wur;
+ __THROW __attribute_malloc__;
#endif
@@ -244,23 +244,21 @@ __BEGIN_NAMESPACE_STD
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern FILE *fopen (__const char *__restrict __filename,
- __const char *__restrict __modes) __wur;
+ __const char *__restrict __modes);
/* Open a file, replacing an existing stream with it.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern FILE *freopen (__const char *__restrict __filename,
__const char *__restrict __modes,
- FILE *__restrict __stream) __wur;
+ FILE *__restrict __stream);
#else
# ifdef __REDIRECT
extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
- __const char *__restrict __modes), fopen64)
- __wur;
+ __const char *__restrict __modes), fopen64);
extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
__const char *__restrict __modes,
- FILE *__restrict __stream), freopen64)
- __wur;
+ FILE *__restrict __stream), freopen64);
# else
# define fopen fopen64
# define freopen freopen64
@@ -269,15 +267,15 @@ extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
__END_NAMESPACE_STD
#ifdef __USE_LARGEFILE64
extern FILE *fopen64 (__const char *__restrict __filename,
- __const char *__restrict __modes) __wur;
+ __const char *__restrict __modes);
extern FILE *freopen64 (__const char *__restrict __filename,
__const char *__restrict __modes,
- FILE *__restrict __stream) __wur;
+ FILE *__restrict __stream);
#endif
#ifdef __USE_POSIX
/* Create a new stream that refers to an existing system file descriptor. */
-extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
+extern FILE *fdopen (int __fd, __const char *__modes) __THROW;
#endif
#ifdef __USE_GNU
@@ -285,16 +283,15 @@ extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
and uses the given functions for input and output. */
extern FILE *fopencookie (void *__restrict __magic_cookie,
__const char *__restrict __modes,
- _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
+ _IO_cookie_io_functions_t __io_funcs) __THROW;
/* Create a new stream that refers to a memory buffer. */
-extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
- __THROW __wur;
+extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW;
/* Open a stream that writes into a malloc'd buffer that is expanded as
necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
and the number of characters written on fflush or fclose. */
-extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
+extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW;
#endif
@@ -370,13 +367,13 @@ __END_NAMESPACE_C99
Store the address of the string in *PTR. */
extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
_G_va_list __arg)
- __THROW __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
+ __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
extern int __asprintf (char **__restrict __ptr,
__const char *__restrict __fmt, ...)
- __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
+ __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
extern int asprintf (char **__restrict __ptr,
__const char *__restrict __fmt, ...)
- __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
+ __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
/* Write formatted output to a file descriptor.
diff --git a/libio/vswprintf.c b/libio/vswprintf.c
index e9a316a01c..5bbd20227b 100644
--- a/libio/vswprintf.c
+++ b/libio/vswprintf.c
@@ -119,7 +119,7 @@ _IO_vswprintf (string, maxlen, format, args)
if (sf.f._sbf._f._wide_data->_IO_buf_base == sf.overflow_buf)
/* ISO C99 requires swprintf/vswprintf to return an error if the
- output does not fit in the provided buffer. */
+ output does not fit int he provided buffer. */
return -1;
/* Terminate the string. */
diff --git a/libio/wfiledoalloc.c b/libio/wfiledoalloc.c
index 67a05175b2..2f8140b0ac 100644
--- a/libio/wfiledoalloc.c
+++ b/libio/wfiledoalloc.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1997, 1999, 2000, 2002, 2006
- Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997, 1999, 2000, 2002 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
@@ -86,20 +85,35 @@ _IO_wfile_doallocate (fp)
_IO_FILE *fp;
{
_IO_size_t size;
+ int couldbetty;
wchar_t *p;
+ struct _G_stat64 st;
/* Allocate room for the external buffer. */
if (fp->_IO_buf_base == NULL)
INTUSE(_IO_file_doallocate) (fp);
- /* If narrow buffer is user allocated (set by setvbuf etc.),
- use that size as the size of the wide buffer, when it is
- allocated by _IO_file_doallocate, multiply that by size
- of the wide character. */
- size = fp->_IO_buf_end - fp->_IO_buf_base;
- if ((fp->_flags & _IO_USER_BUF))
- size = (size + sizeof (wchar_t) - 1) / sizeof (wchar_t);
+ if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0)
+ {
+ couldbetty = 0;
+ size = _IO_BUFSIZ;
+#if 0
+ /* do not try to optimise fseek() */
+ fp->_flags |= __SNPT;
+#endif
+ }
+ else
+ {
+ couldbetty = S_ISCHR (st.st_mode);
+#if _IO_HAVE_ST_BLKSIZE
+ size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize;
+#else
+ size = _IO_BUFSIZ;
+#endif
+ }
ALLOC_WBUF (p, size * sizeof (wchar_t), EOF);
INTUSE(_IO_wsetb) (fp, p, p + size, 1);
+ if (couldbetty && isatty (fp->_fileno))
+ fp->_flags |= _IO_LINE_BUF;
return 1;
}
diff --git a/libio/wgenops.c b/libio/wgenops.c
index 760a413dc3..355fd2603d 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -115,14 +115,14 @@ _IO_wsetb (f, b, eb, a)
wchar_t *eb;
int a;
{
- if (f->_wide_data->_IO_buf_base && !(f->_flags2 & _IO_FLAGS2_USER_WBUF))
+ if (f->_wide_data->_IO_buf_base && !(f->_flags & _IO_USER_BUF))
FREE_BUF (f->_wide_data->_IO_buf_base, _IO_wblen (f) * sizeof (wchar_t));
f->_wide_data->_IO_buf_base = b;
f->_wide_data->_IO_buf_end = eb;
if (a)
- f->_flags2 &= ~_IO_FLAGS2_USER_WBUF;
+ f->_flags &= ~_IO_USER_BUF;
else
- f->_flags2 |= _IO_FLAGS2_USER_WBUF;
+ f->_flags |= _IO_USER_BUF;
}
INTDEF(_IO_wsetb)
@@ -198,7 +198,7 @@ _IO_wdefault_finish (fp, dummy)
int dummy;
{
struct _IO_marker *mark;
- if (fp->_wide_data->_IO_buf_base && !(fp->_flags2 & _IO_FLAGS2_USER_WBUF))
+ if (fp->_wide_data->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
{
FREE_BUF (fp->_wide_data->_IO_buf_base,
_IO_wblen (fp) * sizeof (wchar_t));
diff --git a/libio/wmemstream.c b/libio/wmemstream.c
index 7bf6a429ac..577931888d 100644
--- a/libio/wmemstream.c
+++ b/libio/wmemstream.c
@@ -92,7 +92,7 @@ open_wmemstream (bufloc, sizeloc)
_IO_fwide (&new_f->fp._sf._sbf._f, 1);
_IO_wstr_init_static (&new_f->fp._sf._sbf._f, buf,
_IO_BUFSIZ / sizeof (wchar_t), buf);
- new_f->fp._sf._sbf._f._flags2 &= ~_IO_FLAGS2_USER_WBUF;
+ new_f->fp._sf._sbf._f._flags &= ~_IO_USER_BUF;
new_f->fp._sf._s._allocate_buffer = (_IO_alloc_type) malloc;
new_f->fp._sf._s._free_buffer = (_IO_free_type) free;
diff --git a/libio/wstrops.c b/libio/wstrops.c
index c5aae7bc6a..8b862fb989 100644
--- a/libio/wstrops.c
+++ b/libio/wstrops.c
@@ -88,7 +88,7 @@ _IO_wstr_overflow (fp, c)
pos = fp->_wide_data->_IO_write_ptr - fp->_wide_data->_IO_write_base;
if (pos >= (_IO_size_t) (_IO_wblen (fp) + flush_only))
{
- if (fp->_flags2 & _IO_FLAGS2_USER_WBUF) /* not allowed to enlarge */
+ if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */
return WEOF;
else
{
@@ -182,7 +182,7 @@ enlarge_userbuf (_IO_FILE *fp, _IO_off64_t offset, int reading)
_IO_ssize_t oldend = wd->_IO_write_end - wd->_IO_write_base;
/* Try to enlarge the buffer. */
- if (fp->_flags2 & _IO_FLAGS2_USER_WBUF)
+ if (fp->_flags & _IO_USER_BUF)
/* User-provided buffer. */
return 1;
@@ -335,7 +335,7 @@ _IO_wstr_finish (fp, dummy)
_IO_FILE *fp;
int dummy;
{
- if (fp->_wide_data->_IO_buf_base && !(fp->_flags2 & _IO_FLAGS2_USER_WBUF))
+ if (fp->_wide_data->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
(((_IO_strfile *) fp)->_s._free_buffer) (fp->_wide_data->_IO_buf_base);
fp->_wide_data->_IO_buf_base = NULL;