MantisBT - CMake
View Issue Details
0012350CMakeCMakepublic2011-07-19 06:472016-06-10 14:31
Flávio J. Saraiva 
Kitware Robot 
normalfeatureN/A
closedmoved 
CMake-2-8 
 
0012350: add STRING(ESCAPE) to produce the original string in a CONFIGURE_FILE substitution
string(ESCAPE <string to escape> <output variable>)

It would escape the string, adding surrounding quotes if necessary so that using the escaped string in a CONFIGURE_FILE substitution would produce the original string.
see attached file TestEscapeHell.cmake for a test showcasing the problem and a test with the proposed solution
I'm doing CONFIGURE_FILE on the script file CopyIfNotExists.cmake.in to run at install time.
I have a regex SVN_FOLDER_PATTERN=[\\.]svn that contains a backslash and is passed on to a variable in the file.

Configuring the file turns: set( SVN_FOLDER_PATTERN @SVN_FOLDER_PATTERN@ )
into: set( SVN_FOLDER_PATTERN [\.]svn )

This obviously generates a parse error: Invalid escape sequence \.
I'm forced to use string(REPLACE) to add escapes and avoid the issue.
No tags attached.
? TestEscapeHell.cmake (1,125) 2011-07-19 06:47
https://public.kitware.com/Bug/file/3976/TestEscapeHell.cmake
patch 0014-added-STRING-ESCAPE-command.patch (3,702) 2011-07-20 05:34
https://public.kitware.com/Bug/file/3978/0014-added-STRING-ESCAPE-command.patch
Issue History
2011-07-19 06:47Flávio J. SaraivaNew Issue
2011-07-19 06:47Flávio J. SaraivaFile Added: TestEscapeHell.cmake
2011-07-19 15:52Flávio J. SaraivaNote Added: 0027054
2011-07-20 05:34Flávio J. SaraivaFile Added: 0014-added-STRING-ESCAPE-command.patch
2011-07-20 05:42Flávio J. SaraivaNote Added: 0027056
2012-08-11 11:38David ColeStatusnew => backlog
2012-08-11 11:38David ColeNote Added: 0030279
2016-06-10 14:28Kitware RobotNote Added: 0041865
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0027054)
Flávio J. Saraiva   
2011-07-19 15:52   
Adding surrounding quotes isn't necessary since this can be done: set( SVN_FOLDER_PATTERN "@SVN_FOLDER_PATTERN@" )

Sidenote:
CMakeCache.txt doesn't support storing multi-line values (truncated to 1st line on load, cache can get poisoned with the other lines) or strings that start and end with a single quote (quote pair removed on load).
Properly escaping the value would be a good idea and allow for any value to be stored.
(0027056)
Flávio J. Saraiva   
2011-07-20 05:42   
Added an implementation of the command. 0014-added-STRING-ESCAPE-command.patch

Only compiling was tested.
Escapes quotes, backslash, new line, carriage return, horizontal tab, vertical tab, $ and @.
Replaces new line, carriage return, horizontal tab, vertical tab in a 'quick-and-dirty' way.

Dunno what escapes it should handle, but these seem reasonable.
(0030279)
David Cole   
2012-08-11 11:38   
Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0041865)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.