Skip to content

Commit

Permalink
Fixes for f(get|put)[w]c
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Forsberg committed Apr 7, 2021
1 parent f215dfb commit 38a17d5
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions libphobos/libdruntime/core/stdc/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ else version (CRuntime_Microsoft)
private int _flsbuf(int, FILE*);

///
int _fputc_nolock()(int c, FILE* fp)
int _fputc_nolock(int c, FILE* fp)
{
pragma(inline, true);
fp._cnt = fp._cnt - 1;
Expand All @@ -1441,7 +1441,38 @@ else version (CRuntime_Microsoft)
return _flsbuf(c, fp);
}
///
int _fgetc_nolock()(FILE* fp)
int _fgetc_nolock(FILE* fp)
{
pragma(inline, true);
fp._cnt = fp._cnt - 1;
if (fp._cnt >= 0)
{
immutable ch = *fp._ptr;
fp._ptr = fp._ptr + 1;
return ch & 0xFF;
}
else
return _filbuf(fp);
}

///_fputwc_nolock
int _fputwc_nolock(int c, FILE* fp)
{
pragma(inline, true);
fp._cnt = fp._cnt - 1;
if (fp._cnt >= 0)
{
immutable ch = cast(char)c;
*fp._ptr = ch;
fp._ptr = fp._ptr + 1;
return ch & 0xFF;
}
else
return _flsbuf(c, fp);
}

///
int _fgetwc_nolock(FILE* fp)
{
pragma(inline, true);
fp._cnt = fp._cnt - 1;
Expand Down

0 comments on commit 38a17d5

Please sign in to comment.