mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Merge pull request #1139 from monarchdodra/stdio
Errors vs Exception in stdio
This commit is contained in:
commit
30d3d470e7
1 changed files with 8 additions and 7 deletions
15
std/stdio.d
15
std/stdio.d
|
@ -20,7 +20,7 @@ public import core.stdc.stdio, std.string : KeepTerminator;
|
|||
static import std.c.stdio;
|
||||
import std.stdiobase;
|
||||
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,
|
||||
std.range, std.string, std.traits, std.typecons,
|
||||
std.typetuple, std.utf;
|
||||
|
@ -1144,7 +1144,7 @@ to this file. */
|
|||
|
||||
|
||||
/// Range primitive operations.
|
||||
@property
|
||||
@property nothrow
|
||||
bool empty() const
|
||||
{
|
||||
return !file_.isOpen;
|
||||
|
@ -1152,9 +1152,10 @@ to this file. */
|
|||
|
||||
|
||||
/// Ditto
|
||||
@property
|
||||
nothrow ubyte[] front()
|
||||
@property nothrow
|
||||
ubyte[] front()
|
||||
{
|
||||
version(assert) if (empty) throw new RangeError();
|
||||
return chunk_;
|
||||
}
|
||||
|
||||
|
@ -1162,7 +1163,7 @@ to this file. */
|
|||
/// Ditto
|
||||
void popFront()
|
||||
{
|
||||
enforce(!empty, "Cannot call popFront on empty range");
|
||||
version(assert) if (empty) throw new RangeError();
|
||||
|
||||
chunk_ = file_.rawRead(chunk_);
|
||||
if (chunk_.length == 0)
|
||||
|
@ -1430,13 +1431,13 @@ struct LockingTextReader
|
|||
|
||||
@property dchar front()
|
||||
{
|
||||
enforce(!empty);
|
||||
version(assert) if (empty) throw new RangeError();
|
||||
return _crt;
|
||||
}
|
||||
|
||||
void popFront()
|
||||
{
|
||||
enforce(!empty);
|
||||
version(assert) if (empty) throw new RangeError();
|
||||
if (FGETC(cast(_iobuf*) _f._p.handle) == -1)
|
||||
{
|
||||
enforce(_f.eof);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue