[cmake-developers] New command 'file(LOCK_DIRECTORY ...)'
Rolf Eike Beer
eike at sf-mail.de
Mon Dec 1 11:05:57 EST 2014
Brad King wrote:
> On 11/25/2014 06:24 PM, Ruslan Baratov wrote:
> > updated
>
> Thanks. I squashed the commits since the addition of the files
> cannot be tested independently, made minor tweaks, and merged
> to 'next' for testing:
>
> cmSystemTools: Add StringToInt helper
> http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5121f118
Since I hate *scanf() with passion, how about this:
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 4c08e07..9852dd6 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2927,7 +2927,7 @@ std::vector<std::string> cmSystemTools::tokenize(const
std::string& str,
//----------------------------------------------------------------------------
bool cmSystemTools::StringToInt(const char* str, int* value)
{
- char unused;
- const int result = sscanf(str, "%d%c", value, &unused);
- return (result == 1);
+ char *endp;
+ *value = static_cast<int>(strtol(str, &endp, 10));
+ return (*endp == '\0') && (endp != str);
}
Eike
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20141201/674c4169/attachment.sig>
More information about the cmake-developers
mailing list