/* Process the known entries of the file. Comments start with `#' and
end with the end of the line. Empty lines are ignored. */
- while (!feof (fp))
+ while (!feof_unlocked (fp))
{
char *rp, *endp, *word;
ssize_t n = __getdelim (&line, &line_len, '\n', fp);
int c;
struct toktab *t;
- if (feof(cfile) || ferror(cfile))
+ if (feof_unlocked(cfile) || ferror_unlocked(cfile))
return (0);
while ((c = getc_unlocked(cfile)) != EOF &&
(c == '\n' || c == '\t' || c == ' ' || c == ','))
# define alloca(size) (malloc (size))
#endif /* have alloca */
+#if defined _LIBC || defined HAVE_FGETS_UNLOCKED
+# undef fgets
+# define fgets(buf, len, s) fgets_unlocked (buf, len, s)
+#endif
+#if defined _LIBC || defined HAVE_FEOF_UNLOCKED
+# undef feof
+# define feof(s) feof_unlocked (s)
+#endif
+
struct alias_map
{
clearerr feof ferror fgetc fileno fputc freopen fseek getc getchar \
memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \
iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello \
- freopen64 fseeko64 ftello64 iofread_u iofwrite_u \
+ freopen64 fseeko64 ftello64 \
\
libc_fatal
ifneq (,$(filter %REENTRANT, $(defines)))
routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \
- iofflush_u putc_u putchar_u peekc
+ iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u
CPPFLAGS += -D_IO_MTSAFE_IO
endif
# f*
fgetpos64; fopen64; freopen64; fseeko; fseeko64; fsetpos64; ftello;
ftello64; fopen; fclose; fdopen; fread_unlocked; fwrite_unlocked;
+ fgets_unlocked;
}
}
--- /dev/null
+/* Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include <stdio.h>
+
+char *
+fgets_unlocked (buf, n, fp)
+ char *buf;
+ int n;
+ _IO_FILE *fp;
+{
+ _IO_size_t count;
+ char *result;
+ int old_error;
+ CHECK_FILE (fp, NULL);
+ if (n <= 0)
+ return NULL;
+ /* This is very tricky since a file descriptor may be in the
+ non-blocking mode. The error flag doesn't mean much in this
+ case. We return an error only when there is a new error. */
+ old_error = fp->_IO_file_flags & _IO_ERR_SEEN;
+ fp->_IO_file_flags &= ~_IO_ERR_SEEN;
+ count = _IO_getline (fp, buf, n - 1, '\n', 1);
+ if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN))
+ result = NULL;
+ else
+ {
+ buf[count] = '\0';
+ result = buf;
+ }
+ fp->_IO_file_flags |= old_error;
+ return result;
+}
extern char *fgets __P ((char *__restrict __s, int __n,
FILE *__restrict __stream));
+#ifdef __USE_GNU
+/* This function does the same as `fgets' but does not lock the stream. */
+extern char *fgets_unlocked __P ((char *__restrict __s, int __n,
+ FILE *__restrict __stream));
+#endif
+
/* Get a newline-terminated string from stdin, removing the newline.
DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. */
extern char *gets __P ((char *__s));
+1998-07-05 11:54 Ulrich Drepper <drepper@cygnus.com>
+
+ * Versions: Add pthread_attr_init ti GLIBC_2.1 version in libc.
+
1998-07-01 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* attr.c: Include <string.h>.
pthread_self; pthread_setcancelstate; pthread_setcanceltype;
pthread_setschedparam;
}
+ GLIBC_2.1 {
+ pthread_attr_init;
+ }
}
libpthread {