Pino Toscano
2014-Mar-10 12:48 UTC
[Libguestfs] [PATCH] builder: use Filename.check_suffix
... 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 -- 1.8.3.1
Richard W.M. Jones
2014-Mar-10 15:12 UTC
Re: [Libguestfs] [PATCH] builder: use Filename.check_suffix
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 inACK. 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#)