diff options
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/collections/tables.nim | 24 | ||||
-rw-r--r-- | lib/pure/parsecfg.nim | 14 | ||||
-rw-r--r-- | lib/pure/times.nim | 2 |
3 files changed, 26 insertions, 14 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 2bdf77125..bee0a41b2 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -438,7 +438,7 @@ proc `$`*[A, B](t: TableRef[A, B]): string = dollarImpl() proc `==`*[A, B](s, t: TableRef[A, B]): bool = - ## The `==` operator for hash tables. Returns ``true`` iff either both tables + ## The `==` operator for hash tables. Returns ``true`` iff either both tables ## are ``nil`` or none is ``nil`` and the content of both tables contains the ## same key-value pairs. Insert order does not matter. if isNil(s): result = isNil(t) @@ -616,8 +616,8 @@ proc `$`*[A, B](t: OrderedTable[A, B]): string = dollarImpl() proc `==`*[A, B](s, t: OrderedTable[A, B]): bool = - ## The `==` operator for ordered hash tables. Both the content and the order - ## must be equal for this to return ``true``. + ## The `==` operator for ordered hash tables. Returns true iff both the + ## content and the order are equal. if s.counter == t.counter: forAllOrderedPairs: if s.data[h] != t.data[h]: return false @@ -768,9 +768,12 @@ proc `$`*[A, B](t: OrderedTableRef[A, B]): string = dollarImpl() proc `==`*[A, B](s, t: OrderedTableRef[A, B]): bool = - ## The `==` operator for ordered hash tables. Both the content and the order - ## must be equal for this to return ``true``. - result = s[] == t[] + ## The `==` operator for ordered hash tables. Returns true iff either both + ## tables are ``nil`` or none is ``nil`` and the content and the order of + ## both are equal. + if isNil(s): result = isNil(t) + elif isNil(t): result = false + else: result = s[] == t[] proc sort*[A, B](t: OrderedTableRef[A, B], cmp: proc (x,y: (A, B)): int) = @@ -1070,9 +1073,12 @@ proc `$`*[A](t: CountTableRef[A]): string = dollarImpl() proc `==`*[A](s, t: CountTableRef[A]): bool = - ## The `==` operator for count tables. Returns ``true`` iff both tables - ## contain the same keys with the same count. Insert order does not matter. - result = s[] == t[] + ## The `==` operator for count tables. Returns ``true`` iff either both tables + ## are ``nil`` or none is ``nil`` and both contain the same keys with the same + ## count. Insert order does not matter. + if isNil(s): result = isNil(t) + elif isNil(t): result = false + else: result = s[] == t[] proc inc*[A](t: CountTableRef[A], key: A, val = 1) = ## increments `t[key]` by `val`. diff --git a/lib/pure/parsecfg.nim b/lib/pure/parsecfg.nim index c648b0703..47670cc19 100644 --- a/lib/pure/parsecfg.nim +++ b/lib/pure/parsecfg.nim @@ -512,10 +512,16 @@ proc writeConfig*(dict: Config, filename: string) = kv = key if value != "": ## If the key is not empty if not allCharsInSet(value, SymChars): - kv.add(segmentChar) - kv.add("\"") - kv.add(replace(value)) - kv.add("\"") + if find(value, '"') == -1: + kv.add(segmentChar) + kv.add("\"") + kv.add(replace(value)) + kv.add("\"") + else: + kv.add(segmentChar) + kv.add("\"\"\"") + kv.add(replace(value)) + kv.add("\"\"\"") else: kv.add(segmentChar) kv.add(value) diff --git a/lib/pure/times.nim b/lib/pure/times.nim index efc1dfa92..db09f94c1 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -84,7 +84,7 @@ elif defined(windows): timezone {.importc: "_timezone", header: "<time.h>".}: int tzname {.importc: "_tzname", header: "<time.h>"}: array[0..1, cstring] else: - type TimeImpl {.importc: "time_t", header: "<time.h>".} = int32 + type TimeImpl {.importc: "time_t", header: "<time.h>".} = int var timezone {.importc, header: "<time.h>".}: int tzname {.importc, header: "<time.h>" .}: array[0..1, cstring] |