summaryrefslogtreecommitdiffstats
path: root/virt-top/virt_top_utils.ml
diff options
context:
space:
mode:
Diffstat (limited to 'virt-top/virt_top_utils.ml')
-rw-r--r--virt-top/virt_top_utils.ml11
1 files changed, 7 insertions, 4 deletions
diff --git a/virt-top/virt_top_utils.ml b/virt-top/virt_top_utils.ml
index f858e0e..c5dc97d 100644
--- a/virt-top/virt_top_utils.ml
+++ b/virt-top/virt_top_utils.ml
@@ -109,10 +109,13 @@ let read_config_file filename =
(* Pad a string to the full width with spaces. If too long, truncate. *)
let pad width str =
- let n = String.length str in
- if n = width then str
- else if n > width then String.sub str 0 width
- else (* if n < width then *) str ^ String.make (width-n) ' '
+ if width <= 0 then ""
+ else (
+ let n = String.length str in
+ if n = width then str
+ else if n > width then String.sub str 0 width
+ else (* if n < width then *) str ^ String.make (width-n) ' '
+ )
module Show = struct
(* Show a percentage in 4 chars. *)