summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-12-26 15:04:58 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-01-06 16:25:09 (GMT)
commit2d6638008c2aeba6015d45160e52d78d92daf57d (patch)
tree324cfe8366dec59e9d0629200f264c7997a89f95 /Source/cmTarget.cxx
parentb225dbbd0235b545383105e0571f84a1bf6b1be0 (diff)
downloadCMake-2d6638008c2aeba6015d45160e52d78d92daf57d.zip
CMake-2d6638008c2aeba6015d45160e52d78d92daf57d.tar.gz
CMake-2d6638008c2aeba6015d45160e52d78d92daf57d.tar.bz2
cmTarget: Use strtol for numeric parsing.
On Windows apparently sscanf can not handle hex numbers. Test that numeric comparison works with hex numbers.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ead48b9..472f87d 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -24,6 +24,7 @@
#include <set>
#include <stdlib.h> // required for atof
#include <assert.h>
+#include <errno.h>
const char* cmTarget::GetTargetTypeName(TargetType targetType)
{
@@ -4274,6 +4275,7 @@ std::pair<bool, const char*> consistentNumberProperty(const char *lhs,
const char *rhs,
CompatibleType t)
{
+ char *pEnd;
#if defined(_MSC_VER)
static const char* const null_ptr = 0;
@@ -4281,10 +4283,14 @@ std::pair<bool, const char*> consistentNumberProperty(const char *lhs,
# define null_ptr 0
#endif
- double lnum;
- double rnum;
- if(sscanf(lhs, "%lg", &lnum) != 1 ||
- sscanf(rhs, "%lg", &rnum) != 1)
+ long lnum = strtol(lhs, &pEnd, 0);
+ if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE)
+ {
+ return std::pair<bool, const char*>(false, null_ptr);
+ }
+
+ long rnum = strtol(rhs, &pEnd, 0);
+ if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE)
{
return std::pair<bool, const char*>(false, null_ptr);
}