Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file compat.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160(*
* Copyright (c) 2018 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)moduleChar=structincludeChar#ifOCAML_VERSION<(4,3,0)letequalxy=Char.comparexy=0#endifendmoduleString=structincludeString#ifOCAML_VERSION<(4,3,0)letequalxy=String.comparexy=0#endif#ifOCAML_VERSION<(4,4,0)letsplit_on_charseps=letr=ref[]inletj=ref(String.lengths)infori=String.lengths-1downto0doifString.unsafe_getsi=septhenbeginr:=String.subs(i+1)(!j-i-1)::!r;j:=ienddone;String.subs0!j::!r#endif#ifOCAML_VERSION<(4,5,0)letrecindex_rec_optslimic=ifi>=limthenNoneelseifunsafe_getsi=cthenSomeielseindex_rec_optslim(i+1)cletindex_optsc=index_rec_opts(lengths)0c#endif#ifOCAML_VERSION<(4,3,0)letcapitalize_ascii=String.capitalize(* deprecated >= 4.3.0 *)#endifendmoduleFilename=structincludeFilename#ifOCAML_VERSION<(4,4,0)letis_dir_sepsi=s.[i]='/'(* Unix only *)letextension_lenname=letrecchecki0i=ifi<0||is_dir_sepnameithen0elseifname.[i]='.'thenchecki0(i-1)elseString.lengthname-i0inletrecsearch_doti=ifi<0||is_dir_sepnameithen0elseifname.[i]='.'thenchecki(i-1)elsesearch_dot(i-1)insearch_dot(String.lengthname-1)letextensionname=letl=extension_lennameinifl=0then""elseString.subname(String.lengthname-l)lletremove_extensionname=letl=extension_lennameinifl=0thennameelseString.subname0(String.lengthname-l)#endifendmoduleList=structincludeList#ifOCAML_VERSION<(4,8,0)letfilter_mapf=letrecauxaccu=function|[]->revaccu|x::l->matchfxwith|None->auxaccul|Somev->aux(v::accu)linaux[]#endif#ifOCAML_VERSION<(4,6,0)letrecinit_auxinf=ifi>=nthen[]else(fi)::init_aux(i+1)nfletinitnf=init_aux0nf#endif#ifOCAML_VERSION<(4,5,0)letrecfind_optp=function|[]->None|x::l->ifpxthenSomexelsefind_optplletreccompare_length_withln=matchlwith|[]->ifn=0then0elseifn>0then-1else1|_::l->ifn<=0then1elsecompare_length_withl(n-1)#endif#ifOCAML_VERSION<(4,3,0)letconsxxs=x::xs#endifendmoduleWarnings=structincludeWarnings#ifOCAML_VERSION<(4,3,0)(* Can't be overriden *)letreset_fatal()=()#endifendmoduleLexer=structincludeLexer#ifOCAML_VERSION<(4,3,0)lethandle_docstrings=reftrue#endifend#ifOCAML_VERSION<(4,4,0)moduleEnv=structincludeEnv(* Can't be overriden *)letwithout_cmisfx=fxend#endif#ifOCAML_VERSION>=(4,9,0)letinit_path()=Compmisc.init_path()#elseletinit_path()=Compmisc.init_pathtrue#endif