View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0010740 | CMake | CMake | public | 2010-05-21 03:26 | 2011-11-11 10:45 | ||||
Reporter | Rolf Eike Beer | ||||||||
Assigned To | David Cole | ||||||||
Priority | high | Severity | feature | Reproducibility | N/A | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake-2-8 | ||||||||
Target Version | CMake 2.8.5 | Fixed in Version | CMake 2.8.5 | ||||||
Summary | 0010740: STRING(SUBSTRING) should work with length -1 | ||||||||
Description | I would like to cut the first character from a string. This means I have to query the string length, substract one and then call: STRING(SUBSTRING "foo" 1 ${LENGTH} FOO_OUT) It would be very useful to have a simple way to delete the first N and last N characters. The first could happen by allowing -1 as length: STRING(SUBSTRING "foo" 1 -1 FOO_OUT) -> "oo" The other operation could be something like STRING(CHOP "foo" 1 FOO_OUT) -> "fo" | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | ![]() ![]() ![]() | ||||||||
Relationships | |
Relationships |
Notes | |
(0021234) Rolf Eike Beer (developer) 2010-07-04 13:47 |
These patches (based on efee95cd710808ca7ac261359b9b8e6dacb09211) implement both things and add testcases to make sure that works as expected. |
(0021235) Rolf Eike Beer (developer) 2010-07-04 13:48 |
Please replace the From line with From: Rolf Eike Beer <eike@sf-mail.de> before applying. |
(0022116) David Cole (manager) 2010-09-07 17:24 |
Changing target version... Since there is a way to accomplish this with existing CMake and this is merely a "convenience" feature request, and it is a new feature.... I'm delaying the implementation for this issue to a future release (not for 2.8.3). CMake devs do not have enough time left before 2.8.3 to work on this issue. I don't like the word "CHOP" and I'm not sure that we should extend SUBSTRING to use "-1" as meaning "the rest of the string". Or at least use the word "truncate" rather than chop. Truncate has a specific meaning of chopping off the end, whereas chop could mean chop off either end. Even better, though, I think it would be more clear to introduce new methods in the string command for string(LEFT and string(RIGHT. |
(0022117) Rolf Eike Beer (developer) 2010-09-07 17:31 |
I just took the "chop" from Qt's QString, I don't have any objections against truncate. RIGHT and LEFT would still not solve the "issue" to just remove the first n characters without checking the length first. |
(0022118) David Cole (manager) 2010-09-07 17:36 |
Certainly for now, you could write a function or macro in the CMake language that performs these operations in a more elegant manner... but uses MATH and SUBSTRING under the hood. |
(0023825) Ben Boeckel (developer) 2010-12-08 16:52 |
I applied the substring patch. Is there some reason to apply the CHOP (or an equivalent) without a mirror version to take from the beginning of the string? A RIGHT and LEFT would suffice for that I'd think. |
(0023858) Rolf Eike Beer (developer) 2010-12-09 16:10 |
Well, that substring one is basically the opposite of the CHOP. We could make CHOP_RIGHT and CHOP_LEFT (or whatever) from them. Or any better name one could imagine. I can't ;) |
(0023859) Ben Boeckel (developer) 2010-12-09 16:17 |
The patch that was attached added -1 as "rest of string" so that would conflict with a meaning of going backwards in the string. Alternatively, a value of 0 could mean "rest of string" as a length of 0 is no different then setting a variable to the empty string, but this breaks backwards compatibility and is probably not a valid solution for CMake. I'll look at implementing RIGHT and LEFT. Maybe FIRST and LAST as names? |
(0023860) David Cole (manager) 2010-12-09 16:26 |
There's no need for LEFT or FIRST: string(LEFT 5 ...) because it's equivalent to: string(SUBSTRING 0 5 ...) But it probably doesn't make sense to provide a RIGHT if there is no LEFT... Coming up with the proper names here is critical for this issue. It should "do what it's named" so that 99.9% of people who encounter just know what it does without looking up the documentation. |
(0024473) Ben Boeckel (developer) 2011-01-06 14:39 |
Merged into master. http://cmake.org/gitweb?p=cmake.git;a=commit;h=2d1aa4ad06eedf6bc677c8ebf757f4978a839e02 [^] |
(0025229) Rolf Eike Beer (developer) 2011-02-03 05:40 |
There are some error messages in the C++ file and the documentation that need to reflect the change. I'll cook up a patch tonight. |
(0026599) David Cole (manager) 2011-05-25 17:19 |
Hi Rolf, Have any patches been cooked up? What error messages need to change? |
(0026615) Rolf Eike Beer (developer) 2011-05-26 07:06 |
https://public.kitware.com/Bug/file/3675/0001-update-documentation-of-STRING-SUBSTRING-for-length-.patch [^] |
(0026616) David Cole (manager) 2011-05-26 07:29 |
Ah, thanks. I didn't notice that a patch had been attached after your previous note... |
(0026671) David Cole (manager) 2011-06-05 14:30 |
Documentation updated in this commit: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ecdad65a4541db353bd498be7d7090b5ed059ebc [^] |
(0027759) David Cole (manager) 2011-11-11 10:45 |
Closing resolved issues that have not been updated in more than 4 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2010-05-21 03:26 | Rolf Eike Beer | New Issue | |
2010-07-04 13:46 | Rolf Eike Beer | File Added: 0001-allow-STRING-SUBSTRING-work-with-length-1-as-rest-of.patch | |
2010-07-04 13:46 | Rolf Eike Beer | File Added: 0002-add-STRING-CHOP-command.patch | |
2010-07-04 13:47 | Rolf Eike Beer | Note Added: 0021234 | |
2010-07-04 13:48 | Rolf Eike Beer | Note Added: 0021235 | |
2010-08-31 17:12 | David Cole | Status | new => assigned |
2010-08-31 17:12 | David Cole | Assigned To | => David Cole |
2010-08-31 17:50 | David Cole | Target Version | => CMake 2.8.3 |
2010-09-07 17:24 | David Cole | Note Added: 0022116 | |
2010-09-07 17:24 | David Cole | Target Version | CMake 2.8.3 => |
2010-09-07 17:31 | Rolf Eike Beer | Note Added: 0022117 | |
2010-09-07 17:36 | David Cole | Note Added: 0022118 | |
2010-09-09 17:59 | David Cole | Priority | normal => high |
2010-11-10 21:09 | David Cole | Target Version | => CMake 2.8.4 |
2010-12-08 14:50 | Ben Boeckel | Assigned To | David Cole => Ben Boeckel |
2010-12-08 16:52 | Ben Boeckel | Note Added: 0023825 | |
2010-12-09 16:10 | Rolf Eike Beer | Note Added: 0023858 | |
2010-12-09 16:17 | Ben Boeckel | Note Added: 0023859 | |
2010-12-09 16:26 | David Cole | Note Added: 0023860 | |
2011-01-06 14:39 | Ben Boeckel | Note Added: 0024473 | |
2011-01-06 14:39 | Ben Boeckel | Status | assigned => resolved |
2011-01-06 14:39 | Ben Boeckel | Resolution | open => fixed |
2011-01-06 14:39 | Ben Boeckel | Fixed in Version | => CMake 2.8.4 |
2011-02-03 05:40 | Rolf Eike Beer | Note Added: 0025229 | |
2011-02-03 05:40 | Rolf Eike Beer | Status | resolved => feedback |
2011-02-03 05:40 | Rolf Eike Beer | Resolution | fixed => reopened |
2011-02-03 15:11 | Rolf Eike Beer | File Added: 0001-update-documentation-of-STRING-SUBSTRING-for-length-.patch | |
2011-02-16 11:33 | David Cole | Target Version | CMake 2.8.4 => CMake 2.8.5 |
2011-05-25 17:18 | David Cole | Assigned To | Ben Boeckel => David Cole |
2011-05-25 17:18 | David Cole | Status | feedback => assigned |
2011-05-25 17:19 | David Cole | Note Added: 0026599 | |
2011-05-26 07:06 | Rolf Eike Beer | Note Added: 0026615 | |
2011-05-26 07:29 | David Cole | Note Added: 0026616 | |
2011-06-05 14:30 | David Cole | Note Added: 0026671 | |
2011-06-05 14:30 | David Cole | Status | assigned => resolved |
2011-06-05 14:30 | David Cole | Fixed in Version | CMake 2.8.4 => CMake 2.8.5 |
2011-06-05 14:30 | David Cole | Resolution | reopened => fixed |
2011-11-11 10:45 | David Cole | Note Added: 0027759 | |
2011-11-11 10:45 | David Cole | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |