Re: [Libguestfs] [PATCH] builder: use Filename.check_suffix

Richard W.M. Jones
Mon, 10 Mar 2014 15:12:14 -0000

On Mon, Mar 10, 2014 at 01:48:29PM +0100, Pino Toscano
wrote:
> ... instead of manually extracting and checking the suffix by ourselves
> ---
>  builder/sources.ml | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/builder/sources.ml b/builder/sources.ml
> index fd0b236..016adc4 100644
> --- a/builder/sources.ml
> +++ b/builder/sources.ml
> @@ -87,10 +87,7 @@ let merge_sources current_sources new_sources >    )
new_sources current_sources
>
>  let filter_filenames filename > -  let suffix = ".conf" in
> -  let n = String.length filename in
> -  let ns = String.length suffix in
> -  n >= ns && String.sub filename (n - ns) ns = suffix
> +  Filename.check_suffix filename ".conf"
>
>  let read_sources ~prog ~debug >    let dirs = Paths.xdg_config_dirs
~prog in

ACK.

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)