Skip to content

Commit 94b2d0f

Browse files
authored
Merge pull request #76 from liyishuai/patch
Allow empty patch version
2 parents 7d21786 + 6ec744e commit 94b2d0f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/cppo_main.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let add_extension tbl s =
1717
let semver_re = Str.regexp "\
1818
\\([0-9]+\\)\
1919
\\.\\([0-9]+\\)\
20-
\\.\\([0-9]+\\)\
20+
\\(\\.\\([0-9]+\\)\\)?\
2121
\\([~-]\\([^+]*\\)\\)?\
2222
\\(\\+\\(.*\\)\\)?\
2323
\r?$"
@@ -28,9 +28,9 @@ let parse_semver s =
2828
else
2929
let major = Str.matched_group 1 s in
3030
let minor = Str.matched_group 2 s in
31-
let patch = Str.matched_group 3 s in
32-
let prerelease = try Some (Str.matched_group 5 s) with Not_found -> None in
33-
let build = try Some (Str.matched_group 7 s) with Not_found -> None in
31+
let patch = try (Str.matched_group 4 s) with Not_found -> "0" in
32+
let prerelease = try Some (Str.matched_group 6 s) with Not_found -> None in
33+
let build = try Some (Str.matched_group 8 s) with Not_found -> None in
3434
Some (major, minor, patch, prerelease, build)
3535

3636
let define var s =

test/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
(action
7171
(with-stdout-to
7272
%{targets}
73-
(run %{bin:cppo} -V X:123.05.2-alpha.1+foo-2.1 %{<}))))
73+
(run %{bin:cppo} -V X:123.05.2-alpha.1+foo-2.1 -V COQ:8.13+beta1 %{<}))))
7474

7575
(alias
7676
(name runtest)

test/version.cppo

+2
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ patch: X_PATCH
2828
#else
2929
#error ""
3030
#endif
31+
32+
Coq: COQ_VERSION

0 commit comments

Comments
 (0)