diff options
author | Fredrik Høisæther Rasch <fredrik.rasch@gmail.com> | 2017-06-28 18:03:18 +0200 |
---|---|---|
committer | Fredrik Høisæther Rasch <fredrik.h.rasch@uit.no> | 2017-07-04 11:52:54 +0200 |
commit | 177a634992c378ec331c95e64c7f2ddd73154e77 (patch) | |
tree | 55fbb6d118746d711ec9492621493b7a5b9cec19 /lib | |
parent | 9823c677b865eb6d491271ec103ecd751da2dde5 (diff) | |
download | Nim-177a634992c378ec331c95e64c7f2ddd73154e77.tar.gz |
Add safeties for alignLeft
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/strutils.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index fb52a0cc0..a6bf273b3 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -1092,8 +1092,8 @@ proc alignLeft*(s: string, count: Natural, padding = ' '): string {.noSideEffect ## assert alignLeft("1232", 6, '#') == "1232##" if s.len < count: result = newString(count) - for i in 0 ..< s.len: - result[i] = s[i] + if s.len > 0: + result[0 .. (s.len - 1)] = s for i in s.len ..< count: result[i] = padding else: |