From 6b3e75edf034ebcbd048a24c283c7bcf7b1da019 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 25 May 2021 11:19:04 +0200 Subject: Add support for regex-based target type/pattern specific variables This is in addition to the already supported path-based target type/pattern specific variables. For example: hxx{*}: x = y # path-based hxx{~/.*/}: x = y # regex-based --- libbuild2/name.ixx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libbuild2/name.ixx') diff --git a/libbuild2/name.ixx b/libbuild2/name.ixx index 80a097e..a3ee94b 100644 --- a/libbuild2/name.ixx +++ b/libbuild2/name.ixx @@ -21,7 +21,20 @@ namespace build2 r = pair < x.pair ? -1 : (pair > x.pair ? 1 : 0); if (r == 0) - r = pattern == x.pattern ? 0 : (!pattern && x.pattern ? -1 : 1); + { + bool p (pattern); + bool xp (x.pattern); + + r = p == xp ? 0 : (p ? 1 : -1); + + if (r == 0 && p) + { + auto p (static_cast (*pattern)); + auto xp (static_cast (*x.pattern)); + + r = p < xp ? -1 : (p > xp ? 1 : 0); + } + } return r; } -- cgit v1.1