search for: triml

Displaying 20 results from an estimated 31 matches for "triml".

Did you mean: trim
2016 Jun 16
1
[PATCH] mllib: Add isspace, triml, trimr and trim functions.
...flen && sub str (len - sufflen) sufflen = suffix + (* Note OCaml stdlib has an "is_space" function. *) + let isspace c = + c = ' ' + (* || c = '\f' *) || c = '\n' || c = '\r' || c = '\t' (* || c = '\v' *) + + let triml ?(test = isspace) str = + let i = ref 0 in + let n = ref (String.length str) in + while !n > 0 && test str.[!i]; do + decr n; + incr i + done; + if !i = 0 then str + else String.sub str !i !n + + let trimr ?(test = isspace) str = + let...
2020 Jan 29
2
Re: [PATCH v2] mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
On Wed, Jan 29, 2020 at 03:07:12PM +0100, Martin Kletzander wrote: > From: Martin Kletzander <mkletzan@redhat.com> > > The first split does not care about the whole string, it is just trying to get > the command name in front, so triml is just right. > > Signed-off-by: Martin Kletzander <mkletzan@redhat.com> > --- > mlcustomize/customize_cmdline.ml | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mlcustomize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml > index c062379879e2..abd2...
2020 Jan 23
6
Re: [common PATCH] Trim whitespaces from commands read from file
...l > >+++ b/mlcustomize/customize_cmdline.ml > >@@ -481,6 +481,7 @@ let rec argspec () = > > ] in > > let lines = read_whole_file filename in > > let lines = String.lines_split lines in > >+ let lines = List.map String.trim lines in I wonder if String.triml is safer? However I cannot think of a way that it's likely to be useful to have trailing whitespace be meaningful. Please put this in the subject line of the commit message: “(RHBZ#1351000)”. This will ensure that it is picked up by the release notes by the bugs-in-changelog script. ACK Ri...
2019 Aug 13
0
[PATCH 3/3] generator: improve pod2text invocation
...rintf "=head1 %s\n\n%s\n" name longdesc); + close_out chan_in; let lines = ref [] in - let rec loop i = - let line = input_line chan in - if i = 1 && discard then (* discard the first line of output *) - loop (i+1) - else ( - let line = if trim then String.triml line else line in - lines := line :: !lines; - loop (i+1) - ) in - let lines : pod2text_memo_value = try loop 1 with End_of_file -> List.rev !lines in - unlink filename; - (match close_process_in chan with + (try while true do lines := input_line chan_out :: !lines done + with...
2020 Jan 29
0
[PATCH v2] mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
The first split does not care about the whole string, it is just trying to get the command name in front, so triml is just right. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- mlcustomize/customize_cmdline.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/mlcustomize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml index c062379879e2..abd21a4cbca5 100644 --- a/mlcustomize/custom...
2020 Feb 24
0
Re: [PATCH v2] mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
...Richard W.M. Jones wrote: > On Wed, Jan 29, 2020 at 03:07:12PM +0100, Martin Kletzander wrote: > > From: Martin Kletzander <mkletzan@redhat.com> > > > > The first split does not care about the whole string, it is just trying to get > > the command name in front, so triml is just right. > > > > Signed-off-by: Martin Kletzander <mkletzan@redhat.com> > > --- > > mlcustomize/customize_cmdline.ml | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/mlcustomize/customize_cmdline.ml b/mlcustomize/customize_cmdli...
2019 Aug 13
5
[PATCH 0/3] generator: pod2text-related improvements
- refactor memoization code - pass pod as stdin rather than files Pino Toscano (3): generator: isolate memoized cache in own module generator: adjust variable names generator: improve pod2text invocation generator/Makefile.am | 3 ++ generator/memoized_cache.ml | 62 +++++++++++++++++++++ generator/memoized_cache.mli | 29 ++++++++++ generator/utils.ml | 101
2016 Dec 09
0
Re: [PATCH] generator: Share Common_utils code.
...b2 i c2; > - r := true > - ) > - done; > - if not !r then s else Bytes.to_string b2 Ditto. > -let isspace c = > - c = ' ' > - (* || c = '\f' *) || c = '\n' || c = '\r' || c = '\t' (* || c = '\v' *) Ditto. > -let triml ?(test = isspace) str = > - let i = ref 0 in > - let n = ref (String.length str) in > - while !n > 0 && test str.[!i]; do > - decr n; > - incr i > - done; > - if !i = 0 then str > - else String.sub str !i !n > - > -let trimr ?(test = isspace) str...
2020 Jan 23
1
Re: [common PATCH] Trim whitespaces from commands read from file
...t;> >@@ -481,6 +481,7 @@ let rec argspec () = >>> > ] in >>> > let lines = read_whole_file filename in >>> > let lines = String.lines_split lines in >>> >+ let lines = List.map String.trim lines in >> >>I wonder if String.triml is safer? However I cannot >>think of a way that it's likely to be useful to have >>trailing whitespace be meaningful. >> > >I actually thought about that and it might be dangerous to just trim from left. >Space in the end might change semantics of a command (althoug...
2016 Dec 08
4
[PATCH] generator: Share Common_utils code.
...s.unsafe_get b2 i = c1 then ( - Bytes.unsafe_set b2 i c2; - r := true - ) - done; - if not !r then s else Bytes.to_string b2 - -let isspace c = - c = ' ' - (* || c = '\f' *) || c = '\n' || c = '\r' || c = '\t' (* || c = '\v' *) - -let triml ?(test = isspace) str = - let i = ref 0 in - let n = ref (String.length str) in - while !n > 0 && test str.[!i]; do - decr n; - incr i - done; - if !i = 0 then str - else String.sub str !i !n - -let trimr ?(test = isspace) str = - let n = ref (String.length str) in - while...
2018 Jan 10
0
[PATCH 1/3] daemon: make sgdisk_info_extract_uuid_field more generic
...act_field device partnum field chars = if partnum <= 0 then failwith "partition number must be >= 1"; udev_settle (); @@ -167,13 +171,13 @@ and sgdisk_info_extract_uuid_field device partnum field = (* Skip any whitespace after the colon. *) let value = String.triml value in - (* Extract the UUID. *) - extract_uuid value + (* Extract the value. *) + extract_string chars value | _ :: lines -> loop lines in loop lines -and extract_uuid value = +and extract_string chars value = (* The value contains only valid GUID c...
2018 Jan 15
0
[PATCH v2 1/3] daemon: make sgdisk_info_extract_uuid_field more generic
...field device partnum field extractor = if partnum <= 0 then failwith "partition number must be >= 1"; udev_settle (); @@ -167,13 +166,16 @@ and sgdisk_info_extract_uuid_field device partnum field = (* Skip any whitespace after the colon. *) let value = String.triml value in - (* Extract the UUID. *) - extract_uuid value + (* Extract the value. *) + extractor value | _ :: lines -> loop lines in loop lines -and extract_uuid value = - (* The value contains only valid GUID characters. *) - String.sub value 0 (String.s...
2020 Jan 23
0
Re: [common PATCH] Trim whitespaces from commands read from file
.../customize_cmdline.ml >> >@@ -481,6 +481,7 @@ let rec argspec () = >> > ] in >> > let lines = read_whole_file filename in >> > let lines = String.lines_split lines in >> >+ let lines = List.map String.trim lines in > >I wonder if String.triml is safer? However I cannot >think of a way that it's likely to be useful to have >trailing whitespace be meaningful. > I actually thought about that and it might be dangerous to just trim from left. Space in the end might change semantics of a command (although I did not go through t...
2020 Jan 29
0
Re: [common PATCH] Trim whitespaces from commands read from file
.../customize_cmdline.ml >> >@@ -481,6 +481,7 @@ let rec argspec () = >> > ] in >> > let lines = read_whole_file filename in >> > let lines = String.lines_split lines in >> >+ let lines = List.map String.trim lines in > >I wonder if String.triml is safer? However I cannot >think of a way that it's likely to be useful to have >trailing whitespace be meaningful. > >Please put this in the subject line of the commit >message: “(RHBZ#1351000)”. This will ensure that it >is picked up by the release notes by the >bugs-i...
2020 Jan 23
2
[common PATCH] Trim whitespaces from commands read from file
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- mlcustomize/customize_cmdline.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/mlcustomize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml index c062379879e2..67e85af2ad93 100644 --- a/mlcustomize/customize_cmdline.ml +++ b/mlcustomize/customize_cmdline.ml @@ -481,6 +481,7 @@ let rec argspec () = ] in let
2018 Jan 15
6
[PATCH v2 0/3] copying gpt attributes
Hi all, Here is the latest version of the series addressing Pino's comments. Cédric Bosdonnat (3): daemon: make sgdisk_info_extract_uuid_field more generic New APIs: part_set_gpt_attributes and part_get_gpt_attributes resize: copy GPT partition flags daemon/parted.ml | 45 +++++++++++++++++++++++++++++++++++---------- daemon/parted.mli | 3 +++
2017 Jul 21
3
[PATCH] common/mlstdutils: Add chomp function to remove \n from end of strings.
...ons(-) diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml index 374507662..b731b8fd5 100644 --- a/common/mlstdutils/std_utils.ml +++ b/common/mlstdutils/std_utils.ml @@ -229,6 +229,13 @@ module String = struct let trim ?(test = Char.isspace) str = trimr ~test (triml ~test str) + let chomp str = + let n = String.length str in + if n > 0 && str.[n-1] = '\n' then + String.sub str 0 (n-1) + else + str + let count_chars c str = let count = ref 0 in for i = 0 to String.length str - 1 do diff --g...
2018 Jan 16
4
[PATCH v3 0/3] copy GPT attributes
Hi all, Here is v3 of the series, taking Richard's comments in account. Cédric Bosdonnat (3): daemon: make sgdisk_info_extract_uuid_field more generic New APIs: part_set_gpt_attributes and part_get_gpt_attributes resize: copy GPT partition flags daemon/parted.ml | 45 +++++++++++++++++++++++++++++++++++---------- daemon/parted.mli | 2 ++ generator/actions_core.ml
2018 Jan 10
6
[PATCH 0/3] Handle GPT attribute flags
Hi all, Here is the series fixing the bug I mentioned on IRC regarding the GPT attribute flags to copy to the new disk in a virt-resize. Cédric Bosdonnat (3): daemon: make sgdisk_info_extract_uuid_field more generic New APIs: part_set_gpt_attributes and part_get_gpt_attributes resize: copy GPT partition flags daemon/parted.ml | 34 +++++++++++++++++++++++++++-------
2017 Jun 15
0
[PATCH v6 04/41] mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
...let chars = "abcdefghijklmnopqrstuvwxyz0123456789" in + fun () -> + concat "" ( + List.map ( + fun _ -> + let c = Random.int 36 in + let c = chars.[c] in + make 1 c + ) [1;2;3;4;5;6;7;8] + ) + + let triml ?(test = Char.isspace) str = + let i = ref 0 in + let n = ref (String.length str) in + while !n > 0 && test str.[!i]; do + decr n; + incr i + done; + if !i = 0 then str + else String.sub str !i !n + + let trimr ?(test = Char.isspace) str = +...