View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0005999 | CMake | CMake | public | 2007-11-02 17:55 | 2016-06-10 14:30 | ||||
Reporter | Brandon Van Every | ||||||||
Assigned To | Bill Hoffman | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | closed | Resolution | moved | ||||||
Platform | OS | OS Version | |||||||
Product Version | |||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0005999: REGEX ^ does not anchor against the original string | ||||||||
Description | ^ doesn't anchor against the original input string. It anchors against the string as it is processed! If replacements cause the string to have a new beginning, it anchors against the new beginning. Perl does not exhibit this behavior. I know CMake is not Perl, but Perl is a good baseline for "sanity" in regex processing. If a ^ anchor isn't respected then it renders the use of such an anchor fairly pointless. Reproducer script anchor.cmake: SET(sillystring "I wanna rock!") MESSAGE("original string:") MESSAGE("${sillystring}") MESSAGE("expecting replacement to remove the leading 'I'. Instead we get:") STRING(REGEX REPLACE "^." "" out "${sillystring}") MESSAGE("${out}") C:\devel\src\cbugs\anchor>cmake -P anchor.cmake original string: I wanna rock! expecting replacement to remove the leading 'I'. Instead we get: C:\devel\src\cbugs\anchor> For comparison, a Perl script anchor.pl: my $sillystring; $sillystring = "I wanna rock!\n"; print "Original string:\n"; print $sillystring; print "Expecting replacement to remove the leading 'I'. In Perl we get:\n"; $sillystring =~ s/^.//; print $sillystring; bvanevery@OLDFAITHFUL /c/devel/moz $ perl anchor.pl Original string: I wanna rock! Expecting replacement to remove the leading 'I'. In Perl we get: wanna rock! bvanevery@OLDFAITHFUL /c/devel/moz $ | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0009626) Brandon Van Every (reporter) 2007-11-03 16:27 |
Additionally, a regex of ".$" only replaces 1 character at the end of the string. CMake's behavior is inconsistent with respect to leading and trailing anchors, proving that this is a bug and not something CMake does "on principle" out of greed. SET(sillystring "I wanna rock!") MESSAGE("original string:") MESSAGE("${sillystring}") MESSAGE("expecting replacement to remove the leading 'I'. Instead we get:") STRING(REGEX REPLACE "^." "" out "${sillystring}") MESSAGE("${out}") MESSAGE("$ doesn't have the problem, only ^") MESSAGE("Here we get rid of the trailing '!'") STRING(REGEX REPLACE ".$" "" out "${sillystring}") MESSAGE("${out}") C:\devel\src\cbugs\anchor>cmake -P anchor.cmake original string: I wanna rock! expecting replacement to remove the leading 'I'. Instead we get: $ doesn't have the problem, only ^ Here we get rid of the trailing '!' I wanna rock C:\devel\src\cbugs\anchor> |
(0041401) Kitware Robot (administrator) 2016-06-10 14:27 |
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. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2007-11-02 17:55 | Brandon Van Every | New Issue | |
2007-11-02 17:59 | Brandon Van Every | Description Updated | |
2007-11-03 16:27 | Brandon Van Every | Note Added: 0009626 | |
2007-12-14 20:49 | Bill Hoffman | Status | new => assigned |
2007-12-14 20:49 | Bill Hoffman | Assigned To | => Bill Hoffman |
2016-06-10 14:27 | Kitware Robot | Note Added: 0041401 | |
2016-06-10 14:27 | Kitware Robot | Status | assigned => resolved |
2016-06-10 14:27 | Kitware Robot | Resolution | open => moved |
2016-06-10 14:30 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |