scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 1#include <stdio.h>
 2
 3#undef fgets
 4
 5char *
 6fgets(char *restrict s, int n, FILE *restrict fp)
 7{
 8	int ch = 0;
 9	char *t = s;
10
11	for (--n; n > 0; --n) {
12		if ((ch = getc(fp)) == EOF)
13			break;
14		if ((*t++ = ch) == '\n')
15			break;
16	}
17	if (ch == EOF && s == t)
18		return NULL;
19	*t = '\0';
20
21	return s;
22}