Merge pull request #169 from Herringway/safe-scanner

make rest of dyaml.scanner @safe
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2018-06-16 08:28:45 +02:00 committed by GitHub
commit deb56415e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -415,7 +415,7 @@ final class Scanner
/// Decrease indentation, removing entries in indents_. /// Decrease indentation, removing entries in indents_.
/// ///
/// Params: column = Current column in the file/stream. /// Params: column = Current column in the file/stream.
void unwindIndent(const int column) @trusted void unwindIndent(const int column) @safe
{ {
if(flowLevel_ > 0) if(flowLevel_ > 0)
{ {
@ -451,7 +451,7 @@ final class Scanner
/// Params: column = Current column in the file/stream. /// Params: column = Current column in the file/stream.
/// ///
/// Returns: true if the indentation was increased, false otherwise. /// Returns: true if the indentation was increased, false otherwise.
bool addIndent(int column) @trusted bool addIndent(int column) @safe
{ {
if(indent_ >= column){return false;} if(indent_ >= column){return false;}
indents_ ~= indent_; indents_ ~= indent_;
@ -1963,7 +1963,7 @@ final class Scanner
// //
// Returns the number of bytes used by the dchar in bytes on success, // Returns the number of bytes used by the dchar in bytes on success,
// size_t.max on failure. // size_t.max on failure.
static size_t getDchar(char[] bytes, Reader reader_) @trusted static size_t getDchar(char[] bytes, Reader reader_) @safe
{ {
size_t nextChar; size_t nextChar;
dchar c; dchar c;
@ -1979,8 +1979,7 @@ final class Scanner
reader_.sliceBuilder.write(c); reader_.sliceBuilder.write(c);
if(bytes.length - nextChar > 0) if(bytes.length - nextChar > 0)
{ {
core.stdc.string.memmove(&bytes[0], &bytes[nextChar], copy(bytes[nextChar..bytes.length], bytes[0..bytes.length-nextChar]);
bytes.length - nextChar);
} }
return bytes.length - nextChar; return bytes.length - nextChar;
} }