Displaying 11 results from an estimated 11 matches for "match_or_empty".
2017 Aug 01
0
[PATCH 2/2] builder: Replace small usage of Str with new PCRE module.
...A-Za-z]+)(_([A-Za-z]+))?(\\.([A-Za-z0-9-]+))?(@([A-Za-z]+))?$"
+
let split_locale loc =
- let regex = Str.regexp "^\\([A-Za-z]+\\)\\(_\\([A-Za-z]+\\)\\)?\\(\\.\\([A-Za-z0-9-]+\\)\\)?\\(@\\([A-Za-z]+\\)\\)?$" in
let l = ref [] in
- if Str.string_match regex loc 0 then (
- let match_or_empty n =
- try Str.matched_group n loc with
- | Not_found -> ""
- in
- let lang = Str.matched_group 1 loc in
+ if PCRE.matches re_locale loc then (
+ let match_or_empty n = try PCRE.sub n with Not_found -> "" in
+ let lang = PCRE.sub 1 in
let territo...
2014 Jan 30
2
[PATCH] builder: output translated notes
...list_entries.ml
@@ -21,6 +21,23 @@ open Common_utils
open Printf
+let split_locale loc =
+ let regex = Str.regexp "^\\([A-Za-z]+\\)\\(_\\([A-Za-z]+\\)\\)?\\(\\.\\([A-Za-z0-9-]+\\)\\)?\\(@\\([A-Za-z]+\\)\\)?$" in
+ let l = ref [] in
+ if Str.string_match regex loc 0 then (
+ let match_or_empty n =
+ try Str.matched_group n loc with
+ | Not_found -> "" in
+ let lang = Str.matched_group 1 loc in
+ let territory = match_or_empty 3 in
+ (match territory with
+ | "" -> ()
+ | territory -> l := (lang ^ "_" ^ territory) :: !l);
+...
2014 Mar 11
3
[PATCH 1/2] builder: move some language-related code into a Languages module
..., Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Common_utils
+
+let split_locale loc =
+ let regex = Str.regexp "^\\([A-Za-z]+\\)\\(_\\([A-Za-z]+\\)\\)?\\(\\.\\([A-Za-z0-9-]+\\)\\)?\\(@\\([A-Za-z]+\\)\\)?$" in
+ let l = ref [] in
+ if Str.string_match regex loc 0 then (
+ let match_or_empty n =
+ try Str.matched_group n loc with
+ | Not_found -> ""
+ in
+ let lang = Str.matched_group 1 loc in
+ let territory = match_or_empty 3 in
+ (match territory with
+ | "" -> ()
+ | territory -> l := (lang ^ "_" ^ territory) :: !l)...
2014 Jan 30
0
Re: [PATCH] builder: output translated notes
On Thu, Jan 30, 2014 at 02:44:12PM +0100, Pino Toscano wrote:
> + let l = ref [] in
'xs' is a bit more natural for lists of things than 'l'.
> + if Str.string_match regex loc 0 then (
> + let match_or_empty n =
> + try Str.matched_group n loc with
> + | Not_found -> "" in
My preference is to put 'in' on a separate line if you're defining a
function (as here), and 'in' at the end of the line if you're defining
a value.
So I would have written this:...
2017 Aug 01
7
[PATCH 0/2] Add lightweight bindings for PCRE.
We'd like to use PCRE instead of the awful Str module. However I
don't necessarily want to pull in the extra dependency of ocaml-pcre,
and in any case ocaml-pcre is rather difficult to use.
This introduces very simplified and lightweight bindings for PCRE.
They work rather like Str in that there is some global state (actually
thread-local in this implementation) between the matching and
2017 Aug 01
6
[PATCH v2 0/3] common: Add a lightweight OCaml binding for PCRE.
v2:
- Change the OCaml code in the daemon to use PCRE instead of Str.
- Call pcre_compile2 so we can capture the error code on failure.
- Extend the test suite.
- Some other cleanups, but very minor.
Rich.
2016 Jul 07
12
[PATCH v3 0/8] v2v: Move Curl wrapper to mllib and more.
v2 -> v3:
- Changes to the Curl API suggested by Pino.
2016 Jul 07
9
[PATCH v2 0/8] v2v: Move Curl wrapper to mllib and use it for virt-builder (and more).
v1 -> v2:
- Fixed the bug with precedence of if / @.
- Add some imperative list operators inspired by Perl, and use those
for constructing the Curl arguments, and more.
Rich.
2017 Nov 21
2
[PATCH v3 0/2] common/mlstdutils: Extend the List module.
v2 -> v3:
- Renamed List.assoc_ -> List.assoc_lbl.
- Rebased on top of current master branch.
Rich.
2017 Oct 08
4
[PATCH 0/3] common/mlstdutils: Add Std_utils List and Option modules.
In Std_utils we already extend Char and String. These commits take it
a little further by extending List and adding a new Option submodule.
All basically simple refactoring.
Rich.
2017 Oct 08
7
[[PATCH v2 0/4] common/mlstdutils: Add Std_utils List and Option modules.
This time including the first commit ...