2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Isolate lib_base library. Use crl::time in getms.

This commit is contained in:
John Preston
2018-08-08 23:11:28 +03:00
parent cb371f09ac
commit 64b8adb3d0
23 changed files with 267 additions and 157 deletions

View File

@@ -9,20 +9,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "auth_session.h"
#include "lang/lang_tag.h"
#include "base/qthelp_url.h"
namespace TextUtilities {
namespace {
QString ExpressionDomain() {
// Matches any domain name, containing at least one '.', including "file.txt".
return QString::fromUtf8("(?<![\\w\\$\\-\\_%=\\.])(?:([a-zA-Z]+)://)?((?:[A-Za-z" "\xD0\x90-\xD0\xAF\xD0\x81" "\xD0\xB0-\xD1\x8F\xD1\x91" "0-9\\-\\_]+\\.){1,10}([A-Za-z" "\xD1\x80\xD1\x84" "\\-\\d]{2,22})(\\:\\d+)?)");
}
QString ExpressionDomainExplicit() {
// Matches any domain name, containing a protocol, including "test://localhost".
return QString::fromUtf8("(?<![\\w\\$\\-\\_%=\\.])(?:([a-zA-Z]+)://)((?:[A-Za-z" "\xD0\x90-\xD0\xAF\xD0\x81" "\xD0\xB0-\xD1\x8F\xD1\x91" "0-9\\-\\_]+\\.){0,10}([A-Za-z" "\xD1\x80\xD1\x84" "\\-\\d]{2,22})(\\:\\d+)?)");
}
QString ExpressionMailNameAtEnd() {
// Matches email first part (before '@') at the end of the string.
// First we find a domain without protocol (like "gmail.com"), then
@@ -1138,16 +1129,6 @@ const QRegularExpression &RegExpWordSplit() {
} // namespace
const QRegularExpression &RegExpDomain() {
static const auto result = CreateRegExp(ExpressionDomain());
return result;
}
const QRegularExpression &RegExpDomainExplicit() {
static const auto result = CreateRegExp(ExpressionDomainExplicit());
return result;
}
const QRegularExpression &RegExpMailNameAtEnd() {
static const auto result = CreateRegExp(ExpressionMailNameAtEnd());
return result;
@@ -1604,8 +1585,8 @@ void ParseEntities(TextWithEntities &result, int32 flags, bool rich) {
}
}
}
auto mDomain = RegExpDomain().match(result.text, matchOffset);
auto mExplicitDomain = RegExpDomainExplicit().match(result.text, matchOffset);
auto mDomain = qthelp::RegExpDomain().match(result.text, matchOffset);
auto mExplicitDomain = qthelp::RegExpDomainExplicit().match(result.text, matchOffset);
auto mHashtag = withHashtags ? RegExpHashtag().match(result.text, matchOffset) : QRegularExpressionMatch();
auto mMention = withMentions ? RegExpMention().match(result.text, qMax(mentionSkip, matchOffset)) : QRegularExpressionMatch();
auto mBotCommand = withBotCommands ? RegExpBotCommand().match(result.text, matchOffset) : QRegularExpressionMatch();

View File

@@ -157,8 +157,6 @@ namespace TextUtilities {
bool IsValidProtocol(const QString &protocol);
bool IsValidTopDomain(const QString &domain);
const QRegularExpression &RegExpDomain();
const QRegularExpression &RegExpDomainExplicit();
const QRegularExpression &RegExpMailNameAtEnd();
const QRegularExpression &RegExpHashtag();
const QRegularExpression &RegExpHashtagExclude();