diff options
author | Brad King <brad.king@kitware.com> | 2009-02-24 20:43:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-02-24 20:43:06 (GMT) |
commit | 3f4064f7ac672a511937b0a8aba04f87eb831294 (patch) | |
tree | 5d2530d5a0c4033dd45a11f1a59ce3a8c449df28 /Source/cmCTest.cxx | |
parent | 39f8b91125ee3cb426968f089049f393dee1f699 (diff) | |
download | CMake-3f4064f7ac672a511937b0a8aba04f87eb831294.zip CMake-3f4064f7ac672a511937b0a8aba04f87eb831294.tar.gz CMake-3f4064f7ac672a511937b0a8aba04f87eb831294.tar.bz2 |
ENH: Add cmCTest::DecodeURL method
This new method decodes the "percent-encoding" used in URL syntax.
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r-- | Source/cmCTest.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index df7c110..c1f2752 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -47,6 +47,7 @@ #include <stdlib.h> #include <math.h> #include <float.h> +#include <ctype.h> #include <memory> // auto_ptr @@ -180,6 +181,26 @@ std::string cmCTest::MakeURLSafe(const std::string& str) return ost.str(); } +//---------------------------------------------------------------------------- +std::string cmCTest::DecodeURL(const std::string& in) +{ + std::string out; + for(const char* c = in.c_str(); *c; ++c) + { + if(*c == '%' && isxdigit(*(c+1)) && isxdigit(*(c+2))) + { + char buf[3] = {*(c+1), *(c+2), 0}; + out.append(1, char(strtoul(buf, 0, 16))); + c += 2; + } + else + { + out.append(1, *c); + } + } + return out; +} + //---------------------------------------------------------------------- cmCTest::cmCTest() { |