diff --git a/v2/util/utility.jam b/v2/util/utility.jam index 66444aef9..c46747f58 100644 --- a/v2/util/utility.jam +++ b/v2/util/utility.jam @@ -124,6 +124,23 @@ rule ungrist ( names * ) } +# If the passed value is quoted, unquotes it. Otherwise returns the value +# unchanged. +# +rule unquote ( value ? ) +{ + local match-result = [ MATCH ^(\")(.*)(\")$ : $(value) ] ; + if $(match-result) + { + return $(match-result[2]) ; + } + else + { + return $(value) ; + } +} + + rule __test__ ( ) { import assert ; @@ -155,6 +172,14 @@ rule __test__ ( ) assert.result foo : basename foo.so ; assert.result foo.so : basename foo.so.1 ; + assert.result : unquote ; + assert.result "" : unquote "" ; + assert.result foo : unquote foo ; + assert.result \"foo : unquote \"foo ; + assert.result foo\" : unquote foo\" ; + assert.result foo : unquote \"foo\" ; + assert.result \"foo\" : unquote \"\"foo\"\" ; + assert.result : ungrist ; assert.result foo : ungrist ; assert.result : ungrist <> ;