import libguestfs-1.44.0-5.module+el8.6.0+14480+c0a3aa0f
parent
e951e074b3
commit
55b111a4aa
@ -1,56 +0,0 @@
|
||||
From a5e8afb4ed8576a1b3398add2ede49a1f90ad01a Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 30 Jul 2020 13:57:45 +0100
|
||||
Subject: [PATCH] daemon, lib: Replace deprecated security_context_t with char
|
||||
*.
|
||||
|
||||
This gives deprecation warnings. It always was simply a char *, and
|
||||
the recommendation upstream is to replace uses with char *:
|
||||
|
||||
https://github.com/SELinuxProject/selinux/commit/9eb9c9327563014ad6a807814e7975424642d5b9
|
||||
(cherry picked from commit eb78e990ac5277a4282293f8787af871a1420b61)
|
||||
---
|
||||
daemon/selinux.c | 3 +--
|
||||
lib/launch-libvirt.c | 5 ++---
|
||||
2 files changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/daemon/selinux.c b/daemon/selinux.c
|
||||
index 1c1446d30..f4d839c19 100644
|
||||
--- a/daemon/selinux.c
|
||||
+++ b/daemon/selinux.c
|
||||
@@ -63,8 +63,7 @@ char *
|
||||
do_getcon (void)
|
||||
{
|
||||
#if defined(HAVE_GETCON)
|
||||
- security_context_t context;
|
||||
- char *r;
|
||||
+ char *context, *r;
|
||||
|
||||
if (getcon (&context) == -1) {
|
||||
reply_with_perror ("getcon");
|
||||
diff --git a/lib/launch-libvirt.c b/lib/launch-libvirt.c
|
||||
index bc5978cc4..4a47bbb29 100644
|
||||
--- a/lib/launch-libvirt.c
|
||||
+++ b/lib/launch-libvirt.c
|
||||
@@ -288,8 +288,7 @@ create_cow_overlay_libvirt (guestfs_h *g, void *datav, struct drive *drv)
|
||||
if (data->selinux_imagelabel) {
|
||||
debug (g, "setting SELinux label on %s to %s",
|
||||
overlay, data->selinux_imagelabel);
|
||||
- if (setfilecon (overlay,
|
||||
- (security_context_t) data->selinux_imagelabel) == -1)
|
||||
+ if (setfilecon (overlay, data->selinux_imagelabel) == -1)
|
||||
selinux_warning (g, __func__, "setfilecon", overlay);
|
||||
}
|
||||
#endif
|
||||
@@ -840,7 +839,7 @@ is_custom_hv (guestfs_h *g)
|
||||
static void
|
||||
set_socket_create_context (guestfs_h *g)
|
||||
{
|
||||
- security_context_t scon; /* this is actually a 'char *' */
|
||||
+ char *scon;
|
||||
context_t con;
|
||||
|
||||
if (getcon (&scon) == -1) {
|
||||
--
|
||||
2.18.4
|
||||
|
@ -1,36 +0,0 @@
|
||||
From 524b0c748a3a2d47b4c76e3aa546b9d4af144e6c Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Sat, 7 Dec 2019 11:08:54 +0000
|
||||
Subject: [PATCH] caml_named_value returns const value pointer in OCaml 4.09+
|
||||
|
||||
(cherry picked from ocaml-augeas
|
||||
commit 1cf5aef99b26a46529ca797547c0b49627fffe78)
|
||||
---
|
||||
common/mlaugeas/augeas-c.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/common/mlaugeas/augeas-c.c b/common/mlaugeas/augeas-c.c
|
||||
index 3e0ba67ba..3b1dc2551 100644
|
||||
--- a/common/mlaugeas/augeas-c.c
|
||||
+++ b/common/mlaugeas/augeas-c.c
|
||||
@@ -77,7 +77,7 @@ static const int error_map_len = sizeof error_map / sizeof error_map[0];
|
||||
static void
|
||||
raise_error (augeas_t t, const char *msg)
|
||||
{
|
||||
- value *exn = caml_named_value ("Augeas.Error");
|
||||
+ const value *exn = caml_named_value ("Augeas.Error");
|
||||
value args[4];
|
||||
const int code = aug_error (t);
|
||||
const char *aug_err_minor;
|
||||
@@ -113,7 +113,7 @@ raise_error (augeas_t t, const char *msg)
|
||||
static void
|
||||
raise_init_error (const char *msg)
|
||||
{
|
||||
- value *exn = caml_named_value ("Augeas.Error");
|
||||
+ const value *exn = caml_named_value ("Augeas.Error");
|
||||
value args[4];
|
||||
|
||||
args[0] = caml_alloc (1, 0);
|
||||
--
|
||||
2.18.4
|
||||
|
@ -1,78 +0,0 @@
|
||||
From 3860ab78d9fe5c34785aabc2227ebc8687b1171b Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 5 Sep 2019 09:00:14 +0100
|
||||
Subject: [PATCH] ocaml: Change calls to caml_named_value() to cope with const
|
||||
value* return.
|
||||
|
||||
In OCaml >= 4.09 the return value pointer of caml_named_value is
|
||||
declared const.
|
||||
|
||||
Based on Pino Toscano's original patch to ocaml-augeas.
|
||||
|
||||
(cherry picked from commit 9788fa50601ad4f1eab56d0b763591268026e536)
|
||||
---
|
||||
common/mlpcre/pcre-c.c | 3 +--
|
||||
common/mltools/uri-c.c | 6 ++----
|
||||
common/mlvisit/visit-c.c | 4 +---
|
||||
3 files changed, 4 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c
|
||||
index 0762a8341..07f99b8d6 100644
|
||||
--- a/common/mlpcre/pcre-c.c
|
||||
+++ b/common/mlpcre/pcre-c.c
|
||||
@@ -73,12 +73,11 @@ init (void)
|
||||
static void
|
||||
raise_pcre_error (const char *msg, int errcode)
|
||||
{
|
||||
- value *exn = caml_named_value ("PCRE.Error");
|
||||
value args[2];
|
||||
|
||||
args[0] = caml_copy_string (msg);
|
||||
args[1] = Val_int (errcode);
|
||||
- caml_raise_with_args (*exn, 2, args);
|
||||
+ caml_raise_with_args (*caml_named_value ("PCRE.Error"), 2, args);
|
||||
}
|
||||
|
||||
/* Wrap and unwrap pcre regular expression handles, with a finalizer. */
|
||||
diff --git a/common/mltools/uri-c.c b/common/mltools/uri-c.c
|
||||
index 2a8837cd9..e03647c7b 100644
|
||||
--- a/common/mltools/uri-c.c
|
||||
+++ b/common/mltools/uri-c.c
|
||||
@@ -46,10 +46,8 @@ guestfs_int_mllib_parse_uri (value argv /* arg value, not an array! */)
|
||||
int r;
|
||||
|
||||
r = parse_uri (String_val (argv), &uri);
|
||||
- if (r == -1) {
|
||||
- value *exn = caml_named_value ("URI.Parse_failed");
|
||||
- caml_raise (*exn);
|
||||
- }
|
||||
+ if (r == -1)
|
||||
+ caml_raise (*caml_named_value ("URI.Parse_failed"));
|
||||
|
||||
/* Convert the struct into an OCaml tuple. */
|
||||
rv = caml_alloc_tuple (5);
|
||||
diff --git a/common/mlvisit/visit-c.c b/common/mlvisit/visit-c.c
|
||||
index 7137c4998..201f6d762 100644
|
||||
--- a/common/mlvisit/visit-c.c
|
||||
+++ b/common/mlvisit/visit-c.c
|
||||
@@ -53,7 +53,6 @@ value
|
||||
guestfs_int_mllib_visit (value gv, value dirv, value fv)
|
||||
{
|
||||
CAMLparam3 (gv, dirv, fv);
|
||||
- value *visit_failure_exn;
|
||||
guestfs_h *g = (guestfs_h *) (intptr_t) Int64_val (gv);
|
||||
struct visitor_function_wrapper_args args;
|
||||
/* The dir string could move around when we call the
|
||||
@@ -84,8 +83,7 @@ guestfs_int_mllib_visit (value gv, value dirv, value fv)
|
||||
* already printed the error to stderr (XXX - fix), so we raise a
|
||||
* generic exception.
|
||||
*/
|
||||
- visit_failure_exn = caml_named_value ("Visit.Failure");
|
||||
- caml_raise (*visit_failure_exn);
|
||||
+ caml_raise (*caml_named_value ("Visit.Failure"));
|
||||
}
|
||||
free (dir);
|
||||
|
||||
--
|
||||
2.18.4
|
||||
|
@ -1,121 +0,0 @@
|
||||
From 5c5cc8b7bc2588c04dd0d0472b466f978f8ac55c Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 6 Feb 2020 10:17:35 +0000
|
||||
Subject: [PATCH] ocaml: Use caml_alloc_initialized_string instead of memcpy.
|
||||
|
||||
See this commit in libguestfs-common:
|
||||
https://github.com/libguestfs/libguestfs-common/commit/398dc56a6cb5d6d01506338fa94ef580e668d5e9
|
||||
|
||||
(cherry picked from commit 9f3148c791a970b7d6adf249e949a1b7e0b4b0c1)
|
||||
---
|
||||
generator/OCaml.ml | 10 ++++------
|
||||
m4/guestfs-ocaml.m4 | 18 ++++++++++++++++++
|
||||
ocaml/guestfs-c.c | 3 +--
|
||||
ocaml/guestfs-c.h | 18 ++++++++++++++++++
|
||||
4 files changed, 41 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/generator/OCaml.ml b/generator/OCaml.ml
|
||||
index bd4f73b85..1b6970f6d 100644
|
||||
--- a/generator/OCaml.ml
|
||||
+++ b/generator/OCaml.ml
|
||||
@@ -504,12 +504,11 @@ copy_table (char * const * argv)
|
||||
| name, FString ->
|
||||
pr " v = caml_copy_string (%s->%s);\n" typ name
|
||||
| name, FBuffer ->
|
||||
- pr " v = caml_alloc_string (%s->%s_len);\n" typ name;
|
||||
- pr " memcpy (String_val (v), %s->%s, %s->%s_len);\n"
|
||||
+ pr " v = caml_alloc_initialized_string (%s->%s_len, %s->%s);\n"
|
||||
typ name typ name
|
||||
| name, FUUID ->
|
||||
- pr " v = caml_alloc_string (32);\n";
|
||||
- pr " memcpy (String_val (v), %s->%s, 32);\n" typ name
|
||||
+ pr " v = caml_alloc_initialized_string (32, %s->%s);\n"
|
||||
+ typ name
|
||||
| name, (FBytes|FInt64|FUInt64) ->
|
||||
pr " v = caml_copy_int64 (%s->%s);\n" typ name
|
||||
| name, (FInt32|FUInt32) ->
|
||||
@@ -757,8 +756,7 @@ copy_table (char * const * argv)
|
||||
pr " for (i = 0; r[i] != NULL; ++i) free (r[i]);\n";
|
||||
pr " free (r);\n";
|
||||
| RBufferOut _ ->
|
||||
- pr " rv = caml_alloc_string (size);\n";
|
||||
- pr " memcpy (String_val (rv), r, size);\n";
|
||||
+ pr " rv = caml_alloc_initialized_string (size, r);\n";
|
||||
pr " free (r);\n"
|
||||
);
|
||||
|
||||
diff --git a/m4/guestfs-ocaml.m4 b/m4/guestfs-ocaml.m4
|
||||
index 3c504ce7e..90658e8c5 100644
|
||||
--- a/m4/guestfs-ocaml.m4
|
||||
+++ b/m4/guestfs-ocaml.m4
|
||||
@@ -221,6 +221,24 @@ AS_IF([test "x$have_Hivex_OPEN_UNSAFE" = "xno"],[
|
||||
])
|
||||
AC_SUBST([HIVEX_OPEN_UNSAFE_FLAG])
|
||||
|
||||
+dnl Check if OCaml has caml_alloc_initialized_string (added 2017).
|
||||
+AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
|
||||
+ test "x$enable_ocaml" = "xyes"],[
|
||||
+ AC_MSG_CHECKING([for caml_alloc_initialized_string])
|
||||
+ cat >conftest.c <<'EOF'
|
||||
+#include <caml/alloc.h>
|
||||
+int main () { char *p = (void *) caml_alloc_initialized_string; return 0; }
|
||||
+EOF
|
||||
+ AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[
|
||||
+ AC_MSG_RESULT([yes])
|
||||
+ AC_DEFINE([HAVE_CAML_ALLOC_INITIALIZED_STRING],[1],
|
||||
+ [caml_alloc_initialized_string found at compile time.])
|
||||
+ ],[
|
||||
+ AC_MSG_RESULT([no])
|
||||
+ ])
|
||||
+ rm -f conftest.c conftest.o
|
||||
+])
|
||||
+
|
||||
dnl Flags we want to pass to every OCaml compiler call.
|
||||
OCAML_WARN_ERROR="-warn-error CDEFLMPSUVYZX+52-3"
|
||||
AC_SUBST([OCAML_WARN_ERROR])
|
||||
diff --git a/ocaml/guestfs-c.c b/ocaml/guestfs-c.c
|
||||
index 3b5fb198f..18d7dd978 100644
|
||||
--- a/ocaml/guestfs-c.c
|
||||
+++ b/ocaml/guestfs-c.c
|
||||
@@ -360,8 +360,7 @@ event_callback_wrapper_locked (guestfs_h *g,
|
||||
|
||||
ehv = Val_int (event_handle);
|
||||
|
||||
- bufv = caml_alloc_string (buf_len);
|
||||
- memcpy (String_val (bufv), buf, buf_len);
|
||||
+ bufv = caml_alloc_initialized_string (buf_len, buf);
|
||||
|
||||
arrayv = caml_alloc (array_len, 0);
|
||||
for (i = 0; i < array_len; ++i) {
|
||||
diff --git a/ocaml/guestfs-c.h b/ocaml/guestfs-c.h
|
||||
index f05dbd8e7..93ad3e2bf 100644
|
||||
--- a/ocaml/guestfs-c.h
|
||||
+++ b/ocaml/guestfs-c.h
|
||||
@@ -19,6 +19,24 @@
|
||||
#ifndef GUESTFS_OCAML_C_H
|
||||
#define GUESTFS_OCAML_C_H
|
||||
|
||||
+#include "config.h"
|
||||
+
|
||||
+#include <caml/alloc.h>
|
||||
+#include <caml/mlvalues.h>
|
||||
+
|
||||
+/* Replacement if caml_alloc_initialized_string is missing, added
|
||||
+ * to OCaml runtime in 2017.
|
||||
+ */
|
||||
+#ifndef HAVE_CAML_ALLOC_INITIALIZED_STRING
|
||||
+static inline value
|
||||
+caml_alloc_initialized_string (mlsize_t len, const char *p)
|
||||
+{
|
||||
+ value sv = caml_alloc_string (len);
|
||||
+ memcpy ((char *) String_val (sv), p, len);
|
||||
+ return sv;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
#define Guestfs_val(v) (*((guestfs_h **)Data_custom_val(v)))
|
||||
extern void guestfs_int_ocaml_raise_error (guestfs_h *g, const char *func)
|
||||
Noreturn;
|
||||
--
|
||||
2.18.4
|
||||
|
@ -0,0 +1,69 @@
|
||||
From cb2ac63562447e2780bd7103ed060fd6013b9054 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Tue, 7 Jul 2015 09:28:03 -0400
|
||||
Subject: [PATCH] RHEL 8: Reject use of libguestfs-winsupport features except
|
||||
for virt-* tools (RHBZ#1240276).
|
||||
|
||||
Fix the tests: it doesn't let us use guestfish for arbitrary Windows
|
||||
edits.
|
||||
---
|
||||
generator/c.ml | 16 ++++++++++++++++
|
||||
test-data/phony-guests/make-windows-img.sh | 1 +
|
||||
tests/charsets/test-charset-fidelity.c | 2 ++
|
||||
3 files changed, 19 insertions(+)
|
||||
|
||||
diff --git a/generator/c.ml b/generator/c.ml
|
||||
index 86d3b26f8..a625361a9 100644
|
||||
--- a/generator/c.ml
|
||||
+++ b/generator/c.ml
|
||||
@@ -1846,6 +1846,22 @@ and generate_client_actions actions () =
|
||||
check_args_validity c_name style;
|
||||
trace_call name c_name style;
|
||||
|
||||
+ (* RHEL 8 *)
|
||||
+ if name = "mount" || name = "mount_ro" || name = "mount_options" ||
|
||||
+ name = "mount_vfs" then (
|
||||
+ pr " if (g->program && !STRPREFIX (g->program, \"virt-\")) {\n";
|
||||
+ pr " CLEANUP_FREE char *vfs_type = guestfs_vfs_type (g, mountable);\n";
|
||||
+ pr " if (vfs_type && STREQ (vfs_type, \"ntfs\")) {\n";
|
||||
+ pr " error (g, \"mount: unsupported filesystem type\");\n";
|
||||
+ pr " if (trace_flag)\n";
|
||||
+ pr " guestfs_int_trace (g, \"%%s = %%s (error)\",\n";
|
||||
+ pr " \"%s\", \"-1\");\n" name;
|
||||
+ pr " return %s;\n" (string_of_errcode errcode);
|
||||
+ pr " }\n";
|
||||
+ pr " }\n";
|
||||
+ pr "\n";
|
||||
+ );
|
||||
+
|
||||
(* Calculate the total size of all FileIn arguments to pass
|
||||
* as a progress bar hint.
|
||||
*)
|
||||
diff --git a/test-data/phony-guests/make-windows-img.sh b/test-data/phony-guests/make-windows-img.sh
|
||||
index 30908a918..73cf5144e 100755
|
||||
--- a/test-data/phony-guests/make-windows-img.sh
|
||||
+++ b/test-data/phony-guests/make-windows-img.sh
|
||||
@@ -37,6 +37,7 @@ fi
|
||||
|
||||
# Create a disk image.
|
||||
guestfish <<EOF
|
||||
+set-program virt-testing
|
||||
sparse windows.img-t 512M
|
||||
run
|
||||
|
||||
diff --git a/tests/charsets/test-charset-fidelity.c b/tests/charsets/test-charset-fidelity.c
|
||||
index 39ccc2068..2b2e2d8a9 100644
|
||||
--- a/tests/charsets/test-charset-fidelity.c
|
||||
+++ b/tests/charsets/test-charset-fidelity.c
|
||||
@@ -94,6 +94,8 @@ main (int argc, char *argv[])
|
||||
if (g == NULL)
|
||||
error (EXIT_FAILURE, 0, "failed to create handle");
|
||||
|
||||
+ guestfs_set_program (g, "virt-testing");
|
||||
+
|
||||
if (guestfs_add_drive_scratch (g, 1024*1024*1024, -1) == -1)
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
--
|
||||
2.31.1
|
||||
|
@ -1,125 +0,0 @@
|
||||
From 3b4082b239ec0976b366293067e42f91d56cfcd5 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 6 Feb 2020 10:15:29 +0000
|
||||
Subject: [PATCH] ocaml: Use caml_alloc_initialized_string instead of memcpy.
|
||||
|
||||
Since about 2017 OCaml has had a function for creating an initialized
|
||||
string. This uses the function instead of caml_alloc_string + memcpy
|
||||
(which doesn't work for OCaml 4.10) and defines a replacement if the
|
||||
function is missing.
|
||||
|
||||
Note this requires configure.ac in libguestfs.git and virt-v2v.git to
|
||||
define HAVE_CAML_ALLOC_INITIALIZED_STRING.
|
||||
|
||||
(cherry picked from commit 398dc56a6cb5d6d01506338fa94ef580e668d5e9)
|
||||
---
|
||||
common/mlpcre/pcre-c.c | 16 ++++++++++++++--
|
||||
common/mlvisit/visit-c.c | 16 ++++++++++++++--
|
||||
common/mlxml/xml-c.c | 16 ++++++++++++++--
|
||||
3 files changed, 42 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c
|
||||
index 07f99b8d6..7dbba5857 100644
|
||||
--- a/common/mlpcre/pcre-c.c
|
||||
+++ b/common/mlpcre/pcre-c.c
|
||||
@@ -39,6 +39,19 @@
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
+/* Replacement if caml_alloc_initialized_string is missing, added
|
||||
+ * to OCaml runtime in 2017.
|
||||
+ */
|
||||
+#ifndef HAVE_CAML_ALLOC_INITIALIZED_STRING
|
||||
+static inline value
|
||||
+caml_alloc_initialized_string (mlsize_t len, const char *p)
|
||||
+{
|
||||
+ value sv = caml_alloc_string (len);
|
||||
+ memcpy ((char *) String_val (sv), p, len);
|
||||
+ return sv;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/* Data on the most recent match is stored in this thread-local
|
||||
* variable. It is freed either by the next call to PCRE.matches or
|
||||
* by (clean) thread exit.
|
||||
@@ -257,8 +270,7 @@ guestfs_int_pcre_sub (value nv)
|
||||
if (len < 0)
|
||||
raise_pcre_error ("pcre_get_substring", len);
|
||||
|
||||
- strv = caml_alloc_string (len);
|
||||
- memcpy (String_val (strv), str, len);
|
||||
+ strv = caml_alloc_initialized_string (len, str);
|
||||
CAMLreturn (strv);
|
||||
}
|
||||
|
||||
diff --git a/common/mlvisit/visit-c.c b/common/mlvisit/visit-c.c
|
||||
index 201f6d762..d5585ca94 100644
|
||||
--- a/common/mlvisit/visit-c.c
|
||||
+++ b/common/mlvisit/visit-c.c
|
||||
@@ -35,6 +35,19 @@
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
+/* Replacement if caml_alloc_initialized_string is missing, added
|
||||
+ * to OCaml runtime in 2017.
|
||||
+ */
|
||||
+#ifndef HAVE_CAML_ALLOC_INITIALIZED_STRING
|
||||
+static inline value
|
||||
+caml_alloc_initialized_string (mlsize_t len, const char *p)
|
||||
+{
|
||||
+ value sv = caml_alloc_string (len);
|
||||
+ memcpy ((char *) String_val (sv), p, len);
|
||||
+ return sv;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
struct visitor_function_wrapper_args {
|
||||
/* In both case we are pointing to local roots, hence why these are
|
||||
* value* not value.
|
||||
@@ -198,8 +211,7 @@ copy_xattr (const struct guestfs_xattr *xattr)
|
||||
rv = caml_alloc (2, 0);
|
||||
v = caml_copy_string (xattr->attrname);
|
||||
Store_field (rv, 0, v);
|
||||
- v = caml_alloc_string (xattr->attrval_len);
|
||||
- memcpy (String_val (v), xattr->attrval, xattr->attrval_len);
|
||||
+ v = caml_alloc_initialized_string (xattr->attrval_len, xattr->attrval);
|
||||
Store_field (rv, 1, v);
|
||||
CAMLreturn (rv);
|
||||
}
|
||||
diff --git a/common/mlxml/xml-c.c b/common/mlxml/xml-c.c
|
||||
index d3db7e227..a0fa0fc3d 100644
|
||||
--- a/common/mlxml/xml-c.c
|
||||
+++ b/common/mlxml/xml-c.c
|
||||
@@ -40,6 +40,19 @@
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
+/* Replacement if caml_alloc_initialized_string is missing, added
|
||||
+ * to OCaml runtime in 2017.
|
||||
+ */
|
||||
+#ifndef HAVE_CAML_ALLOC_INITIALIZED_STRING
|
||||
+static inline value
|
||||
+caml_alloc_initialized_string (mlsize_t len, const char *p)
|
||||
+{
|
||||
+ value sv = caml_alloc_string (len);
|
||||
+ memcpy ((char *) String_val (sv), p, len);
|
||||
+ return sv;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/* xmlDocPtr type */
|
||||
#define docptr_val(v) (*((xmlDocPtr *)Data_custom_val(v)))
|
||||
|
||||
@@ -183,8 +196,7 @@ mllib_xml_to_string (value docv, value formatv)
|
||||
doc = docptr_val (docv);
|
||||
xmlDocDumpFormatMemory (doc, &mem, &size, Bool_val (formatv));
|
||||
|
||||
- strv = caml_alloc_string (size);
|
||||
- memcpy (String_val (strv), mem, size);
|
||||
+ strv = caml_alloc_initialized_string (size, mem);
|
||||
free (mem);
|
||||
|
||||
CAMLreturn (strv);
|
||||
--
|
||||
2.18.4
|
||||
|
@ -0,0 +1,37 @@
|
||||
From dbd1eaab6a478cf0c3ea093a56b3d04c29278615 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Tue, 12 Jan 2021 10:23:11 +0000
|
||||
Subject: [PATCH] build: Avoid warnings about unknown pragmas.
|
||||
|
||||
In commit 4bbbf03b8bc266ed2b63c461cd0945250bb134fe we started to
|
||||
ignore bogus GCC 11 warnings. Unfortunately earlier versions of GCC
|
||||
don't know about those pragmas so give warnings [hence errors in
|
||||
developer builds] like:
|
||||
|
||||
tsk.c:75:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
|
||||
|
||||
Turn off these warnings.
|
||||
|
||||
Updates: commit 4bbbf03b8bc266ed2b63c461cd0945250bb134fe
|
||||
(cherry picked from commit 812f837c97f48ce0c26a0e02286fb9180c282923)
|
||||
---
|
||||
m4/guestfs-c.m4 | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/m4/guestfs-c.m4 b/m4/guestfs-c.m4
|
||||
index 25ffea0d9..bbb4db464 100644
|
||||
--- a/m4/guestfs-c.m4
|
||||
+++ b/m4/guestfs-c.m4
|
||||
@@ -108,6 +108,9 @@ gl_WARN_ADD([-Wformat-truncation=1])
|
||||
dnl GCC 9 at level 2 gives apparently bogus errors when %.*s is used.
|
||||
gl_WARN_ADD([-Wformat-overflow=1])
|
||||
|
||||
+dnl GCC < 11 gives warnings when disabling GCC 11 warnings.
|
||||
+gl_WARN_ADD([-Wno-pragmas])
|
||||
+
|
||||
AC_SUBST([WARN_CFLAGS])
|
||||
|
||||
NO_SNV_CFLAGS=
|
||||
--
|
||||
2.31.1
|
||||
|
@ -1,32 +0,0 @@
|
||||
From 96462b30d5ca6e45601512609cedfc874739137d Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 5 Sep 2019 09:00:14 +0100
|
||||
Subject: [PATCH] ocaml: Change calls to caml_named_value() to cope with const
|
||||
value* return.
|
||||
|
||||
In OCaml >= 4.09 the return value pointer of caml_named_value is
|
||||
declared const.
|
||||
|
||||
Based on Pino Toscano's original patch to ocaml-augeas.
|
||||
|
||||
(cherry picked from commit 74ce7332dbb9bab2a69737257f0d07c93eb9bab4)
|
||||
---
|
||||
generator/daemon.ml | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/generator/daemon.ml b/generator/daemon.ml
|
||||
index a4e136aaa..b67c4d20b 100644
|
||||
--- a/generator/daemon.ml
|
||||
+++ b/generator/daemon.ml
|
||||
@@ -746,7 +746,7 @@ let generate_daemon_caml_stubs () =
|
||||
let nr_args = List.length args_do_function in
|
||||
|
||||
pr "{\n";
|
||||
- pr " static value *cb = NULL;\n";
|
||||
+ pr " static const value *cb = NULL;\n";
|
||||
pr " CAMLparam0 ();\n";
|
||||
pr " CAMLlocal2 (v, retv);\n";
|
||||
pr " CAMLlocalN (args, %d);\n"
|
||||
--
|
||||
2.18.4
|
||||
|
@ -1,34 +0,0 @@
|
||||
From 93422725a0a8248d97b67cdbc20e065f5164e089 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 6 Feb 2020 10:27:48 +0000
|
||||
Subject: [PATCH] cat: Fix GCC 10 warning.
|
||||
|
||||
I believe this warning is bogus, but simply initializing the local
|
||||
variable is enough to avoid it.
|
||||
|
||||
log.c: In function 'do_log':
|
||||
log.c:390:7: error: 'comm_len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
|
||||
390 | printf (" %.*s", (int) comm_len, comm);
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
(cherry picked from commit 4e199494c41d3240aa5c0708887b7a7513c6b6f2)
|
||||
---
|
||||
cat/log.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/cat/log.c b/cat/log.c
|
||||
index 25107e25f..f8a5c85f2 100644
|
||||
--- a/cat/log.c
|
||||
+++ b/cat/log.c
|
||||
@@ -337,7 +337,7 @@ do_log_journal (void)
|
||||
while ((r = guestfs_journal_next (g)) > 0) {
|
||||
CLEANUP_FREE_XATTR_LIST struct guestfs_xattr_list *xattrs = NULL;
|
||||
const char *priority_str, *identifier, *comm, *pid, *message;
|
||||
- size_t priority_len, identifier_len, comm_len, pid_len, message_len;
|
||||
+ size_t priority_len, identifier_len, comm_len = 0, pid_len, message_len;
|
||||
int priority = LOG_INFO;
|
||||
int64_t ts;
|
||||
|
||||
--
|
||||
2.18.4
|
||||
|
@ -1,29 +0,0 @@
|
||||
From 17df30b82007073a40deb37ff7f840d56a1b5bf1 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 6 Feb 2020 10:33:39 +0000
|
||||
Subject: [PATCH] builder: Fix const correctness for OCaml 4.10.
|
||||
|
||||
String_val now returns a const char *.
|
||||
|
||||
(cherry picked from commit d6fcf519f2d860fe3167629f042f5ff6a4ccc40d)
|
||||
---
|
||||
builder/setlocale-c.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/builder/setlocale-c.c b/builder/setlocale-c.c
|
||||
index f2ad85352..6d877e7ac 100644
|
||||
--- a/builder/setlocale-c.c
|
||||
+++ b/builder/setlocale-c.c
|
||||
@@ -44,7 +44,8 @@ virt_builder_setlocale (value val_category, value val_name)
|
||||
{
|
||||
CAMLparam2 (val_category, val_name);
|
||||
CAMLlocal2 (rv, rv2);
|
||||
- char *ret, *locstring;
|
||||
+ const char *locstring;
|
||||
+ char *ret;
|
||||
int category;
|
||||
|
||||
category = lc_string_table[Int_val (val_category)];
|
||||
--
|
||||
2.18.4
|
||||
|
@ -0,0 +1,113 @@
|
||||
From e1b339688e5f8f2a14fe0c7e9d02ad68004e4655 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 15 Apr 2021 09:18:22 +0100
|
||||
Subject: [PATCH] inspection: More reliable detection of Linux split /usr
|
||||
configurations
|
||||
|
||||
In RHEL 8+, /usr/etc no longer exists. Since we were looking for this
|
||||
directory in order to detect a separate /usr partition, those were no
|
||||
longer detected, so the merging of /usr data into the root was not
|
||||
being done. The result was incomplete inspection data and failure of
|
||||
virt-v2v.
|
||||
|
||||
All Linux systems since forever have had /usr/src but not /src, so
|
||||
detect this instead.
|
||||
|
||||
Furthermore the merging code didn't work, because we expected that the
|
||||
root filesystem had a distro assigned, but in this configuration we
|
||||
may need to look for that information in /usr/lib/os-release (not on
|
||||
the root filesystem). This change makes the merging work even if we
|
||||
have incomplete information about the root filesystem, so long as we
|
||||
have an /etc/fstab entry pointing to the /usr mountpoint.
|
||||
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1949683
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1930133
|
||||
Fixes: commit 394d11be49121884295e61964ed47f5a8488c252
|
||||
(cherry picked from commit 26427b9ecc64e7e5e53a1d577cef9dc080d08877)
|
||||
---
|
||||
daemon/inspect.ml | 33 +++++++++++++++------------------
|
||||
daemon/inspect_fs.ml | 6 +++---
|
||||
2 files changed, 18 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/daemon/inspect.ml b/daemon/inspect.ml
|
||||
index 945a476f6..fb75b4a6c 100644
|
||||
--- a/daemon/inspect.ml
|
||||
+++ b/daemon/inspect.ml
|
||||
@@ -182,11 +182,9 @@ and check_for_duplicated_bsd_root fses =
|
||||
and collect_linux_inspection_info fses =
|
||||
List.map (
|
||||
function
|
||||
- | { role = RoleRoot { distro = Some d } } as root ->
|
||||
- if d <> DISTRO_COREOS then
|
||||
- collect_linux_inspection_info_for fses root
|
||||
- else
|
||||
- root
|
||||
+ | { role = RoleRoot { distro = Some DISTRO_COREOS } } as root -> root
|
||||
+ | { role = RoleRoot _ } as root ->
|
||||
+ collect_linux_inspection_info_for fses root
|
||||
| fs -> fs
|
||||
) fses
|
||||
|
||||
@@ -196,29 +194,28 @@ and collect_linux_inspection_info fses =
|
||||
* or other ways to identify the OS).
|
||||
*)
|
||||
and collect_linux_inspection_info_for fses root =
|
||||
- let root_distro, root_fstab =
|
||||
+ let root_fstab =
|
||||
match root with
|
||||
- | { role = RoleRoot { distro = Some d; fstab = f } } -> d, f
|
||||
+ | { role = RoleRoot { fstab = f } } -> f
|
||||
| _ -> assert false in
|
||||
|
||||
try
|
||||
let usr =
|
||||
List.find (
|
||||
function
|
||||
- | { role = RoleUsr { distro = d } }
|
||||
- when d = Some root_distro || d = None -> true
|
||||
+ | { role = RoleUsr _; fs_location = usr_mp } ->
|
||||
+ (* This checks that this usr is found in the fstab of
|
||||
+ * the root filesystem.
|
||||
+ *)
|
||||
+ List.exists (
|
||||
+ fun (mountable, _) ->
|
||||
+ usr_mp.mountable = mountable
|
||||
+ ) root_fstab
|
||||
| _ -> false
|
||||
) fses in
|
||||
|
||||
- let usr_mountable = usr.fs_location.mountable in
|
||||
-
|
||||
- (* This checks that [usr] is found in the fstab of the root
|
||||
- * filesystem. If not, [Not_found] is thrown.
|
||||
- *)
|
||||
- ignore (
|
||||
- List.find (fun (mountable, _) -> usr_mountable = mountable) root_fstab
|
||||
- );
|
||||
-
|
||||
+ eprintf "collect_linux_inspection_info_for: merging:\n%sinto:\n%s"
|
||||
+ (string_of_fs usr) (string_of_fs root);
|
||||
merge usr root;
|
||||
root
|
||||
with
|
||||
diff --git a/daemon/inspect_fs.ml b/daemon/inspect_fs.ml
|
||||
index 6e00c7083..02b5a0470 100644
|
||||
--- a/daemon/inspect_fs.ml
|
||||
+++ b/daemon/inspect_fs.ml
|
||||
@@ -164,10 +164,10 @@ and check_filesystem mountable =
|
||||
()
|
||||
)
|
||||
(* Linux /usr? *)
|
||||
- else if Is.is_dir "/etc" &&
|
||||
- Is.is_dir "/bin" &&
|
||||
- Is.is_dir "/share" &&
|
||||
+ else if Is.is_dir "/bin" &&
|
||||
Is.is_dir "/local" &&
|
||||
+ Is.is_dir "/share" &&
|
||||
+ Is.is_dir "/src" &&
|
||||
not (Is.is_file "/etc/fstab") then (
|
||||
debug_matching "Linux /usr";
|
||||
role := `Usr;
|
||||
--
|
||||
2.31.1
|
||||
|
@ -0,0 +1,49 @@
|
||||
From 791a16b049ea1ce2c450acd367fce774d9aab5b1 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Tue, 31 Aug 2021 08:27:15 +0100
|
||||
Subject: [PATCH] lib: Autodetect backing format for qemu-img create -b
|
||||
|
||||
qemu 6.1 has decided to change qemu-img create so that a backing
|
||||
format (-F) is required if a backing file (-b) is specified. Since we
|
||||
don't want to change the libguestfs API to force callers to specify
|
||||
this because that would be an API break, autodetect it.
|
||||
|
||||
This is similar to commit c8c181e8d9 ("launch: libvirt: Autodetect
|
||||
backing format for readonly drive overlays").
|
||||
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1998820
|
||||
(cherry picked from commit 45de287447bb18d59749fbfc1ec5072413090109)
|
||||
---
|
||||
lib/create.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/lib/create.c b/lib/create.c
|
||||
index 44a7df25f..75a4d3a28 100644
|
||||
--- a/lib/create.c
|
||||
+++ b/lib/create.c
|
||||
@@ -255,6 +255,7 @@ disk_create_qcow2 (guestfs_h *g, const char *filename, int64_t size,
|
||||
const struct guestfs_disk_create_argv *optargs)
|
||||
{
|
||||
const char *backingformat = NULL;
|
||||
+ CLEANUP_FREE char *backingformat_free = NULL;
|
||||
const char *preallocation = NULL;
|
||||
const char *compat = NULL;
|
||||
int clustersize = -1;
|
||||
@@ -270,6 +271,14 @@ disk_create_qcow2 (guestfs_h *g, const char *filename, int64_t size,
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+ else if (backingfile) {
|
||||
+ /* Since qemu 6.1, qemu-img create has requires a backing format (-F)
|
||||
+ * parameter if backing file (-b) is used (RHBZ#1998820).
|
||||
+ */
|
||||
+ backingformat = backingformat_free = guestfs_disk_format (g, backingfile);
|
||||
+ if (!backingformat)
|
||||
+ return -1;
|
||||
+ }
|
||||
if (optargs->bitmask & GUESTFS_DISK_CREATE_PREALLOCATION_BITMASK) {
|
||||
if (STREQ (optargs->preallocation, "off") ||
|
||||
STREQ (optargs->preallocation, "sparse"))
|
||||
--
|
||||
2.31.1
|
||||
|
@ -1,33 +0,0 @@
|
||||
From 8eb9f06b156c6362a17712cfed9c629dec297a2c Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 6 Feb 2020 10:22:42 +0000
|
||||
Subject: [PATCH] mlxml: Fix pointed target signedness.
|
||||
|
||||
xml-c.c: In function 'mllib_xml_to_string':
|
||||
xml-c.c:199:47: error: pointer targets in passing argument 2 of 'caml_alloc_initialized_string' differ in signedness [-Werror=pointer-sign]
|
||||
199 | strv = caml_alloc_initialized_string (size, mem);
|
||||
| ^~~
|
||||
| |
|
||||
| xmlChar * {aka unsigned char *}
|
||||
|
||||
(cherry picked from commit ea10827b4cfb3cfe5f782421c01d2902e5f73f90)
|
||||
---
|
||||
common/mlxml/xml-c.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/common/mlxml/xml-c.c b/common/mlxml/xml-c.c
|
||||
index a0fa0fc3d..715c3bb24 100644
|
||||
--- a/common/mlxml/xml-c.c
|
||||
+++ b/common/mlxml/xml-c.c
|
||||
@@ -196,7 +196,7 @@ mllib_xml_to_string (value docv, value formatv)
|
||||
doc = docptr_val (docv);
|
||||
xmlDocDumpFormatMemory (doc, &mem, &size, Bool_val (formatv));
|
||||
|
||||
- strv = caml_alloc_initialized_string (size, mem);
|
||||
+ strv = caml_alloc_initialized_string (size, (const char *) mem);
|
||||
free (mem);
|
||||
|
||||
CAMLreturn (strv);
|
||||
--
|
||||
2.18.4
|
||||
|
@ -1,126 +0,0 @@
|
||||
From 83c76b6c610df17e0b9bfd9cd11deb43ebc40411 Mon Sep 17 00:00:00 2001
|
||||
From: Pino Toscano <ptoscano@redhat.com>
|
||||
Date: Tue, 19 Feb 2019 10:50:01 +0100
|
||||
Subject: [PATCH] common/mlpcre: add offset flag for PCRE.matches
|
||||
|
||||
This way it is possible to change where the matching start, instead of
|
||||
always assuming it is the beginning.
|
||||
|
||||
(cherry picked from commit 0ed2e5c14a302d15fd3b75ee2c1cb808a06cb746)
|
||||
---
|
||||
common/mlpcre/PCRE.ml | 2 +-
|
||||
common/mlpcre/PCRE.mli | 5 ++++-
|
||||
common/mlpcre/pcre-c.c | 16 +++++++++++++---
|
||||
common/mlpcre/pcre_tests.ml | 11 ++++++++---
|
||||
4 files changed, 26 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/common/mlpcre/PCRE.ml b/common/mlpcre/PCRE.ml
|
||||
index b054928f9..33074af1c 100644
|
||||
--- a/common/mlpcre/PCRE.ml
|
||||
+++ b/common/mlpcre/PCRE.ml
|
||||
@@ -23,7 +23,7 @@ exception Error of string * int
|
||||
type regexp
|
||||
|
||||
external compile : ?anchored:bool -> ?caseless:bool -> ?dotall:bool -> ?extended:bool -> ?multiline:bool -> string -> regexp = "guestfs_int_pcre_compile_byte" "guestfs_int_pcre_compile"
|
||||
-external matches : regexp -> string -> bool = "guestfs_int_pcre_matches"
|
||||
+external matches : ?offset:int -> regexp -> string -> bool = "guestfs_int_pcre_matches"
|
||||
external sub : int -> string = "guestfs_int_pcre_sub"
|
||||
external subi : int -> int * int = "guestfs_int_pcre_subi"
|
||||
|
||||
diff --git a/common/mlpcre/PCRE.mli b/common/mlpcre/PCRE.mli
|
||||
index eacb6fd90..e10d512fc 100644
|
||||
--- a/common/mlpcre/PCRE.mli
|
||||
+++ b/common/mlpcre/PCRE.mli
|
||||
@@ -62,7 +62,7 @@ val compile : ?anchored:bool -> ?caseless:bool -> ?dotall:bool -> ?extended:bool
|
||||
See pcreapi(3) for details of what they do.
|
||||
All flags default to false. *)
|
||||
|
||||
-val matches : regexp -> string -> bool
|
||||
+val matches : ?offset:int -> regexp -> string -> bool
|
||||
(** Test whether the regular expression matches the string. This
|
||||
returns true if the regexp matches or false otherwise.
|
||||
|
||||
@@ -71,6 +71,9 @@ val matches : regexp -> string -> bool
|
||||
or the thread/program exits. You can call {!sub} to return
|
||||
these substrings.
|
||||
|
||||
+ The [?offset] flag is used to change the start of the search,
|
||||
+ which by default is at the beginning of the string (position 0).
|
||||
+
|
||||
This can raise {!Error} if PCRE returns an error. *)
|
||||
|
||||
val sub : int -> string
|
||||
diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c
|
||||
index 7dbba5857..ec3a6f00d 100644
|
||||
--- a/common/mlpcre/pcre-c.c
|
||||
+++ b/common/mlpcre/pcre-c.c
|
||||
@@ -133,6 +133,15 @@ is_Some_true (value v)
|
||||
Bool_val (Field (v, 0)) /* Some true */;
|
||||
}
|
||||
|
||||
+static int
|
||||
+Optint_val (value intv, int defval)
|
||||
+{
|
||||
+ if (intv == Val_int (0)) /* None */
|
||||
+ return defval;
|
||||
+ else /* Some int */
|
||||
+ return Int_val (Field (intv, 0));
|
||||
+}
|
||||
+
|
||||
value
|
||||
guestfs_int_pcre_compile (value anchoredv, value caselessv, value dotallv,
|
||||
value extendedv, value multilinev,
|
||||
@@ -177,9 +186,9 @@ guestfs_int_pcre_compile_byte (value *argv, int argn)
|
||||
}
|
||||
|
||||
value
|
||||
-guestfs_int_pcre_matches (value rev, value strv)
|
||||
+guestfs_int_pcre_matches (value offsetv, value rev, value strv)
|
||||
{
|
||||
- CAMLparam2 (rev, strv);
|
||||
+ CAMLparam3 (offsetv, rev, strv);
|
||||
pcre *re = Regexp_val (rev);
|
||||
struct last_match *m, *oldm;
|
||||
size_t len = caml_string_length (strv);
|
||||
@@ -217,7 +226,8 @@ guestfs_int_pcre_matches (value rev, value strv)
|
||||
caml_raise_out_of_memory ();
|
||||
}
|
||||
|
||||
- m->r = pcre_exec (re, NULL, m->subject, len, 0, 0, m->vec, veclen);
|
||||
+ m->r = pcre_exec (re, NULL, m->subject, len, Optint_val (offsetv, 0), 0,
|
||||
+ m->vec, veclen);
|
||||
if (m->r < 0 && m->r != PCRE_ERROR_NOMATCH) {
|
||||
int ret = m->r;
|
||||
free_last_match (m);
|
||||
diff --git a/common/mlpcre/pcre_tests.ml b/common/mlpcre/pcre_tests.ml
|
||||
index 346019c40..3e5981107 100644
|
||||
--- a/common/mlpcre/pcre_tests.ml
|
||||
+++ b/common/mlpcre/pcre_tests.ml
|
||||
@@ -30,9 +30,9 @@ let compile ?(anchored = false) ?(caseless = false)
|
||||
patt;
|
||||
PCRE.compile ~anchored ~caseless ~dotall ~extended ~multiline patt
|
||||
|
||||
-let matches re str =
|
||||
- eprintf "PCRE.matches %s ->%!" str;
|
||||
- let r = PCRE.matches re str in
|
||||
+let matches ?(offset = 0) re str =
|
||||
+ eprintf "PCRE.matches %s, %d ->%!" str offset;
|
||||
+ let r = PCRE.matches ~offset re str in
|
||||
eprintf " %b\n%!" r;
|
||||
r
|
||||
|
||||
@@ -103,6 +103,11 @@ let () =
|
||||
assert (subi 1 = (2, 3));
|
||||
assert (subi 2 = (3, 3));
|
||||
|
||||
+ assert (matches ~offset:5 re0 "aaabcabc" = true);
|
||||
+ assert (sub 0 = "ab");
|
||||
+
|
||||
+ assert (matches ~offset:5 re0 "aaabcbaac" = false);
|
||||
+
|
||||
assert (replace re0 "dd" "abcabcaabccca" = "ddcabcaabccca");
|
||||
assert (replace ~global:true re0 "dd" "abcabcaabccca" = "ddcddcddccca");
|
||||
|
||||
--
|
||||
2.18.4
|
||||
|