FreeCalypso > hg > ueda-linux
comparison ueda/libunet/unetrd.c @ 18:52000ae7a6cf
ueda/libunet/unetrd.c: close the stdio stream on EOF
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 02 Aug 2015 01:23:09 +0000 |
parents | faeb83c43f1c |
children | dda8e455c863 |
comparison
equal
deleted
inserted
replaced
17:e86258830e19 | 18:52000ae7a6cf |
---|---|
168 char *cp; | 168 char *cp; |
169 struct objmap *tp; | 169 struct objmap *tp; |
170 | 170 |
171 /* read lines until we get a non-empty, non-comment line or EOF */ | 171 /* read lines until we get a non-empty, non-comment line or EOF */ |
172 for (;;) { | 172 for (;;) { |
173 if (!fgets(linebuf, sizeof linebuf, state->stream)) | 173 if (!fgets(linebuf, sizeof linebuf, state->stream)) { |
174 fclose(state->stream); | |
174 return(0); | 175 return(0); |
176 } | |
175 state->lineno++; | 177 state->lineno++; |
176 cp = index(linebuf, '\n'); | 178 cp = index(linebuf, '\n'); |
177 if (!cp) { | 179 if (!cp) { |
178 fprintf(stderr, | 180 fprintf(stderr, |
179 "error: %s line %d is too long or unterminated\n", | 181 "error: %s line %d is too long or unterminated\n", |