diff options
author | Roland McGrath <roland@gnu.org> | 1994-05-24 00:38:51 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1994-05-24 00:38:51 +0000 |
commit | 1c5b73508d43752e03e3d9e59b43b91056ea26c6 (patch) | |
tree | 4fefeba721d1419b2d1148d35b7809a36c07d3b5 /stdio | |
parent | 8a760ce8c50691c86300a698e0023d4757365c33 (diff) |
entered into RCS
Diffstat (limited to 'stdio')
-rw-r--r-- | stdio/gets.c | 9 | ||||
-rw-r--r-- | stdio/vfprintf.c | 22 |
2 files changed, 17 insertions, 14 deletions
diff --git a/stdio/gets.c b/stdio/gets.c index 858683cc60..39fc452a73 100644 --- a/stdio/gets.c +++ b/stdio/gets.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994 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 @@ -53,7 +53,12 @@ DEFUN(gets, (s), char *s) *p++ = c; *p = '\0'; - if (p == s || ferror(stream)) + + /* Return null if we had an error, or if we got EOF + before writing any characters. */ + + if (ferror (stream) || (feof (stream) && p == s)) return NULL; + return s; } diff --git a/stdio/vfprintf.c b/stdio/vfprintf.c index e08eff9a1d..ff0ae740f0 100644 --- a/stdio/vfprintf.c +++ b/stdio/vfprintf.c @@ -28,6 +28,7 @@ Cambridge, MA 02139, USA. */ #include <stdlib.h> #include <string.h> #include <printf.h> +#include <assert.h> #include "_itoa.h" @@ -296,6 +297,15 @@ DEFUN(vfprintf, (s, format, args), /* double's are long double's, and int's are long long int's. */ is_long_double = 1; break; + + case 'Z': + /* int's are size_t's. */ +#ifdef HAVE_LONGLONG + assert (sizeof(size_t) <= sizeof(unsigned long long int)); + is_longlong = sizeof(size_t) > sizeof(unsigned long int); +#endif + is_long = sizeof(size_t) > sizeof(unsigned int); + break; } /* Format specification. */ @@ -322,18 +332,6 @@ DEFUN(vfprintf, (s, format, args), num = is_neg ? (- signed_num) : signed_num; goto number; - case 'Z': - /* `size_t' value. */ -#ifdef HAVE_LONGLONG - if (sizeof(size_t) > sizeof(unsigned long long int)) - __libc_fatal("`size_t' is bigger than any known type!"); - else - is_longlong = sizeof(size_t) > sizeof(unsigned long int); -#endif - is_long = sizeof(size_t) > sizeof(unsigned int); - - /* Fall through, to print a `size_t' as a decimal integer. */ - case 'u': /* Decimal unsigned integer. */ base = 10; |