This commit is contained in:
Walter Bright 2009-05-12 21:31:39 +00:00
parent cf05d1909b
commit eceae92256

View file

@ -121,10 +121,15 @@ else version (GENERIC_IO)
void funlockfile(FILE*); void funlockfile(FILE*);
} }
alias fputc FPUTC; int fputc_unlocked(int c, _iobuf* fp) { return fputc(c, cast(shared) fp); }
alias fputwc FPUTWC; int fputwc_unlocked(wchar_t c, _iobuf* fp) { return fputwc(c, cast(shared) fp); }
alias fgetc FGETC; int fgetc_unlocked(_iobuf* fp) { return fgetc(cast(shared) fp); }
alias fgetwc FGETWC; int fgetwc_unlocked(_iobuf* fp) { return fgetwc(cast(shared) fp); }
alias fputc_unlocked FPUTC;
alias fputwc_unlocked FPUTWC;
alias fgetc_unlocked FGETC;
alias fgetwc_unlocked FGETWC;
alias flockfile FLOCK; alias flockfile FLOCK;
alias funlockfile FUNLOCK; alias funlockfile FUNLOCK;
@ -2076,9 +2081,10 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator = '\n')
} }
else version (GENERIC_IO) else version (GENERIC_IO)
{ {
FLOCK(fp); FLOCK(fps);
scope(exit) FUNLOCK(fp); scope(exit) FUNLOCK(fps);
if (fwide(fp, 0) > 0) auto fp = cast(_iobuf*)fps;
if (fwide(fps, 0) > 0)
{ /* Stream is in wide characters. { /* Stream is in wide characters.
* Read them and convert to chars. * Read them and convert to chars.
*/ */
@ -2123,7 +2129,7 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator = '\n')
if (c == terminator) if (c == terminator)
break; break;
} }
if (ferror(fp)) if (ferror(fps))
StdioException(); StdioException();
return buf.length; return buf.length;
} }
@ -2140,7 +2146,7 @@ private size_t readlnImpl(FILE* fps, ref char[] buf, dchar terminator = '\n')
if (c == terminator) if (c == terminator)
break; break;
} }
if (ferror(fp)) if (ferror(fps))
StdioException(); StdioException();
return buf.length; return buf.length;
} }