Use regex literals, fixes some compiler warnings

This commit is contained in:
fiaxh 2019-03-14 17:38:48 +01:00
parent fb504308d0
commit 952ac95484
7 changed files with 7 additions and 7 deletions

View file

@ -110,7 +110,7 @@ public class ConnectionManager : Object {
return connection_todo;
}
public XmppStream? connect(Account account) {
public XmppStream? connect_account(Account account) {
if (!connection_todo.contains(account)) connection_todo.add(account);
if (!connections.has_key(account)) {
return connect_(account);

View file

@ -26,7 +26,7 @@ public class StreamInteractor : Object {
public void connect_account(Account account) {
module_manager.initialize(account);
account_added(account);
connection_manager.connect(account);
connection_manager.connect_account(account);
}
public void disconnect_account(Account account) {

View file

@ -136,7 +136,7 @@ public class ConversationRow : ListBoxRow {
nick_label.label = last_message.direction == Message.DIRECTION_SENT ? _("Me") + ": " : "";
}
message_label.label = Markup.escape_text((new Regex("\\s+")).replace_literal(last_message.body, -1, 0, " "));
message_label.label = Markup.escape_text((/\s+/).replace_literal(last_message.body, -1, 0, " "));
break;
case FileItem.TYPE:
FileItem file_item = last_content_item as FileItem;

View file

@ -28,7 +28,7 @@ public class UnifiedWindow : Gtk.Window {
return Util.use_csd() ? conversation_titlebar_csd.subtitle : conversation_titlebar.subtitle;
}
set {
string? new_subtitle = value == null ? null : (new Regex("\\s+")).replace_literal(value, -1, 0, " ");
string? new_subtitle = value == null ? null : (/\s+/).replace_literal(value, -1, 0, " ");
if (Util.use_csd()) {
conversation_titlebar_csd.subtitle = new_subtitle;
} else {

View file

@ -169,7 +169,7 @@ public static string parse_add_markup(string s_, string? highlight_word, bool pa
bool already_escaped = already_escaped_;
if (parse_links) {
Regex url_regex = new Regex("""(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»]))""");
Regex url_regex = /(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/;
MatchInfo match_info;
url_regex.match(s.down(), 0, out match_info);
if (match_info.matches()) {

View file

@ -16,7 +16,7 @@ public class FileProvider : Dino.FileProvider, Object {
public FileProvider(StreamInteractor stream_interactor, Dino.Database dino_db) {
this.stream_interactor = stream_interactor;
this.dino_db = dino_db;
this.url_regex = new Regex("""^(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»]))$""");
this.url_regex = /^(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))$/;
stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(new ReceivedMessageListener(this));
}

View file

@ -17,7 +17,7 @@ public class FileProvider : Dino.FileProvider, Object {
public FileProvider(StreamInteractor stream_interactor, Dino.Database dino_db) {
this.stream_interactor = stream_interactor;
this.dino_db = dino_db;
this.url_regex = new Regex("""^aesgcm://(.*)#(([A-Fa-f0-9]{2}){48}|([A-Fa-f0-9]{2}){44})$""");
this.url_regex = /^aesgcm:\/\/(.*)#(([A-Fa-f0-9]{2}){48}|([A-Fa-f0-9]{2}){44})$/;
stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(new ReceivedMessageListener(this));
}