1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253(**************************************************************************)(* ocaml-gettext: a library to translate messages *)(* *)(* Copyright (C) 2003-2008 Sylvain Le Gall <sylvain@le-gall.net> *)(* *)(* This library is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Lesser General Public *)(* License as published by the Free Software Foundation; either *)(* version 2.1 of the License, or (at your option) any later version; *)(* with the OCaml static compilation exception. *)(* *)(* This library is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *)(* Lesser General Public License for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public *)(* License along with this library; if not, write to the Free Software *)(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *)(* USA *)(**************************************************************************)(** Misc. utilities.
@author Sylvain Le Gall
*)openGettextTypesletstring_of_listlst="[ "^String.concat"; "(List.map(funstr->Printf.sprintf"%S"str)lst)^" ]"letsplit_pluralstr=letrecsplit_plural_onestart=letnext_sep=tryString.index_fromstrstart'\000'withNot_found->String.lengthstrinletnew_plural=String.substrstart(next_sep-start)inifnext_sep+1>=String.lengthstrthen[new_plural]elsenew_plural::split_plural_one(next_sep+1)insplit_plural_one0letfail_or_continuefailsafeexccont_value=matchfailsafewith|Ignore->cont_value|InformStderrexc_printer->prerr_string(exc_printerexc);prerr_newline();cont_value|RaiseException->raiseexc