fixup Fix some warnings
This commit is contained in:
parent
d5d305193c
commit
bd7fde99af
|
@ -259,8 +259,7 @@ public class Database : Qlite.Database {
|
|||
message.type=conversation.type+1 and
|
||||
(message.counterpart_resource=conversation.resource or message.type != 3)""");
|
||||
} catch (Error e) {
|
||||
stderr.printf("Failed to upgrade to database version 8: %s\n", e.message);
|
||||
Process.exit(-1);
|
||||
error("Failed to upgrade to database version 8: %s", e.message);
|
||||
}
|
||||
}
|
||||
if (oldVersion < 9) {
|
||||
|
@ -277,8 +276,7 @@ public class Database : Qlite.Database {
|
|||
message.body in (select info from file_transfer where info not null) or
|
||||
message.id in (select info from file_transfer where info not null)""");
|
||||
} catch (Error e) {
|
||||
stderr.printf("Failed to upgrade to database version 8: %s\n", e.message);
|
||||
Process.exit(-1);
|
||||
error("Failed to upgrade to database version 9: %s", e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,11 +136,7 @@ public class ConversationSelectorRow : ListBoxRow {
|
|||
nick_label.label = last_message.direction == Message.DIRECTION_SENT ? _("Me") + ": " : "";
|
||||
}
|
||||
|
||||
try {
|
||||
message_label.label = Markup.escape_text((/\s+/).replace_literal(last_message.body, -1, 0, " "));
|
||||
} catch (RegexError e) {
|
||||
assert_not_reached();
|
||||
}
|
||||
message_label.label = Util.summarize_whitespaces_to_space(last_message.body);
|
||||
break;
|
||||
case FileItem.TYPE:
|
||||
FileItem file_item = last_content_item as FileItem;
|
||||
|
|
|
@ -205,8 +205,8 @@ public class GlobalSearch : Overlay {
|
|||
regex_str += ")";
|
||||
|
||||
// Color the keywords
|
||||
int elongated_by = 0;
|
||||
try {
|
||||
int elongated_by = 0;
|
||||
Regex highlight_regex = new Regex(regex_str);
|
||||
MatchInfo match_info;
|
||||
string markup_text_bak = markup_text.down();
|
||||
|
@ -218,6 +218,9 @@ public class GlobalSearch : Overlay {
|
|||
elongated_by += "<span bgcolor=\"yellow\">".length + "</span>".length;
|
||||
}
|
||||
markup_text_bak += ""; // We need markup_text_bak to live until here because url_regex.match does not copy the string
|
||||
} catch (RegexError e) {
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
label.label = markup_text;
|
||||
grid.attach(label, 1, 1, 1, 1);
|
||||
|
@ -228,9 +231,6 @@ public class GlobalSearch : Overlay {
|
|||
});
|
||||
button.add(grid);
|
||||
return button;
|
||||
} catch (RegexError e) {
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
private Grid get_context_message_widget(MessageItem item) {
|
||||
|
|
|
@ -153,19 +153,11 @@ public class UnifiedWindowController : Object {
|
|||
|
||||
private void update_conversation_topic(string? subtitle = null) {
|
||||
if (subtitle != null) {
|
||||
try {
|
||||
conversation_topic = (/\s+/).replace_literal(subtitle, -1, 0, " ");
|
||||
} catch (RegexError e) {
|
||||
assert_not_reached();
|
||||
}
|
||||
conversation_topic = Util.summarize_whitespaces_to_space(subtitle);
|
||||
} else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
||||
string? subject = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account);
|
||||
if (subject != null) {
|
||||
try {
|
||||
conversation_topic = (/\s+/).replace_literal(subject, -1, 0, " ");
|
||||
} catch (RegexError e) {
|
||||
assert_not_reached();
|
||||
}
|
||||
conversation_topic = Util.summarize_whitespaces_to_space(subject);
|
||||
} else {
|
||||
conversation_topic = null;
|
||||
}
|
||||
|
|
|
@ -272,6 +272,14 @@ public int get_only_emoji_count(string markup_text) {
|
|||
return emoji_no;
|
||||
}
|
||||
|
||||
public string summarize_whitespaces_to_space(string s) {
|
||||
try {
|
||||
return (/\s+/).replace_literal(s, -1, 0, " ");
|
||||
} catch (RegexError e) {
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
public bool use_csd() {
|
||||
return (GLib.Application.get_default() as Application).use_csd();
|
||||
}
|
||||
|
|
|
@ -220,9 +220,8 @@ namespace Signal {
|
|||
[CCode (cname = "ec_public_key_serialize_")]
|
||||
public uint8[] serialize() {
|
||||
Buffer buffer;
|
||||
try {
|
||||
throw_by_code(serialize_(out buffer));
|
||||
} catch (GLib.Error e) {
|
||||
int code = serialize_(out buffer);
|
||||
if (code < 0 && code > MIN_ERROR_CODE) {
|
||||
// Can only throw for invalid arguments or out of memory.
|
||||
GLib.assert_not_reached();
|
||||
}
|
||||
|
@ -240,9 +239,8 @@ namespace Signal {
|
|||
[CCode (cname = "ec_private_key_serialize_")]
|
||||
public uint8[] serialize() throws GLib.Error {
|
||||
Buffer buffer;
|
||||
try {
|
||||
throw_by_code(serialize_(out buffer));
|
||||
} catch (GLib.Error e) {
|
||||
int code = serialize_(out buffer);
|
||||
if (code < 0 && code > MIN_ERROR_CODE) {
|
||||
// Can only throw for invalid arguments or out of memory.
|
||||
GLib.assert_not_reached();
|
||||
}
|
||||
|
|
|
@ -1,27 +1,17 @@
|
|||
namespace Xmpp.Util {
|
||||
|
||||
// Parse a number from a hexadecimal representation.
|
||||
//
|
||||
// Skips any whitespace at the start of the string, parses as many valid
|
||||
// characters as hexadecimal digits as possible (possibly zero) and returns
|
||||
// them as an integer value.
|
||||
//
|
||||
// ```
|
||||
// // 0x0
|
||||
// print("0x%lx\n", from_hex(""));
|
||||
//
|
||||
// // 0x123abc
|
||||
// print("0x%lx\n", from_hex("123abc"));
|
||||
//
|
||||
// // 0x0
|
||||
// print("0x%lx\n", from_hex("0x123abc"));
|
||||
//
|
||||
// // 0xa
|
||||
// print("0x%lx\n", from_hex("A quick brown fox jumps over the lazy dog."));
|
||||
//
|
||||
// // 0xfeed
|
||||
// print("0x%lx\n", from_hex(" FEED ME "));
|
||||
// ```
|
||||
/**
|
||||
* Parse a number from a hexadecimal representation.
|
||||
*
|
||||
* Skips any whitespace at the start of the string, parses as many valid
|
||||
* characters as hexadecimal digits as possible (possibly zero) and returns
|
||||
* them as an integer value.
|
||||
*
|
||||
* ```
|
||||
* // 0xa
|
||||
* print("0x%lx\n", from_hex("A quick brown fox jumps over the lazy dog."));
|
||||
* ```
|
||||
*/
|
||||
|
||||
public long from_hex(string numeral) {
|
||||
long result = 0;
|
||||
|
|
Loading…
Reference in a new issue