From: jurko.gospodnetic_at_[hidden]
Date: 2008-08-31 17:25:03


Author: jurko
Date: 2008-08-31 17:25:03 EDT (Sun, 31 Aug 2008)
New Revision: 48500
URL: http://svn.boost.org/trac/boost/changeset/48500

Log:
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.
Text files modified:
   trunk/tools/build/v2/util/utility.jam | 25 +++++++++++++++++++++++++
   1 files changed, 25 insertions(+), 0 deletions(-)

Modified: trunk/tools/build/v2/util/utility.jam
==============================================================================
--- trunk/tools/build/v2/util/utility.jam (original)
+++ trunk/tools/build/v2/util/utility.jam 2008-08-31 17:25:03 EDT (Sun, 31 Aug 2008)
@@ -124,6 +124,23 @@
 }
 
 
+# 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 @@
     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 <foo> ;
     assert.result <foo> : ungrist <<foo>> ;