repo.or.cz
/
minix3.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
at_wini also needs a pci_reserve() for the pci compatability device, if
[minix3.git]
/
lib
/
stdio
/
fgets.c
blob
1072a736b60e54aaafad8d324df01e6c463a5aa8
1
/*
2
* fgets.c - get a string from a file
3
*/
4
/* $Header$ */
5
6
#include <stdio.h>
7
8
char
*
9
fgets
(
char
*
s
,
register
int
n
,
register
FILE
*
stream
)
10
{
11
register
int
ch
;
12
register
char
*
ptr
;
13
14
ptr
=
s
;
15
while
(--
n
>
0
&& (
ch
=
getc
(
stream
)) !=
EOF
) {
16
*
ptr
++ =
ch
;
17
if
(
ch
==
'
\n
'
)
18
break
;
19
}
20
if
(
ch
==
EOF
) {
21
if
(
feof
(
stream
)) {
22
if
(
ptr
==
s
)
return
NULL
;
23
}
else return
NULL
;
24
}
25
*
ptr
=
'\0'
;
26
return
s
;
27
}