Skip to content

Commit

Permalink
Fix return type of fgetwc
Browse files Browse the repository at this point in the history
It returns wint_t, not wchar_t.

This bug was fixed by Github user olehjalmar, I just applied the
patch: deadpixi#118
  • Loading branch information
japanoise committed Sep 9, 2023
1 parent 674a579 commit ef0a4cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sam/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ inputc(void)
terminp = termoutp = termline;
} else{
int olderr = errno;
r = fgetwc(stdin);
if (r == WEOF && errno == EILSEQ){
wint_t err;
r = err = fgetwc(stdin);
if (err = WEOF && errno == EILSEQ){
clearerr(stdin);
fflush(stdin);
fgetc(stdin);
Expand Down
5 changes: 3 additions & 2 deletions sam/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ readio(File *f, bool *nulls, bool setdate)

wchar_t buf[2] = {0};
while (true){
buf[0] = fgetwc(io);
if (buf[0] == WEOF){
wint_t err;
buf[0] = err = fgetwc(io);
if (err == WEOF){
if (errno == EILSEQ){
clearerr(io);
fflush(io);
Expand Down

0 comments on commit ef0a4cc

Please sign in to comment.