From 3d266433a75449d76b589aba6edaf488d5a8c921 Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Tue, 9 Jun 2015 22:16:43 +0200 Subject: [PATCH 1/4] securehash: Keep module name consistent 1. All other modules don't use underscore, why this should be different? 2. Wrap some imports to 80 column --- compiler/ast.nim | 2 +- compiler/cgen.nim | 2 +- compiler/extccomp.nim | 3 ++- compiler/jsgen.nim | 2 +- compiler/modules.nim | 2 +- compiler/rodread.nim | 2 +- compiler/rodwrite.nim | 3 ++- compiler/{secure_hash.nim => securehash.nim} | 0 8 files changed, 9 insertions(+), 7 deletions(-) rename compiler/{secure_hash.nim => securehash.nim} (100%) diff --git a/compiler/ast.nim b/compiler/ast.nim index dc190fd7f..36d29e06a 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -10,7 +10,7 @@ # abstract syntax tree + symbol table import - msgs, hashes, nversion, options, strutils, secure_hash, ropes, idents, lists, + msgs, hashes, nversion, options, strutils, securehash, ropes, idents, lists, intsets, idgen type diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 03aa0b4d4..390150cf7 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -11,7 +11,7 @@ import ast, astalgo, hashes, trees, platform, magicsys, extccomp, options, intsets, - nversion, nimsets, msgs, secure_hash, bitsets, idents, lists, types, + nversion, nimsets, msgs, securehash, bitsets, idents, lists, types, ccgutils, os, ropes, math, passes, rodread, wordrecg, treetab, cgmeth, condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases, lowerings, semparallel diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 2ddb98aba..38427b367 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -13,7 +13,8 @@ # nim files. import - lists, ropes, os, strutils, osproc, platform, condsyms, options, msgs, secure_hash + lists, ropes, os, strutils, osproc, platform, condsyms, options, msgs, + securehash type TSystemCC* = enum diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 346a52cfc..1f82306d2 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -31,7 +31,7 @@ implements the required case distinction. import ast, astalgo, strutils, hashes, trees, platform, magicsys, extccomp, options, - nversion, nimsets, msgs, secure_hash, bitsets, idents, lists, types, os, + nversion, nimsets, msgs, securehash, bitsets, idents, lists, types, os, times, ropes, math, passes, ccgutils, wordrecg, renderer, rodread, rodutils, intsets, cgmeth, lowerings diff --git a/compiler/modules.nim b/compiler/modules.nim index 0573b91f8..6cb14c091 100644 --- a/compiler/modules.nim +++ b/compiler/modules.nim @@ -10,7 +10,7 @@ ## implements the module handling import - ast, astalgo, magicsys, secure_hash, rodread, msgs, cgendata, sigmatch, options, + ast, astalgo, magicsys, securehash, rodread, msgs, cgendata, sigmatch, options, idents, os, lexer, idgen, passes, syntaxes, llstream type diff --git a/compiler/rodread.nim b/compiler/rodread.nim index 27cb96ca1..dad7d111e 100644 --- a/compiler/rodread.nim +++ b/compiler/rodread.nim @@ -90,7 +90,7 @@ import os, options, strutils, nversion, ast, astalgo, msgs, platform, condsyms, - ropes, idents, secure_hash, idgen, types, rodutils, memfiles + ropes, idents, securehash, idgen, types, rodutils, memfiles type TReasonForRecompile* = enum ## all the reasons that can trigger recompilation diff --git a/compiler/rodwrite.nim b/compiler/rodwrite.nim index 3454b9ade..737387597 100644 --- a/compiler/rodwrite.nim +++ b/compiler/rodwrite.nim @@ -13,7 +13,8 @@ import intsets, os, options, strutils, nversion, ast, astalgo, msgs, platform, - condsyms, ropes, idents, secure_hash, rodread, passes, importer, idgen, rodutils + condsyms, ropes, idents, securehash, rodread, passes, importer, idgen, + rodutils # implementation diff --git a/compiler/secure_hash.nim b/compiler/securehash.nim similarity index 100% rename from compiler/secure_hash.nim rename to compiler/securehash.nim From eccc2f87e9dfa7e849e027bef857a390de3e9bae Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Tue, 9 Jun 2015 22:15:08 +0200 Subject: [PATCH 2/4] securehash: remove unused emptySecureHash --- compiler/securehash.nim | 8 -------- 1 file changed, 8 deletions(-) diff --git a/compiler/securehash.nim b/compiler/securehash.nim index 3383f23a2..12950f137 100644 --- a/compiler/securehash.nim +++ b/compiler/securehash.nim @@ -16,14 +16,6 @@ type SHA1Digest = array[0 .. sha_digest_size-1, uint8] SecureHash* = distinct SHA1Digest -const emptySecureHash = SecureHash([ - 0u8, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, -]) - proc sha1(src: string) : SHA1Digest proc secureHash*(str: string): SecureHash = SecureHash(sha1(str)) From 54c863d6ae36faa9ba14fa2a5c34ea38d4be6efe Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Tue, 9 Jun 2015 22:15:51 +0200 Subject: [PATCH 3/4] securehash: sha_digest_size is not following style https://github.com/Araq/Nim/wiki/Style-Guide-for-Nim-Code --- compiler/securehash.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/securehash.nim b/compiler/securehash.nim index 12950f137..ad15c2e8f 100644 --- a/compiler/securehash.nim +++ b/compiler/securehash.nim @@ -10,10 +10,10 @@ import strutils, unsigned -const sha_digest_size = 20 +const SHA1DigestSize = 20 type - SHA1Digest = array[0 .. sha_digest_size-1, uint8] + SHA1Digest = array[0 .. SHA1DigestSize-1, uint8] SecureHash* = distinct SHA1Digest proc sha1(src: string) : SHA1Digest @@ -26,7 +26,7 @@ proc `$`*(self: SecureHash): string = result.add(toHex(int(v), 2)) proc parseSecureHash*(hash: string): SecureHash = - for i in 0.. Date: Tue, 9 Jun 2015 22:55:29 +0200 Subject: [PATCH 4/4] securehash: SHA1 -> Sha1 according to style guide --- compiler/securehash.nim | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/compiler/securehash.nim b/compiler/securehash.nim index ad15c2e8f..8ac6acb0e 100644 --- a/compiler/securehash.nim +++ b/compiler/securehash.nim @@ -10,28 +10,28 @@ import strutils, unsigned -const SHA1DigestSize = 20 +const Sha1DigestSize = 20 type - SHA1Digest = array[0 .. SHA1DigestSize-1, uint8] - SecureHash* = distinct SHA1Digest + Sha1Digest = array[0 .. Sha1DigestSize-1, uint8] + SecureHash* = distinct Sha1Digest -proc sha1(src: string) : SHA1Digest +proc sha1(src: string) : Sha1Digest proc secureHash*(str: string): SecureHash = SecureHash(sha1(str)) proc secureHashFile*(filename: string): SecureHash = secureHash(readFile(filename)) proc `$`*(self: SecureHash): string = result = "" - for v in SHA1Digest(self): + for v in Sha1Digest(self): result.add(toHex(int(v), 2)) proc parseSecureHash*(hash: string): SecureHash = - for i in 0..