projects
/
modest
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* modest-text-utils.[ch]:
[modest]
/
src
/
modest-text-utils.c
diff --git
a/src/modest-text-utils.c
b/src/modest-text-utils.c
index
1fb11e7
..
5cf47bc
100644
(file)
--- a/
src/modest-text-utils.c
+++ b/
src/modest-text-utils.c
@@
-198,8
+198,10
@@
modest_text_utils_derived_subject (const gchar *subject, const gchar *prefix)
{
gchar *tmp;
{
gchar *tmp;
+ g_return_val_if_fail (prefix, NULL);
+
if (!subject)
if (!subject)
- return g_strdup_printf ("%s ", prefix);
+ return g_strdup (prefix);
tmp = g_strchug (g_strdup (subject));
tmp = g_strchug (g_strdup (subject));
@@
-211,16
+213,18
@@
modest_text_utils_derived_subject (const gchar *subject, const gchar *prefix)
}
}
}
}
-gchar *
+gchar*
modest_text_utils_remove_address (const gchar *address_list, const gchar *address)
{
modest_text_utils_remove_address (const gchar *address_list, const gchar *address)
{
- char *dup, *token, *ptr, *result;
+ gchar *dup, *token, *ptr, *result;
GString *filtered_emails;
GString *filtered_emails;
- if (!address_list)
- return NULL;
+ g_return_val_if_fail (address_list, NULL);
- /* Search for substring */
+ if (!address)
+ return g_strdup (address_list);
+
+ /* search for substring */
if (!strstr ((const char *) address_list, (const char *) address))
return g_strdup (address_list);
if (!strstr ((const char *) address_list, (const char *) address))
return g_strdup (address_list);
@@
-233,9
+237,9
@@
modest_text_utils_remove_address (const gchar *address_list, const gchar *addres
/* Add to list if not found */
if (!strstr ((const char *) token, (const char *) address)) {
if (filtered_emails->len == 0)
/* Add to list if not found */
if (!strstr ((const char *) token, (const char *) address)) {
if (filtered_emails->len == 0)
- g_string_append_printf (filtered_emails, "%s", token);
+ g_string_append_printf (filtered_emails, "%s", g_strstrip (token));
else
else
- g_string_append_printf (filtered_emails, ",%s", token);
+ g_string_append_printf (filtered_emails, ",%s", g_strstrip (token));
}
token = strtok_r (NULL, ",", &ptr);
}
}
token = strtok_r (NULL, ",", &ptr);
}
@@
-664,16
+668,24
@@
modest_text_utils_display_address (gchar *address)
g_return_val_if_fail (g_utf8_validate (address, -1, NULL), NULL);
g_return_val_if_fail (g_utf8_validate (address, -1, NULL), NULL);
- /* simplistic --> remove <email@address> from display name */
+ g_strchug (address); /* remove leading whitespace */
+
+ /* <email@address> from display name */
cursor = g_strstr_len (address, strlen(address), "<");
cursor = g_strstr_len (address, strlen(address), "<");
+ if (cursor == address) /* there's nothing else? leave it */
+ return address;
if (cursor)
cursor[0]='\0';
if (cursor)
cursor[0]='\0';
- /* simplistic --> remove (bla bla) from display name */
+ /* remove (bla bla) from display name */
cursor = g_strstr_len (address, strlen(address), "(");
cursor = g_strstr_len (address, strlen(address), "(");
+ if (cursor == address) /* there's nothing else? leave it */
+ return address;
if (cursor)
cursor[0]='\0';
if (cursor)
cursor[0]='\0';
-
+
+ g_strchomp (address); /* remove trailing whitespace */
+
return address;
}
return address;
}