12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364includeDune_caml.Filename(* Return the index of the start of the extension, using the same semantic as
[Filename.extension] in 4.04 *)letextension_start=(* This is from the win32 implementation, but it is acceptable for
the usage we make of it in this function and covers all
platforms. *)letis_dir_sep=function|'/'|'\\'|':'->true|_->falseinletreccheck_at_least_one_non_dotslencandidatei=ifi<0thenlenelsematchs.[i]with|'.'->check_at_least_one_non_dotslencandidate(i-1)|c->ifis_dir_sepcthenlenelsecandidateinletrecsearch_dotsleni=ifi<=0thenlenelsematchs.[i]with|'.'->check_at_least_one_non_dotsleni(i-1)|c->ifis_dir_sepcthenlenelsesearch_dotslen(i-1)infuns->letlen=String.lengthsinsearch_dotslen(len-1)letsplit_extensionfn=leti=extension_startfninString.split_nfniletsplit_extension_after_dotfn=leti=extension_startfn+1inletlen=String.lengthfninifi>lenthen(fn,"")elseString.split_nfniletextensionfn=String.dropfn(extension_startfn)typeprogram_name_kind=|In_path|Relative_to_current_dir|Absoluteletanalyze_program_namefn=ifnot(is_relativefn)thenAbsoluteelseifString.containsfn'/'||(Sys.win32&&String.containsfn'\\')thenRelative_to_current_direlseIn_path