Displaying 20 results from an estimated 29 matches for "lines_split".
2020 Jan 23
2
[common PATCH] Trim whitespaces from commands read from file
...omize/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 lines = read_whole_file filename in
let lines = String.lines_split lines in
+ let lines = List.map String.trim lines in
let lines = List.filter (
fun line ->
String.length line > 0 && line.[0] <> '#'
--
2.25.0
2020 Jan 29
2
Re: [PATCH v2] mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
...omize/customize_cmdline.ml
> index c062379879e2..abd21a4cbca5 100644
> --- a/mlcustomize/customize_cmdline.ml
> +++ 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.triml lines in
> let lines = List.filter (
> fun line ->
> String.length line > 0 && line.[0] <> '#'
Seems OK to me, so ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://peop...
2017 Jan 30
0
[PATCH v6 2/3] mllib: modify nsplit to take optional noempty and count arguments
...;] (String.nsplit ~count:10 "|" "A|B|C|D");
+
+ (* count and keep_empty together *)
+ assert_equal_stringlist ["A"; "B"; "|||C|D"] (String.nsplit ~keep_empty:false ~count:2 "|" "|||A||||B||||C|D")
+
(* Test Common_utils.String.lines_split. *)
let test_string_lines_split ctx =
assert_equal_stringlist [""] (String.lines_split "");
@@ -135,6 +164,7 @@ let suite =
"strings.is_prefix" >:: test_string_is_prefix;
"strings.is_suffix" >:: test_string_is_suffix;
"stri...
2017 Jun 15
0
[PATCH v6 04/41] mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
...#39; :: nsplit sep s''
+ )
+
+ let split sep str =
+ let len = length sep in
+ let seplen = length str in
+ let i = find str sep in
+ if i = -1 then str, ""
+ else (
+ sub str 0 i, sub str (i + len) (seplen - i - len)
+ )
+
+ let rec lines_split str =
+ let buf = Buffer.create 16 in
+ let len = length str in
+ let rec loop start len =
+ try
+ let i = index_from str start '\n' in
+ if i > 0 && str.[i-1] = '\\' then (
+ Buffer.add_substring buf str start (i-start-1...
2020 Jan 23
6
Re: [common PATCH] Trim whitespaces from commands read from file
...l
> >index c062379879e2..67e85af2ad93 100644
> >--- a/mlcustomize/customize_cmdline.ml
> >+++ 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...
2015 Oct 07
1
Re: [PATCH 5/5] mllib: Replace various ad hoc string_* functions with String.*
...old vs "new" functions are:
>
> string_prefix -> String.is_prefix
> string_suffix -> String.is_suffix
> string_find -> String.find
> replace_str -> String.replace
> string_nsplit -> String.nsplit
> string_split -> String.split
> string_lines_split -> String.lines_split
> string_random8 -> String.random8
> ---
As mentioned yesterday on IRC, I'm torn about this one: the functions
would automatically alias functions with the same name, whenever
available in OCaml' stdlib. Also (but this is more personal), reading
String.fo...
2017 Apr 07
1
[PATCH 1/2] mllib: add new Common_utils.run_commands
...sert_equal_intlist = assert_equal ~printer:(fun x -> "(" ^ (String.concat ";" (List.map string_of_int x)) ^ ")")
let test_subdirectory ctx =
assert_equal_string "" (subdirectory "/foo" "/foo");
@@ -131,6 +132,54 @@ let test_string_lines_split ctx =
assert_equal_stringlist ["A\nB"; ""] (String.lines_split "A\\\nB\n");
assert_equal_stringlist ["A\nB\n"] (String.lines_split "A\\\nB\\\n")
+(* Test Common_utils.run_commands. *)
+let test_run_commands ctx =
+ begin
+ let res = run_...
2016 Dec 18
0
[PATCH v4 4/6] mllib: modify nsplit to take optional noempty and count arguments
...uot;D"] (String.nsplit ~count:10 "," "A,B,C,D");
+
+ (* count and noempty together *)
+ assert_equal_stringlist ["A"; "B"; "C,D"] (String.nsplit ~noempty:true ~count:2 "," ",,,A,,,,B,,,,C,D")
+
(* Test Common_utils.String.lines_split. *)
let test_string_lines_split ctx =
assert_equal_stringlist [""] (String.lines_split "");
--
2.10.2
2017 Jun 20
2
[PATCH v2 1/2] mllib: add new Common_utils.run_commands
...sert_equal_intlist = assert_equal ~printer:(fun x -> "(" ^ (String.concat ";" (List.map string_of_int x)) ^ ")")
let test_subdirectory ctx =
assert_equal_string "" (subdirectory "/foo" "/foo");
@@ -131,6 +132,73 @@ let test_string_lines_split ctx =
assert_equal_stringlist ["A\nB"; ""] (String.lines_split "A\\\nB\n");
assert_equal_stringlist ["A\nB\n"] (String.lines_split "A\\\nB\\\n")
+(* Test Common_utils.run_command. *)
+let test_run_command ctx =
+ assert_equal_int 0 (run_com...
2020 Jan 23
1
Re: [common PATCH] Trim whitespaces from commands read from file
...44
>>> >--- a/mlcustomize/customize_cmdline.ml
>>> >+++ 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.
>>
>
>I actually thought about that...
2017 Jun 19
16
[PATCH v7 00/13] Refactor utilities
This is just the utilities part of the patch series from:
https://www.redhat.com/archives/libguestfs/2017-June/msg00103.html
I believe this addresses everything raised in comments on that
patch series.
Rich.
2020 Jan 23
0
Re: [common PATCH] Trim whitespaces from commands read from file
.../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 lines = read_whole_file filename in
> let lines = String.lines_split lines in
>+ let lines = List.map String.trim lines in
> let lines = List.filter (
> fun line ->
> String.length line > 0 && line.[0] <> '#'
>--
>2.25.0
>
>_______________________________________________
>Libguestfs mailing...
2020 Jan 23
0
Re: [common PATCH] Trim whitespaces from commands read from file
...879e2..67e85af2ad93 100644
>> >--- a/mlcustomize/customize_cmdline.ml
>> >+++ 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.
>
I actually thought about that and it might be dangerous to jus...
2020 Jan 29
0
Re: [common PATCH] Trim whitespaces from commands read from file
...879e2..67e85af2ad93 100644
>> >--- a/mlcustomize/customize_cmdline.ml
>> >+++ 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
>messa...
2020 Jan 29
0
[PATCH v2] mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
...omize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml
index c062379879e2..abd21a4cbca5 100644
--- a/mlcustomize/customize_cmdline.ml
+++ 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.triml lines in
let lines = List.filter (
fun line ->
String.length line > 0 && line.[0] <> '#'
--
2.25.0
2020 Feb 24
0
Re: [PATCH v2] mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
...; index c062379879e2..abd21a4cbca5 100644
> > --- a/mlcustomize/customize_cmdline.ml
> > +++ 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.triml lines in
> > let lines = List.filter (
> > fun line ->
> > String.length line > 0 && line.[0] <> '#'
>
> Seems OK to me, so ACK.
LGTM as well, so pushed:
https://gith...
2015 Oct 06
0
[PATCH 5/5] mllib: Replace various ad hoc string_* functions with String.*
...placed
in the String.* namespace. The old vs "new" functions are:
string_prefix -> String.is_prefix
string_suffix -> String.is_suffix
string_find -> String.find
replace_str -> String.replace
string_nsplit -> String.nsplit
string_split -> String.split
string_lines_split -> String.lines_split
string_random8 -> String.random8
---
builder/checksums.ml | 2 +-
builder/downloader.ml | 2 +-
builder/index_parser.ml | 4 +-
builder/paths.ml | 2 +-
builder/sigchecker.ml...
2017 Jun 09
12
[PATCH 00/12] Refactor utility functions.
This turned out to be rather more involved than I thought.
We have lots of utility functions, spread all over the repository,
with not a lot of structure. This moves many of them under common/
and structures them so there are clear dependencies.
This doesn't complete the job by any means. Other items I had on my
to-do list for this change were:
- Split up mllib/common_utils into:
-
2015 Oct 06
10
[PATCH 0/5] mllib: Hide bad String functions and miscellaneous refactoring.
Hide/prevent the use of bad string functions like String.lowercase.
These are replaced by safe functions that won't break UTF-8 strings.
Other miscellaneous refactoring.
Rich.
2019 Jan 11
3
[PATCH 1/3] mlstdutils: add a very simple test for Std_utils.which
...+let test_which ctx =
+ assert_nonempty_string (which "true");
+ assert_raises_executable_not_found "this-command-does-not-really-exist";
+ ()
+
(* Suites declaration. *)
let suite =
"mllib Std_utils" >:::
@@ -154,6 +165,7 @@ let suite =
"strings.lines_split" >:: test_string_lines_split;
"strings.span" >:: test_string_span;
"strings.chomp" >:: test_string_chomp;
+ "which" >:: test_which;
]
let () =
--
2.17.2