Deleted Added
full compact
gets.c (92986) gets.c (101776)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 24 unchanged lines hidden (view full) ---

33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93";
39#endif /* LIBC_SCCS and not lint */
40#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 24 unchanged lines hidden (view full) ---

33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93";
39#endif /* LIBC_SCCS and not lint */
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD: head/lib/libc/stdio/gets.c 92986 2002-03-22 21:53:29Z obrien $");
41__FBSDID("$FreeBSD: head/lib/libc/stdio/gets.c 101776 2002-08-13 09:30:41Z tjr $");
42
43#include "namespace.h"
44#include <unistd.h>
45#include <stdio.h>
46#include <sys/cdefs.h>
47#include "un-namespace.h"
48
49__warn_references(gets, "warning: this program uses gets(), which is unsafe.");
50
51char *
52gets(buf)
53 char *buf;
54{
55 int c;
56 char *s;
57 static int warned;
58 static char w[] =
59 "warning: this program uses gets(), which is unsafe.\n";
60
42
43#include "namespace.h"
44#include <unistd.h>
45#include <stdio.h>
46#include <sys/cdefs.h>
47#include "un-namespace.h"
48
49__warn_references(gets, "warning: this program uses gets(), which is unsafe.");
50
51char *
52gets(buf)
53 char *buf;
54{
55 int c;
56 char *s;
57 static int warned;
58 static char w[] =
59 "warning: this program uses gets(), which is unsafe.\n";
60
61 /* Orientation set by getchar(). */
62
61 if (!warned) {
62 (void) _write(STDERR_FILENO, w, sizeof(w) - 1);
63 warned = 1;
64 }
65 for (s = buf; (c = getchar()) != '\n';)
66 if (c == EOF)
67 if (s == buf)
68 return (NULL);
69 else
70 break;
71 else
72 *s++ = c;
73 *s = 0;
74 return (buf);
75}
63 if (!warned) {
64 (void) _write(STDERR_FILENO, w, sizeof(w) - 1);
65 warned = 1;
66 }
67 for (s = buf; (c = getchar()) != '\n';)
68 if (c == EOF)
69 if (s == buf)
70 return (NULL);
71 else
72 break;
73 else
74 *s++ = c;
75 *s = 0;
76 return (buf);
77}