let start, stop = HExtlib.loc_of_floc floc in
let start_bytes = Glib.Utf8.offset_to_pos s ~pos:0 ~off:start in
let stop_bytes = Glib.Utf8.offset_to_pos s ~pos:0 ~off:stop in
- assert(stop_bytes >= start_bytes);
+ if (stop_bytes < start_bytes) then
+ Printf.sprintf "ERROR (%d > %d)" start_bytes stop_bytes, 0
+ else
let bytes = stop_bytes - start_bytes in
try
String.sub s start_bytes bytes, bytes
with Invalid_argument _ ->
- Printf.eprintf "%s/%d/%d\n" s start_bytes bytes;
- assert false
-
+ Printf.sprintf "ERROR (%s/%d/%d)" s start_bytes bytes, 0
let utf8_string_length s =
if BuildTimeConf.debug then