[Libguestfs] [PATCH v4 4/6] mllib: modify nsplit to take optional noempty and count arguments
Pino Toscano
ptoscano at redhat.com
Thu Dec 22 17:35:24 UTC 2016
On Sunday, 18 December 2016 23:16:31 CET Tomáš Golembiovský wrote:
> Added two new optional arguments to nsplit:
>
> * noempty: if set to false empty elements are not stored in the returned
> list. The default is to keep the empty elements
>
> * count: specifies how many splits to perform; negative count
> (the default) means do as many splits as possible
>
> Added tests for nsplit.
>
> Signed-off-by: Tomáš Golembiovský <tgolembi at redhat.com>
> ---
> mllib/common_utils.ml | 12 +++++++++---
> mllib/common_utils.mli | 12 ++++++++++--
> mllib/common_utils_tests.ml | 26 ++++++++++++++++++++++++++
> 3 files changed, 45 insertions(+), 5 deletions(-)
>
> diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
> index f948dce..b6f3046 100644
> --- a/mllib/common_utils.ml
> +++ b/mllib/common_utils.ml
> @@ -130,15 +130,21 @@ module String = struct
> done;
> if not !r then s else Bytes.to_string b2
>
> - let rec nsplit sep str =
> + let rec nsplit ?(noempty = true) ?(count = -1) sep str =
Shouldn't the default value of noempty be false, matching the current
behaviour, and the documentation added?
The rest of the changes (implementation and unit tests) LGTM.
Thanks,
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20161222/3616c0d7/attachment.sig>
More information about the Libguestfs
mailing list