let
strip_final_cr s =
let
l = length s
in
if
l > 0
&&
s.[l-1] =
'\r'
then
sub s 0 (l-1)
else
s