let index_of_character_reverse t ?from c =
let from =
let length_of_t = length t in
match from with
| None -> length_of_t - 1
| Some s when s < 0 -> -1
| Some s when s > length_of_t - 1 -> length_of_t - 1
| Some s -> s
in
let res = ref None in
try
for i = from downto 0 do
if S.get t i = c then (res:= Some i; raise Not_found)
done;
None
with _ -> !res