summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /SwifTools/Linkify.cpp
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'SwifTools/Linkify.cpp')
-rw-r--r--SwifTools/Linkify.cpp160
1 files changed, 80 insertions, 80 deletions
diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp
index 324d145..b1557e5 100644
--- a/SwifTools/Linkify.cpp
+++ b/SwifTools/Linkify.cpp
@@ -16,89 +16,89 @@ namespace Swift {
static boost::regex linkifyRegexp("^(https?://|xmpp:).*");
std::string Linkify::linkify(const std::string& input) {
- std::ostringstream result;
- std::vector<char> currentURL;
- bool inURL = false;
- for (size_t i = 0; i < input.size(); ++i) {
- char c = input[i];
- if (inURL) {
- if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) {
- currentURL.push_back(c);
- }
- else {
- std::string url(&currentURL[0], currentURL.size());
- result << "<a href=\"" << url << "\">" << url << "</a>";
- currentURL.clear();
- inURL = false;
- result << c;
- }
- }
- else {
- if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
- currentURL.push_back(c);
- inURL = true;
- }
- else {
- result << c;
- }
- }
- }
- if (!currentURL.empty()) {
- std::string url(&currentURL[0], currentURL.size());
- result << "<a href=\"" << url << "\">" << url << "</a>";
- }
- return std::string(result.str());
+ std::ostringstream result;
+ std::vector<char> currentURL;
+ bool inURL = false;
+ for (size_t i = 0; i < input.size(); ++i) {
+ char c = input[i];
+ if (inURL) {
+ if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) {
+ currentURL.push_back(c);
+ }
+ else {
+ std::string url(&currentURL[0], currentURL.size());
+ result << "<a href=\"" << url << "\">" << url << "</a>";
+ currentURL.clear();
+ inURL = false;
+ result << c;
+ }
+ }
+ else {
+ if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
+ currentURL.push_back(c);
+ inURL = true;
+ }
+ else {
+ result << c;
+ }
+ }
+ }
+ if (!currentURL.empty()) {
+ std::string url(&currentURL[0], currentURL.size());
+ result << "<a href=\"" << url << "\">" << url << "</a>";
+ }
+ return std::string(result.str());
}
std::pair<std::vector<std::string>, size_t> Linkify::splitLink(const std::string& input) {
- std::vector<std::string> result;
- std::pair<std::vector<std::string>, size_t> pair;
- std::vector<char> currentURL;
- bool inURL = false;
- size_t urlStartsAt = 0;
- for (size_t i = 0; i < input.size(); ++i) {
- char c = input[i];
- if (inURL) {
- if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) {
- // Keep parsing
- }
- else {
- std::string url(input.substr(urlStartsAt, i - urlStartsAt));
- result.push_back(url);
- inURL = false;
- size_t remaining = input.size() - i;
- if (remaining > 0) {
- result.push_back(input.substr(i, remaining));
- }
- pair.first = result;
- pair.second = urlStartsAt == 0 ? 0 : 1;
- return pair;
- }
- }
- else {
- if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
- urlStartsAt = i;
- inURL = true;
- if (i > 0) {
- result.push_back(input.substr(0, i));
- }
- }
- else {
- // Just keep swimming
- }
- }
- }
- if (urlStartsAt > 0 || inURL) {
- std::string url(input.substr(urlStartsAt, input.size() - urlStartsAt));
- result.push_back(url);
- pair.first = result;
- pair.second = urlStartsAt == 0 ? 0 : 1;
- }
- else {
- pair.first.push_back(input);
- pair.second = 1;
- }
- return pair;
+ std::vector<std::string> result;
+ std::pair<std::vector<std::string>, size_t> pair;
+ std::vector<char> currentURL;
+ bool inURL = false;
+ size_t urlStartsAt = 0;
+ for (size_t i = 0; i < input.size(); ++i) {
+ char c = input[i];
+ if (inURL) {
+ if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) {
+ // Keep parsing
+ }
+ else {
+ std::string url(input.substr(urlStartsAt, i - urlStartsAt));
+ result.push_back(url);
+ inURL = false;
+ size_t remaining = input.size() - i;
+ if (remaining > 0) {
+ result.push_back(input.substr(i, remaining));
+ }
+ pair.first = result;
+ pair.second = urlStartsAt == 0 ? 0 : 1;
+ return pair;
+ }
+ }
+ else {
+ if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
+ urlStartsAt = i;
+ inURL = true;
+ if (i > 0) {
+ result.push_back(input.substr(0, i));
+ }
+ }
+ else {
+ // Just keep swimming
+ }
+ }
+ }
+ if (urlStartsAt > 0 || inURL) {
+ std::string url(input.substr(urlStartsAt, input.size() - urlStartsAt));
+ result.push_back(url);
+ pair.first = result;
+ pair.second = urlStartsAt == 0 ? 0 : 1;
+ }
+ else {
+ pair.first.push_back(input);
+ pair.second = 1;
+ }
+ return pair;
}
}