X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=blobdiff_plain;f=virt-top%2Fvirt_top_utils.ml;h=c5dc97df20ea378479d9257481171ba328e003c2;hp=f858e0e3be35b2b798e24b367440c307873896e1;hb=0b94aeb460d42eea16bf942dd0892b8ebf63877b;hpb=80357d3ee11d22a649cfefb1786f5ae7148b53a1;ds=sidebyside 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. *)