gets.c (50476) | gets.c (55837) |
---|---|
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 --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#if defined(LIBC_SCCS) && !defined(lint) 38#if 0 39static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93"; 40#endif 41static const char rcsid[] = | 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 --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#if defined(LIBC_SCCS) && !defined(lint) 38#if 0 39static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93"; 40#endif 41static const char rcsid[] = |
42 "$FreeBSD: head/lib/libc/stdio/gets.c 50476 1999-08-28 00:22:10Z peter $"; | 42 "$FreeBSD: head/lib/libc/stdio/gets.c 55837 2000-01-12 09:23:48Z jasone $"; |
43#endif /* LIBC_SCCS and not lint */ 44 45#include <unistd.h> 46#include <stdio.h> 47#include <sys/cdefs.h> 48 49__warn_references(gets, "warning: this program uses gets(), which is unsafe."); 50 51char * 52gets(buf) 53 char *buf; 54{ 55 register int c; 56 register char *s; 57 static int warned; 58 static char w[] = 59 "warning: this program uses gets(), which is unsafe.\n"; 60 61 if (!warned) { | 43#endif /* LIBC_SCCS and not lint */ 44 45#include <unistd.h> 46#include <stdio.h> 47#include <sys/cdefs.h> 48 49__warn_references(gets, "warning: this program uses gets(), which is unsafe."); 50 51char * 52gets(buf) 53 char *buf; 54{ 55 register int c; 56 register char *s; 57 static int warned; 58 static char w[] = 59 "warning: this program uses gets(), which is unsafe.\n"; 60 61 if (!warned) { |
62 (void) write(STDERR_FILENO, w, sizeof(w) - 1); | 62 (void) _libc_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 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} |