Displaying 14 results from an estimated 14 matches for "count_chars".
2017 Jul 21
3
[PATCH] common/mlstdutils: Add chomp function to remove \n from end of strings.
...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 --git a/common/mlstdutils/std_utils.mli b/common/mlstdutils/std_utils.mli
index 0b7d90736..d217e48d4 100644
--- a/common/mlstdutils/std_utils.mli
+++ b/common/mlstdutils/std_utils.mli
@@ -107,6 +107,8 @@ module St...
2016 Dec 09
0
Re: [PATCH] generator: Share Common_utils code.
...)
Ditto.
> -let (|>) x f = f x
Ditto.
> -let rec find_map f = function
> - | [] -> raise Not_found
> - | x :: xs ->
> - match f x with
> - | Some y -> y
> - | None -> find_map f xs
Ditto. Also it does not seem to be used anywhere.
> -let count_chars c str =
> - let count = ref 0 in
> - for i = 0 to String.length str - 1 do
> - if c = String.unsafe_get str i then incr count
> - done;
> - !count
Ditto.
> -let explode str =
> - let r = ref [] in
> - for i = 0 to String.length str - 1 do
> - let c = String....
2016 Dec 08
4
[PATCH] generator: Share Common_utils code.
...66cd41 100644
--- a/generator/pr.ml
+++ b/generator/pr.ml
@@ -21,6 +21,7 @@
open Unix
open Printf
+open Common_utils
open Utils
(* Output channel, 'pr' prints to this. *)
@@ -39,7 +40,7 @@ let fileshash = Hashtbl.create 13
let pr fs =
ksprintf
(fun str ->
- let i = count_chars '\n' str in
+ let i = String.count_chars '\n' str in
lines := !lines + i;
output_string !chan str
) fs
diff --git a/generator/python.ml b/generator/python.ml
index 281fb0a..1e24a59 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -20,6 +20,7 @...
2016 Aug 18
3
[PATCH v2 0/2] v2v: Use OVMF secure boot file (RHBZ#1367615).
First version was posted here:
https://www.redhat.com/archives/libguestfs/2016-August/thread.html#00100
This is semantically the same as the first version. However
I've split the patch up into two parts. In the first part,
I factor out the UEFI paths so now they are created by the
generator and written in the library and v2v/ directory directly,
instead of the complex business of having a C
2017 Jun 15
0
[PATCH v6 04/41] mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
...) str =
+ let n = ref (String.length str) in
+ while !n > 0 && test str.[!n-1]; do
+ decr n
+ done;
+ if !n = String.length str then str
+ else String.sub str 0 !n
+
+ let trim ?(test = Char.isspace) str =
+ trimr ~test (triml ~test str)
+
+ let count_chars c str =
+ let count = ref 0 in
+ for i = 0 to String.length str - 1 do
+ if c = String.unsafe_get str i then incr count
+ done;
+ !count
+
+ let explode str =
+ let r = ref [] in
+ for i = 0 to String.length str - 1 do
+ let c = String.unsafe_get str i...
2015 Dec 02
3
[PATCH 0/3] [FOR COMMENTS ONLY] Rework inspection.
This is something I've been working on: Reworking inspection so it's
not a big mess of ad hoc C code, but instead uses a well-defined
domain-specific language to describe how we inspect guests.
The best introduction to this is the manual page, which I include
below (it's also included in patch 2/3).
Rich.
----------------------------------------------------------------------
NAME
2016 Feb 23
4
[PATCH v3 0/4] [FOR COMMENTS ONLY] Rework inspection.
Previously posted:
https://www.redhat.com/archives/libguestfs/2015-December/msg00038.html
Inspection now really succeeds on a small number of simple guests.
To test it out:
$ ./run guestfish -v -x -a /tmp/centos-6.img
><fs> run
><fs> debug sh "guestfs-inspection --verbose"
Rich.
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.
2015 Dec 05
6
[PATCH 0/6 v2] [FOR COMMENTS ONLY] Rework inspection.
This is a more working version. Inspection (partially) succeeds on a
real guest this time :-)
You can test it out on a real guest (in this case, a CentOS disk image
located at /tmp/centos-6.img) by doing:
$ ./run guestfish -v -x -a /tmp/centos-6.img
><fs> run
><fs> debug sh "guestfs-inspection --verbose"
which will print lots of debugging, and at the end the
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:
-
2016 Jan 21
8
[PATCH v3 0/6] [FOR COMMENTS ONLY] Rework inspection.
For background on this change, see:
https://rwmj.wordpress.com/2015/12/06/inspection-now-with-added-prolog/
v2 was previously posted here:
https://www.redhat.com/archives/libguestfs/2015-December/msg00038.html
To test this patch series on a real guest, you can do:
$ ./run guestfish -v -x -a /var/tmp/centos-6.img
><fs> run
><fs> debug sh "guestfs-inspection
2017 Jun 12
32
[PATCH v5 00/32] Refactor utilities, implement some APIs in OCaml.
This is a combination of:
https://www.redhat.com/archives/libguestfs/2017-June/msg00046.html
[PATCH 00/12] Refactor utility functions.
plus:
https://www.redhat.com/archives/libguestfs/2017-June/msg00023.html
[PATCH v3 00/19] Allow APIs to be implemented in OCaml.
with the second patches rebased on top of the utility refactoring, and
some other adjustments and extensions.
This passes
2017 Jun 15
45
[PATCH v6 00/41] Refactor utilities, reimplement inspection in the daemon.
v5:
https://www.redhat.com/archives/libguestfs/2017-June/msg00065.html
Since v5, this now implements inspection almost completely for Linux
and Windows guests.
Rich.
2017 Jun 21
45
[PATCH v8 00/42] Refactor utilities and reimplement inspection.
v7 was:
https://www.redhat.com/archives/libguestfs/2017-June/msg00169.html
https://www.redhat.com/archives/libguestfs/2017-June/msg00184.html
I believe this addresses all comments received so far.
Also it now passes a test where I compared about 100 disk images
processed with old and new virt-inspector binaries. The output is
identical in all cases except one which is caused by a bug in blkid