repo.or.cz
/
syslinux-debian
/
hramrach.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Adding upstream version 3.35.
[syslinux-debian/hramrach.git]
/
com32
/
lib
/
fgets.c
blob
474de49c71e3eb4fad014c748ad83ade5c35816b
1
/*
2
* fgets.c
3
*
4
* This will be very slow due to the implementation of getc(),
5
* but we can't afford to drain characters we don't need from
6
* the input.
7
*/
8
9
#include <stdio.h>
10
11
char
*
fgets
(
char
*
s
,
int
n
,
FILE
*
f
)
12
{
13
int
ch
;
14
char
*
p
=
s
;
15
16
while
(
n
>
1
) {
17
ch
=
getc
(
f
);
18
if
(
ch
==
EOF
) {
19
*
p
=
'\0'
;
20
return
(
p
==
s
) ?
NULL
:
s
;
21
}
22
*
p
++ =
ch
;
23
if
(
ch
==
'
\n
'
)
24
break
;
25
n
--;
26
}
27
if
(
n
)
28
*
p
=
'\0'
;
29
30
return
s
;
31
}