File:  [MW Coherent from dump] / coherent / b / lib / libc / stdio / gets.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * libc/stdio/gets.c
 * ANSI-compliant C standard i/o library.
 * gets()
 * ANSI 4.9.7.7.
 * Read string from stdin.
 * Do not retain newline.
 */

#include <stdio.h>

char *
gets(s) char *s;
{
	register c;
	register char *cp;

	cp = s;
	while ((c = getchar()) != EOF && c != '\n')
		*cp++ = c;
	if (c == EOF && (s == cp || ferror(stdin)))
		return NULL;		/* ANSI says leave *s unchanged */
	*cp = '\0';			/* else NUL-terminate */
	return s;
}

/* end of libc/stdio/gets.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.