X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=blobdiff_plain;f=src%2Ftop.ml;h=c38239c23ec1fd6cf486ff496d364f9b054efbd2;hp=e2a93d6f1833883086373f51d64a6d0de7469f7b;hb=451a8810221ff41185d29d2362301f0efaba727e;hpb=431dbd98bad6e3635b4d0885bf33dd3e759ca35d diff --git a/src/top.ml b/src/top.ml index e2a93d6..c38239c 100644 --- a/src/top.ml +++ b/src/top.ml @@ -296,17 +296,20 @@ let millisleep n = *) let get_string maxlen = ignore (echo ()); - let str = String.create maxlen in - let ok = getstr str in (* Safe because binding calls getnstr. *) + let str = Bytes.create maxlen in + (* Safe because binding calls getnstr. However the unsafe cast + * to string is required because ocaml-curses needs to be fixed. + *) + let ok = getstr (Obj.magic str) in ignore (noecho ()); if not ok then "" else ( (* Chop at first '\0'. *) try - let i = String.index str '\000' in - String.sub str 0 i + let i = Bytes.index str '\000' in + Bytes.sub_string str 0 i with - Not_found -> str (* it is full maxlen bytes *) + Not_found -> Bytes.to_string str (* it is full maxlen bytes *) ) (* Main loop. *) @@ -417,7 +420,7 @@ and change_delay () = delay := int_of_float (newdelay *. 1000.); false ) with - Failure "float_of_string" -> + Failure _ -> print_msg (s_"Not a valid number"); true in refresh (); sleep (if error then 2 else 1)