Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_unix/sys/src/libstdio/fgets.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/*
2
 * pANS stdio -- fgets
3
 */
4
#include "iolib.h"
5
char *fgets(char *as, int n, FILE *f){
6
	int c;
7
	char *s=as;
8
	c = EOF;
9
	while(n>1 && (c=getc(f))!=EOF){
10
		*s++=c;
11
		--n;
12
		if(c=='\n') break;
13
	}
14
	if(c==EOF && s==as
15
	|| ferror(f)) return NULL;
16
	if(n) *s='\0';
17
	return as;
18
}