Skip to content

Commit

Permalink
Merge branch 'windows_read_stdin_line_ending'
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
  • Loading branch information
dlenski committed Mar 30, 2020
2 parents 6f1240f + 1ec900d commit e4b2297
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.c
Expand Up @@ -408,8 +408,13 @@ static void read_stdin(char **string, int hidden, int allow_fail)
nr_read = wcslen(wbuf);
}
if (nr_read >= 2 && wbuf[nr_read - 1] == 10 && wbuf[nr_read - 2] == 13) {
/* remove trailing "\r\n" */
wbuf[nr_read - 2] = 0;
nr_read -= 2;
} else if (nr_read >= 1 && wbuf[nr_read - 1] == 10) {
/* remove trailing "\n" */
wbuf[nr_read - 1] = 0;
nr_read -= 1;
}

nr_read = WideCharToMultiByte(CP_UTF8, 0, wbuf, -1, NULL, 0, NULL, NULL);
Expand Down

0 comments on commit e4b2297

Please sign in to comment.