X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-text-utils.c;h=cfa6414d7e152b4f9498b78017b39367137c317b;hp=038ac26eb57a0ea988b1d127739da4bf6dd1e7a1;hb=32ba35b63ed6986eab57acf8bfd76dba10ee129e;hpb=22c65ebfd20d1203fd9500498205e8ab755298b9 diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index 038ac26..cfa6414 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -376,6 +376,43 @@ modest_text_utils_split_addresses_list (const gchar *addresses) } +void +modest_text_utils_address_range_at_position (const gchar *recipients_list, + gint position, + gint *start, + gint *end) +{ + gchar *current = NULL; + gint range_start = 0; + gint range_end = 0; + gint index; + gboolean is_quoted = FALSE; + + index = 0; + 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)) { + if (index < position) { + range_start = index + 1; + } else { + break; + } + } else if (c == '\"') { + is_quoted = !is_quoted; + } else if ((c == ' ') &&(range_start == index)) { + range_start ++; + } + index ++; + range_end = index; + } + + if (start) + *start = range_start; + if (end) + *end = range_end; +} + /* ******************************************************************* */ /* ************************* UTILIY FUNCTIONS ************************ */