Skip to content

Commit b65d515

Browse files
committed
handle noeol file ending
closes #154
1 parent 283cb52 commit b65d515

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

include/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525

2626
#define MDP_VER_MAJOR 1
2727
#define MDP_VER_MINOR 0
28-
#define MDP_VER_REVISION 16
28+
#define MDP_VER_REVISION 17
2929

3030
#endif // !defined( MAIN_H )

src/parser.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ deck_t *markdown_load(FILE *input, int noexpand) {
119119
// initialize bits as empty line
120120
SET_BIT(bits, IS_EMPTY);
121121

122-
while ((c = fgetwc(input)) != WEOF) {
122+
for (;;) {
123+
c = fgetwc(input);
123124
if (ferror(input)) {
124125
fprintf(stderr, "markdown_load() failed to read input: %s\n", strerror(errno));
125126
exit(EXIT_FAILURE);
126127
}
127128

128-
if(c == L'\n') {
129+
if(c == L'\n' || c == WEOF) {
129130

130131
// markdown analyse
131132
prev = bits;
@@ -230,6 +231,10 @@ deck_t *markdown_load(FILE *input, int noexpand) {
230231
// add char to line
231232
(text->expand)(text, c);
232233
}
234+
235+
if (c == WEOF) {
236+
break;
237+
}
233238
}
234239
(text->delete)(text);
235240

0 commit comments

Comments
 (0)