diff options
author | Carl Hetherington <carl@carlh.net> | 2012-04-01 14:30:06 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2012-04-01 14:30:06 +0000 |
commit | 7f417fb44fca536d3eb038bf01919e2557082d13 (patch) | |
tree | 1052fa3a8353a313889a882bd3642325bfbc2474 /libs/pbd/convert.cc | |
parent | 3240a93aad831eea5295fbca2387d2210e9e8638 (diff) |
Remove unused ustring version of url_decode(). Rework
the other version to be a bit simpler, avoiding #4800.
git-svn-id: svn://localhost/ardour2/branches/3.0@11771 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/convert.cc')
-rw-r--r-- | libs/pbd/convert.cc | 95 |
1 files changed, 12 insertions, 83 deletions
diff --git a/libs/pbd/convert.cc b/libs/pbd/convert.cc index 49650ab6e9..3d968d0627 100644 --- a/libs/pbd/convert.cc +++ b/libs/pbd/convert.cc @@ -178,94 +178,23 @@ int_from_hex (char hic, char loc) return lo + (16 * hi); } -void -url_decode (string& url) +string +url_decode (string const & url) { - string::iterator last; - string::iterator next; - - for (string::iterator i = url.begin(); i != url.end(); ++i) { - if ((*i) == '+') { - *i = ' '; - } - } - - if (url.length() <= 3) { - return; - } - - last = url.end(); - - --last; /* points at last char */ - --last; /* points at last char - 1 */ - - for (string::iterator i = url.begin(); i != last; ) { - - if (*i == '%') { - - next = i; - - url.erase (i); - - i = next; - ++next; - - if (isxdigit (*i) && isxdigit (*next)) { - /* replace first digit with char */ - *i = int_from_hex (*i,*next); - ++i; /* points at 2nd of 2 digits */ - url.erase (i); - } + string decoded; + + for (string::size_type i = 0; i < url.length(); ++i) { + if (url[i] == '+') { + decoded += ' '; + } else if (url[i] == '%' && i <= url.length() - 3) { + decoded += char (int_from_hex (url[i + 1], url[i + 2])); + i += 2; } else { - ++i; + decoded += url[i]; } } -} -void -url_decode (ustring& url) -{ - ustring::iterator last; - ustring::iterator next; - - for (ustring::iterator i = url.begin(); i != url.end(); ++i) { - if ((*i) == '+') { - next = i; - ++next; - url.replace (i, next, 1, ' '); - } - } - - if (url.length() <= 3) { - return; - } - - last = url.end(); - - --last; /* points at last char */ - --last; /* points at last char - 1 */ - - for (ustring::iterator i = url.begin(); i != last; ) { - - if (*i == '%') { - - next = i; - - url.erase (i); - - i = next; - ++next; - - if (isxdigit (*i) && isxdigit (*next)) { - /* replace first digit with char */ - url.replace (i, next, 1, (gunichar) int_from_hex (*i,*next)); - ++i; /* points at 2nd of 2 digits */ - url.erase (i); - } - } else { - ++i; - } - } + return decoded; } #if 0 |