From b2cd2e29142bd3b3bcc1735eb41384d472b15932 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 26 Apr 2016 20:57:28 +0300 Subject: [PATCH] std.digest style fix: space between operators --- std/digest/crc.d | 2 +- std/digest/digest.d | 40 ++++++++++++++++++++-------------------- std/digest/md.d | 2 +- std/digest/ripemd.d | 2 +- std/digest/sha.d | 38 +++++++++++++++++++------------------- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/std/digest/crc.d b/std/digest/crc.d index 930cbb84f3c..e768fd4504f 100644 --- a/std/digest/crc.d +++ b/std/digest/crc.d @@ -252,7 +252,7 @@ unittest { //Let's use the template features: //Note: When passing a CRC32 to a function, it must be passed by reference! - void doSomething(T)(ref T hash) if(isDigest!T) + void doSomething(T)(ref T hash) if (isDigest!T) { hash.put(cast(ubyte)0); } diff --git a/std/digest/digest.d b/std/digest/digest.d index e10021bdd16..983aa70d996 100644 --- a/std/digest/digest.d +++ b/std/digest/digest.d @@ -92,7 +92,7 @@ unittest import std.stdio; // Digests a file and prints the result. - void digestFile(Hash)(string filename) if(isDigest!Hash) + void digestFile(Hash)(string filename) if (isDigest!Hash) { auto file = File(filename); auto result = digest!Hash(file.byChunk(4096 * 1024)); @@ -116,7 +116,7 @@ unittest import std.digest.crc, std.digest.sha, std.digest.md; import std.stdio; // Digests a file and prints the result. - void digestFile(Hash)(ref Hash hash, string filename) if(isDigest!Hash) + void digestFile(Hash)(ref Hash hash, string filename) if (isDigest!Hash) { File file = File(filename); @@ -303,7 +303,7 @@ unittest unittest { import std.digest.crc; - void myFunction(T)() if(isDigest!T) + void myFunction(T)() if (isDigest!T) { T dig; dig.start(); @@ -317,7 +317,7 @@ unittest */ template DigestType(T) { - static if(isDigest!T) + static if (isDigest!T) { alias DigestType = ReturnType!(typeof( @@ -377,7 +377,7 @@ unittest unittest { import std.digest.crc; - void myFunction(T)() if(hasPeek!T) + void myFunction(T)() if (hasPeek!T) { T dig; dig.start(); @@ -424,7 +424,7 @@ package template isDigestibleRange(Range) * Params: * range= an $(D InputRange) with $(D ElementType) $(D ubyte), $(D ubyte[]) or $(D ubyte[num]) */ -DigestType!Hash digest(Hash, Range)(auto ref Range range) if(!isArray!Range +DigestType!Hash digest(Hash, Range)(auto ref Range range) if (!isArray!Range && isDigestibleRange!Range) { import std.algorithm : copy; @@ -449,11 +449,11 @@ unittest * Params: * data= one or more arrays of any type */ -DigestType!Hash digest(Hash, T...)(scope const T data) if(allSatisfy!(isArray, typeof(data))) +DigestType!Hash digest(Hash, T...)(scope const T data) if (allSatisfy!(isArray, typeof(data))) { Hash hash; hash.start(); - foreach(datum; data) + foreach (datum; data) hash.put(cast(const(ubyte[]))datum); return hash.finish(); } @@ -486,7 +486,7 @@ unittest * range= an $(D InputRange) with $(D ElementType) $(D ubyte), $(D ubyte[]) or $(D ubyte[num]) */ char[digestLength!(Hash)*2] hexDigest(Hash, Order order = Order.increasing, Range)(ref Range range) - if(!isArray!Range && isDigestibleRange!Range) + if (!isArray!Range && isDigestibleRange!Range) { return toHexString!order(digest!Hash(range)); } @@ -508,7 +508,7 @@ unittest * data= one or more arrays of any type */ char[digestLength!(Hash)*2] hexDigest(Hash, Order order = Order.increasing, T...)(scope const T data) - if(allSatisfy!(isArray, typeof(data))) + if (allSatisfy!(isArray, typeof(data))) { return toHexString!order(digest!Hash(data)); } @@ -611,7 +611,7 @@ interface Digest final @trusted nothrow ubyte[] digest(scope const(void[])[] data...) { this.reset(); - foreach(datum; data) + foreach (datum; data) this.put(cast(ubyte[])datum); return this.finish(); } @@ -713,9 +713,9 @@ char[num*2] toHexString(Order order = Order.increasing, size_t num, LetterCase l char[num*2] result; size_t i; - static if(order == Order.increasing) + static if (order == Order.increasing) { - foreach(u; digest) + foreach (u; digest) { result[i++] = hexDigits[u >> 4]; result[i++] = hexDigits[u & 15]; @@ -724,7 +724,7 @@ char[num*2] toHexString(Order order = Order.increasing, size_t num, LetterCase l else { size_t j = num - 1; - while(i < num*2) + while (i < num*2) { result[i++] = hexDigits[digest[j] >> 4]; result[i++] = hexDigits[digest[j] & 15]; @@ -756,9 +756,9 @@ string toHexString(Order order = Order.increasing, LetterCase letterCase = Lette auto result = new char[digest.length*2]; size_t i; - static if(order == Order.increasing) + static if (order == Order.increasing) { - foreach(u; digest) + foreach (u; digest) { result[i++] = hexDigits[u >> 4]; result[i++] = hexDigits[u & 15]; @@ -767,7 +767,7 @@ string toHexString(Order order = Order.increasing, LetterCase letterCase = Lette else { import std.range : retro; - foreach(u; retro(digest)) + foreach (u; retro(digest)) { result[i++] = hexDigits[u >> 4]; result[i++] = hexDigits[u & 15]; @@ -838,7 +838,7 @@ ref T[N] asArray(size_t N, T)(ref T[] source, string errorMsg = "") * useful for other purposes as well. It returns the length (in bytes) of the hash value * produced by T. */ -template digestLength(T) if(isDigest!T) +template digestLength(T) if (isDigest!T) { enum size_t digestLength = (ReturnType!(T.finish)).length; } @@ -848,7 +848,7 @@ template digestLength(T) if(isDigest!T) * Modules providing digest implementations will usually provide * an alias for this template (e.g. MD5Digest, SHA1Digest, ...). */ -class WrapperDigest(T) if(isDigest!T) : Digest +class WrapperDigest(T) if (isDigest!T) : Digest { protected: T _digest; @@ -943,7 +943,7 @@ class WrapperDigest(T) if(isDigest!T) : Digest ///ditto @trusted ubyte[] peek() const; } - else static if(hasPeek!T) + else static if (hasPeek!T) { @trusted ubyte[] peek(scope ubyte[] buf) const in diff --git a/std/digest/md.d b/std/digest/md.d index 7f28bff4e0b..da6159e37d2 100644 --- a/std/digest/md.d +++ b/std/digest/md.d @@ -428,7 +428,7 @@ unittest unittest { //Let's use the template features: - void doSomething(T)(ref T hash) if(isDigest!T) + void doSomething(T)(ref T hash) if (isDigest!T) { hash.put(cast(ubyte)0); } diff --git a/std/digest/ripemd.d b/std/digest/ripemd.d index 19881e66b1c..2dd2b060643 100644 --- a/std/digest/ripemd.d +++ b/std/digest/ripemd.d @@ -586,7 +586,7 @@ unittest unittest { //Let's use the template features: - void doSomething(T)(ref T hash) if(isDigest!T) + void doSomething(T)(ref T hash) if (isDigest!T) { hash.put(cast(ubyte)0); } diff --git a/std/digest/sha.d b/std/digest/sha.d index 82dd0b1679d..e81a37afd51 100644 --- a/std/digest/sha.d +++ b/std/digest/sha.d @@ -213,7 +213,7 @@ struct SHA(uint hashBlockSize, uint digestSize) static assert(!(blockSize == 1024 && digestSize < 224), "Invalid SHA digestSize for a blockSize of 1024. The digestSize must be 224, 256, 384 or 512."); - static if(digestSize==160) /* SHA-1 */ + static if (digestSize==160) /* SHA-1 */ { version(USE_SSSE3) { @@ -230,35 +230,35 @@ struct SHA(uint hashBlockSize, uint digestSize) alias transform = transformX86; } } - else static if(blockSize == 512) /* SHA-224, SHA-256 */ + else static if (blockSize == 512) /* SHA-224, SHA-256 */ alias transform = transformSHA2!uint; - else static if(blockSize == 1024) /* SHA-384, SHA-512, SHA-512/224, SHA-512/256 */ + else static if (blockSize == 1024) /* SHA-384, SHA-512, SHA-512/224, SHA-512/256 */ alias transform = transformSHA2!ulong; else static assert(0); private: /* magic initialization constants - state (ABCDEFGH) */ - static if(blockSize == 512 && digestSize == 160) /* SHA-1 */ + static if (blockSize == 512 && digestSize == 160) /* SHA-1 */ { uint[5] state = [0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0]; } - else static if(blockSize == 512 && digestSize == 224) /* SHA-224 */ + else static if (blockSize == 512 && digestSize == 224) /* SHA-224 */ { uint[8] state = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4, ]; } - else static if(blockSize == 512 && digestSize == 256) /* SHA-256 */ + else static if (blockSize == 512 && digestSize == 256) /* SHA-256 */ { uint[8] state = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, ]; } - else static if(blockSize == 1024 && digestSize == 224) /* SHA-512/224 */ + else static if (blockSize == 1024 && digestSize == 224) /* SHA-512/224 */ { ulong[8] state = [ 0x8C3D37C8_19544DA2, 0x73E19966_89DCD4D6, @@ -267,7 +267,7 @@ struct SHA(uint hashBlockSize, uint digestSize) 0x3F9D85A8_6A1D36C8, 0x1112E6AD_91D692A1, ]; } - else static if(blockSize == 1024 && digestSize == 256) /* SHA-512/256 */ + else static if (blockSize == 1024 && digestSize == 256) /* SHA-512/256 */ { ulong[8] state = [ 0x22312194_FC2BF72C, 0x9F555FA3_C84C64C2, @@ -276,7 +276,7 @@ struct SHA(uint hashBlockSize, uint digestSize) 0x2B0199FC_2C85B8AA, 0x0EB72DDC_81C52CA2, ]; } - else static if(blockSize == 1024 && digestSize == 384) /* SHA-384 */ + else static if (blockSize == 1024 && digestSize == 384) /* SHA-384 */ { ulong[8] state = [ 0xcbbb9d5d_c1059ed8, 0x629a292a_367cd507, @@ -285,7 +285,7 @@ struct SHA(uint hashBlockSize, uint digestSize) 0xdb0c2e0d_64f98fa7, 0x47b5481d_befa4fa4, ]; } - else static if(blockSize == 1024 && digestSize == 512) /* SHA-512 */ + else static if (blockSize == 1024 && digestSize == 512) /* SHA-512 */ { ulong[8] state = [ 0x6a09e667_f3bcc908, 0xbb67ae85_84caa73b, @@ -298,7 +298,7 @@ struct SHA(uint hashBlockSize, uint digestSize) static assert(0); /* constants */ - static if(blockSize == 512) + static if (blockSize == 512) { static immutable uint[64] constants = [ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, @@ -311,7 +311,7 @@ struct SHA(uint hashBlockSize, uint digestSize) 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, ]; } - else static if(blockSize == 1024) + else static if (blockSize == 1024) { static immutable ulong[80] constants = [ 0x428a2f98_d728ae22, 0x71374491_23ef65cd, 0xb5c0fbcf_ec4d3b2f, 0xe9b5dba5_8189dbbc, @@ -632,7 +632,7 @@ struct SHA(uint hashBlockSize, uint digestSize) T_SHA2_16_79!Word(62, W, C, D, E, F, G, H, A, B, constants[62]); T_SHA2_16_79!Word(63, W, B, C, D, E, F, G, H, A, constants[63]); - static if(is(Word==ulong)) + static if (is(Word==ulong)) { T_SHA2_16_79!Word(64, W, A, B, C, D, E, F, G, H, constants[64]); T_SHA2_16_79!Word(65, W, H, A, B, C, D, E, F, G, constants[65]); @@ -702,14 +702,14 @@ struct SHA(uint hashBlockSize, uint digestSize) index = (cast(uint)count[0] >> 3) & (blockSizeInBytes - 1); /* Update number of bits */ - static if(blockSize==512) + static if (blockSize==512) count[0] += inputLen * 8; - else static if(blockSize==1024) + else static if (blockSize==1024) { /* ugly hack to work around lack of ucent */ auto oldCount0 = count[0]; count[0] += inputLen * 8; - if(count[0] < oldCount0) + if (count[0] < oldCount0) count[1]++; } else @@ -752,7 +752,7 @@ struct SHA(uint hashBlockSize, uint digestSize) */ ubyte[digestSize/8] finish() @trusted pure nothrow @nogc { - static if(blockSize==512) + static if (blockSize==512) { ubyte[32] data = void; uint index, padLen; @@ -776,7 +776,7 @@ struct SHA(uint hashBlockSize, uint digestSize) start(); return data[0..digestSize/8]; } - else static if(blockSize==1024) + else static if (blockSize==1024) { ubyte[64] data = void; uint index, padLen; @@ -854,7 +854,7 @@ unittest { //Let's use the template features: //Note: When passing a SHA1 to a function, it must be passed by reference! - void doSomething(T)(ref T hash) if(isDigest!T) + void doSomething(T)(ref T hash) if (isDigest!T) { hash.put(cast(ubyte)0); }