void
modest_text_utils_address_range_at_position (const gchar *recipients_list,
- gint position,
- gint *start,
- gint *end)
+ guint position,
+ guint *start,
+ guint *end)
{
gchar *current = NULL;
gint range_start = 0;
gint index;
gboolean is_quoted = FALSE;
+ g_return_if_fail (recipients_list);
+ g_return_if_fail (position < g_utf8_strlen(recipients_list, -1));
+
index = 0;
- for (current = (gchar *) recipients_list; *current != '\0'; current = g_utf8_find_next_char (current, NULL)) {
+ for (current = (gchar *) recipients_list; *current != '\0';
+ current = g_utf8_find_next_char (current, NULL)) {
gunichar c = g_utf8_get_char (current);
if ((c == ',') && (!is_quoted)) {
/**
* modest_text_utils_address_range_at_position:
- * @address_list: utf8 string containing a list of addresses
+ * @address_list: non-NULL utf8 string containing a list of addresses
* @position: a gint
* @start: a gint pointer
* @end: a gint pointer
* @end
*/
void modest_text_utils_address_range_at_position (const gchar *recipients_list,
- gint position,
- gint *start,
- gint *end);
+ guint position,
+ guint *start,
+ guint *end);
/**
* modest_text_utils_hyperlinkify_begin:
gtk_text_buffer_get_end_iter (buffer, &end_iter);
text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE);
- modest_text_utils_address_range_at_position (text,
- index,
- &selection_start, &selection_end);
- /* TODO: now gtk label tries to select more than the label as usual,
- * and we force it to recover the selected region for the defined area.
- * It should be fixed (maybe preventing gtklabel to manage selections
- * in parallel with us
- */
- gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, selection_start);
- gtk_text_buffer_get_iter_at_offset (buffer, &end_iter, selection_end);
- gtk_text_buffer_select_range (buffer, &start_iter, &end_iter);
-
- if (text)
+ /* text will not be NULL, but source code checkers should be satisfied */
+ if (text) {
+ modest_text_utils_address_range_at_position (text,
+ index,
+ &selection_start, &selection_end);
+ /* TODO: now gtk label tries to select more than the label as usual,
+ * and we force it to recover the selected region for the defined area.
+ * It should be fixed (maybe preventing gtklabel to manage selections
+ * in parallel with us
+ */
+ gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, selection_start);
+ gtk_text_buffer_get_iter_at_offset (buffer, &end_iter, selection_end);
+ gtk_text_buffer_select_range (buffer, &start_iter, &end_iter);
+
g_free (text);
-
+ }
}
-
+
if (selected) {
gchar *selection;