From 294c975d49f5bd84f5867456b1a108eddfa3f450 Mon Sep 17 00:00:00 2001 From: Stefan Koch Date: Tue, 20 Feb 2018 14:35:52 +0100 Subject: [PATCH 1/3] Fix Imports to point to the actual symbols rather then wrongly imported ones. --- src/dfmt/globmatch_editorconfig.d | 5 +++-- src/dfmt/main.d | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dfmt/globmatch_editorconfig.d b/src/dfmt/globmatch_editorconfig.d index ac1106f..898460f 100644 --- a/src/dfmt/globmatch_editorconfig.d +++ b/src/dfmt/globmatch_editorconfig.d @@ -2,8 +2,9 @@ module dfmt.globmatch_editorconfig; import std.path : CaseSensitive; import std.range : isForwardRange, ElementEncodingType; -import std.string : isSomeChar, isSomeString, empty, save, front, popFront; -import std.typecons : Unqual; +import std.traits : isSomeChar, isSomeString; +import std.range.primitives : empty, save, front, popFront; +import std.traits : Unqual; import std.conv : to; import std.path : filenameCharCmp, isDirSeparator; diff --git a/src/dfmt/main.d b/src/dfmt/main.d index 7ed73b6..c59e3d8 100644 --- a/src/dfmt/main.d +++ b/src/dfmt/main.d @@ -188,7 +188,7 @@ else Config explicitConfig; if (explicitConfigDir) { - import std.path : exists, isDir; + import std.file : exists, isDir; if (!exists(explicitConfigDir) || !isDir(explicitConfigDir)) { From d04afa8ea7d942b01a7e8ec84cad98459a4a8287 Mon Sep 17 00:00:00 2001 From: Stefan Koch Date: Mon, 26 Feb 2018 11:18:02 +0100 Subject: [PATCH 2/3] Ignore empty files while formatting --- src/dfmt/main.d | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dfmt/main.d b/src/dfmt/main.d index c59e3d8..cde0956 100644 --- a/src/dfmt/main.d +++ b/src/dfmt/main.d @@ -265,11 +265,15 @@ else if (!config.isValid()) return 1; File f = File(path); - buffer = new ubyte[](cast(size_t) f.size); - f.rawRead(buffer); - if (inplace) - output = File(path, "wb"); - format(path, buffer, output.lockingTextWriter(), &config); + // ignore empty files + if (f.size) + { + buffer = new ubyte[](cast(size_t) f.size); + f.rawRead(buffer); + if (inplace) + output = File(path, "wb"); + format(path, buffer, output.lockingTextWriter(), &config); + } } } return 0; From 8333180e279f8f87b07f15b77bcb651d8dd568a9 Mon Sep 17 00:00:00 2001 From: Stefan Koch Date: Mon, 26 Feb 2018 11:18:33 +0100 Subject: [PATCH 3/3] Add empty test files --- tests/allman/empty.d.ref | 0 tests/empty.d | 0 tests/otbs/empty.d.ref | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/allman/empty.d.ref create mode 100644 tests/empty.d create mode 100644 tests/otbs/empty.d.ref diff --git a/tests/allman/empty.d.ref b/tests/allman/empty.d.ref new file mode 100644 index 0000000..e69de29 diff --git a/tests/empty.d b/tests/empty.d new file mode 100644 index 0000000..e69de29 diff --git a/tests/otbs/empty.d.ref b/tests/otbs/empty.d.ref new file mode 100644 index 0000000..e69de29