Merge pull request #1139 from monarchdodra/stdio

Errors vs Exception in stdio
This commit is contained in:
Jonathan M Davis 2013-03-06 20:16:45 -08:00
commit 30d3d470e7

View file

@ -20,7 +20,7 @@ public import core.stdc.stdio, std.string : KeepTerminator;
static import std.c.stdio; static import std.c.stdio;
import std.stdiobase; import std.stdiobase;
import core.stdc.errno, core.stdc.stddef, core.stdc.stdlib, core.memory, import core.stdc.errno, core.stdc.stddef, core.stdc.stdlib, core.memory,
core.stdc.string, core.stdc.wchar_; core.stdc.string, core.stdc.wchar_, core.exception;
import std.algorithm, std.array, std.conv, std.exception, std.format, import std.algorithm, std.array, std.conv, std.exception, std.format,
std.range, std.string, std.traits, std.typecons, std.range, std.string, std.traits, std.typecons,
std.typetuple, std.utf; std.typetuple, std.utf;
@ -1144,7 +1144,7 @@ to this file. */
/// Range primitive operations. /// Range primitive operations.
@property @property nothrow
bool empty() const bool empty() const
{ {
return !file_.isOpen; return !file_.isOpen;
@ -1152,9 +1152,10 @@ to this file. */
/// Ditto /// Ditto
@property @property nothrow
nothrow ubyte[] front() ubyte[] front()
{ {
version(assert) if (empty) throw new RangeError();
return chunk_; return chunk_;
} }
@ -1162,7 +1163,7 @@ to this file. */
/// Ditto /// Ditto
void popFront() void popFront()
{ {
enforce(!empty, "Cannot call popFront on empty range"); version(assert) if (empty) throw new RangeError();
chunk_ = file_.rawRead(chunk_); chunk_ = file_.rawRead(chunk_);
if (chunk_.length == 0) if (chunk_.length == 0)
@ -1430,13 +1431,13 @@ struct LockingTextReader
@property dchar front() @property dchar front()
{ {
enforce(!empty); version(assert) if (empty) throw new RangeError();
return _crt; return _crt;
} }
void popFront() void popFront()
{ {
enforce(!empty); version(assert) if (empty) throw new RangeError();
if (FGETC(cast(_iobuf*) _f._p.handle) == -1) if (FGETC(cast(_iobuf*) _f._p.handle) == -1)
{ {
enforce(_f.eof); enforce(_f.eof);