Skip to content

Commit

Permalink
fix for output not ending with newline
Browse files Browse the repository at this point in the history
  • Loading branch information
codekitchen committed Nov 30, 2019
1 parent edb2c80 commit 4ff2700
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void termput1(char *cmd, int arg1) {
// Read a single line from s and print it out. Once max_display_len is reached,
// keep scanning for the rest of the line but don't print anymore.
ssize_t read_line(FILE *s, size_t max_display_len) {
ssize_t display_len = 0;
ssize_t len = 0;
ssize_t display_len = 0; // number of printed columns
ssize_t len = 0; // number of chars read
for (;;) {
wchar_t c = fgetwc(s);
if (c == WEOF) {
Expand All @@ -72,6 +72,7 @@ ssize_t read_line(FILE *s, size_t max_display_len) {
return -1;
break;
}
++len;
if (c == L'\n')
break;
int c_len = wcwidth(c);
Expand Down

0 comments on commit 4ff2700

Please sign in to comment.