From 78483280a0f21838faf136d5dfb2e62cf8ead835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Sun, 31 Aug 2008 21:25:03 +0000 Subject: [PATCH] Added a new utility.unquote() rule to the Boost Build util/utility.jam module. Tests included. This is part of cleaning up some command line parsing where on some OS's quotes are stripped by the OS and on some they are not. [SVN r48500] --- v2/util/utility.jam | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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 <> ;