search for: raise_pcre_error

Displaying 9 results from an estimated 9 matches for "raise_pcre_error".

2018 Apr 27
1
[PATCH] common/mlpcre: fix access to freed memory
...++ b/common/mlpcre/pcre-c.c @@ -207,8 +207,9 @@ guestfs_int_pcre_matches (value rev, value strv) m->r = pcre_exec (re, NULL, m->subject, len, 0, 0, m->vec, veclen); if (m->r < 0 && m->r != PCRE_ERROR_NOMATCH) { + int ret = m->r; free_last_match (m); - raise_pcre_error ("pcre_exec", m->r); + raise_pcre_error ("pcre_exec", ret); } /* This error would indicate that pcre_exec ran out of space in the -- 2.14.3
2019 Sep 05
2
[PATCH 0/1] Build fix for future OCaml 4.09
This is a simple fix for building also with the upcoming OCaml 4.09, which has a slight API change in the C library. This does not cover embedded copies such as ocaml-augeas, and ocaml-libvirt, which are being fixed separately, and will then be synchronized. Pino Toscano (1): ocaml: make const the return value of caml_named_value() common/mlpcre/pcre-c.c | 2 +- common/mltools/uri-c.c |
2019 Sep 05
1
[PATCH] ocaml: Change calls to caml_named_value() to cope with const value* return.
...it-c.c | 4 +--- generator/daemon.ml | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c index be054a004..d23f17e05 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...
2017 Sep 22
0
[PATCH v3 01/22] common/mlpcre: Raise Invalid_argument if PCRE.sub n parameter is negative.
...mon/mlpcre/pcre-c.c +++ b/common/mlpcre/pcre-c.c @@ -201,6 +201,7 @@ value guestfs_int_pcre_sub (value nv) { CAMLparam1 (nv); + int n = Int_val (nv); CAMLlocal1 (strv); int len; CLEANUP_FREE char *str = NULL; @@ -209,8 +210,10 @@ guestfs_int_pcre_sub (value nv) if (m == NULL) raise_pcre_error ("PCRE.sub called without calling PCRE.matches", 0); - len = pcre_get_substring (m->subject, m->vec, m->r, Int_val (nv), - (const char **) &str); + if (n < 0) + caml_invalid_argument ("PCRE.sub: n must be >= 0"); + + len = pc...
2019 Sep 05
0
[PATCH 1/1] ocaml: make const the return value of caml_named_value()
...t/visit-c.c | 2 +- generator/daemon.ml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c index be054a004..62a6dd5da 100644 --- a/common/mlpcre/pcre-c.c +++ b/common/mlpcre/pcre-c.c @@ -73,7 +73,7 @@ init (void) static void raise_pcre_error (const char *msg, int errcode) { - value *exn = caml_named_value ("PCRE.Error"); + const value *exn = caml_named_value ("PCRE.Error"); value args[2]; args[0] = caml_copy_string (msg); diff --git a/common/mltools/uri-c.c b/common/mltools/uri-c.c index 2a8837cd9..db6fe2...
2017 Sep 20
4
[PATCH 0/4] Replace some uses of the Str module with PCRE.
Str is a pretty ugly regexp module. Let's try to replace it with PCRE. This series of commits goes some small way towards that eventual goal. - - - I wonder if there was a deep reason why we had this? let unix2dos s = String.concat "\r\n" (Str.split_delim (Str.regexp_string "\n") s) I replaced it with what I think should be (nearly) equivalent: let unix2dos s =
2017 Sep 22
0
[PATCH v3 02/22] common/mlpcre: Add PCRE.subi to return indexes instead of the substring.
...5,3 +225,30 @@ guestfs_int_pcre_sub (value nv) memcpy (String_val (strv), str, len); CAMLreturn (strv); } + +value +guestfs_int_pcre_subi (value nv) +{ + CAMLparam1 (nv); + int n = Int_val (nv); + CAMLlocal1 (rv); + struct last_match *m = gl_tls_get (last_match); + + if (m == NULL) + raise_pcre_error ("PCRE.subi called without calling PCRE.matches", 0); + + if (n < 0) + caml_invalid_argument ("PCRE.subi: n must be >= 0"); + + /* eg if there are 2 captures, m->r == 3, and valid values of n are + * 0, 1 or 2. + */ + if (n >= m->r) + caml_raise_not_f...
2017 Sep 21
18
[PATCH v2 00/18] Replace many more uses of the Str module with PCRE.
v1 was here: https://www.redhat.com/archives/libguestfs/2017-September/msg00135.html This is a more complete evolution of the earlier patch. It replaces most important uses of Str with PCRE throughout the code. It also extends the bindings with some useful features like case-insensitive regexps. The main places I *didn't* touch are the generator (GObject uses Str extensively); and
2017 Sep 22
27
[PATCH v3 00/22] Replace almost all uses of the Str module with PCRE.
v1: https://www.redhat.com/archives/libguestfs/2017-September/msg00135.html v2: https://www.redhat.com/archives/libguestfs/2017-September/msg00158.html v3 is almost identical to v2, but I have added 4 extra commits to almost finish the job of replacing Str everywhere possible (note it's not possible to replace Str in common/mlstdutils or the generator because those are pure OCaml). As