diff options
Diffstat (limited to 'stdio-common')
-rw-r--r-- | stdio-common/printf.c | 37 | ||||
-rw-r--r-- | stdio-common/sscanf.c | 34 | ||||
-rw-r--r-- | stdio-common/tmpfile.c | 32 | ||||
-rw-r--r-- | stdio-common/vfscanf.c | 36 |
4 files changed, 83 insertions, 56 deletions
diff --git a/stdio-common/printf.c b/stdio-common/printf.c index edb13da439..c92cd94d99 100644 --- a/stdio-common/printf.c +++ b/stdio-common/printf.c @@ -1,20 +1,20 @@ -/* Copyright (C) 1991, 1995 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* Copyright (C) 1991, 1995, 1996 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 -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. -The GNU C 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 -Library General Public License for more details. + The GNU C 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 + Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <stdarg.h> #include <stdio.h> @@ -22,8 +22,7 @@ Cambridge, MA 02139, USA. */ /* Write formatted output to stdout from the format string FORMAT. */ /* VARARGS1 */ int -printf (format) - const char *format; +printf (const char *format, ...) { va_list arg; int done; @@ -34,3 +33,9 @@ printf (format) return done; } + +#ifdef USE_IN_LIBIO +# undef _IO_printf +/* This is for libg++. */ +strong_alias (printf, _IO_printf); +#endif diff --git a/stdio-common/sscanf.c b/stdio-common/sscanf.c index d9c31bf32f..c1061523cb 100644 --- a/stdio-common/sscanf.c +++ b/stdio-common/sscanf.c @@ -1,20 +1,20 @@ -/* Copyright (C) 1991, 1995 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* Copyright (C) 1991, 1995, 1996 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 -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. -The GNU C 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 -Library General Public License for more details. + The GNU C 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 + Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <stdarg.h> #include <stdio.h> @@ -35,3 +35,9 @@ sscanf (s, format) return done; } + +#ifdef USE_IN_LIBIO +# undef _IO_sscanf +/* This is for libg++. */ +strong_alias (sscanf, _IO_sscanf) +#endif diff --git a/stdio-common/tmpfile.c b/stdio-common/tmpfile.c index 924df9b6bb..2cc03d6b89 100644 --- a/stdio-common/tmpfile.c +++ b/stdio-common/tmpfile.c @@ -1,20 +1,20 @@ /* Copyright (C) 1991, 1993, 1996 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 -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <stdio.h> diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index 7985602443..71945bbf2e 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -82,11 +82,16 @@ { \ /* Check file argument for consistence. */ \ CHECK_FILE (s, EOF); \ - if (s->_flags & _IO_NO_READS || format == NULL) \ - { \ - MAYBE_SET_EINVAL; \ - return EOF; \ - } \ + if (s->_flags & _IO_NO_READS) \ + { \ + __set_errno (EBADF); \ + return EOF; \ + } \ + else if (format == NULL) \ + { \ + MAYBE_SET_EINVAL; \ + return EOF; \ + } \ } while (0) # define LOCK_STREAM(S) \ __libc_cleanup_region_start ((void (*) (void *)) &_IO_funlockfile, (S)); \ @@ -117,7 +122,12 @@ do \ { \ /* Check file argument for consistence. */ \ - if (!__validfp (s) || !s->__mode.__read || format == NULL) \ + if (!__validfp (s) || !s->__mode.__read) \ + { \ + __set_errno (EBADF); \ + return EOF; \ + } \ + else if (format == NULL) \ { \ __set_errno (EINVAL); \ return EOF; \ @@ -159,7 +169,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr) register unsigned char fc; /* Current character of the format. */ register size_t done = 0; /* Assignments done. */ register size_t read_in = 0; /* Chars read in. */ - register int c; /* Last char read. */ + register int c = 0; /* Last char read. */ register int width; /* Maximum field width. */ register int flags; /* Modifiers for current format element. */ @@ -296,7 +306,8 @@ __vfscanf (FILE *s, const char *format, va_list argptr) if (skip_space) { while (isspace (c)) - (void) inchar (); + if (inchar () == EOF && errno == EINTR) + conv_error (); skip_space = 0; } @@ -409,13 +420,18 @@ __vfscanf (FILE *s, const char *format, va_list argptr) if (*f == '\0') conv_error (); + /* We must take care for EINTR errors. */ + if (c == EOF && errno == EINTR) + input_error (); + /* Find the conversion specifier. */ fc = *f++; - if (skip_space || (fc != '[' && fc != 'c' && fc != 'n')) + if (skip_space || (fc != '[' && fc != 'c' && fc != 'C' && fc != 'n')) { /* Eat whitespace. */ do - (void) inchar (); + if (inchar () == EOF && errno == EINTR) + input_error (); while (isspace (c)); ungetc (c, s); skip_space = 0; |