From: Dirk-Jan C. Binnema Date: Mon, 11 Dec 2006 12:42:15 +0000 (+0000) Subject: * modest-text-utils.[ch]: X-Git-Tag: git_migration_finished~4339 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=7f9d1f70237b84a7ed1261681a6e11b644ecc73c * modest-text-utils.[ch]: - modest_text_utils_display_address: small cleanup, clarifications --> unit tests work pmo-trunk-r540 --- diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index 1fb11e7..0900a69 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -664,16 +664,24 @@ modest_text_utils_display_address (gchar *address) g_return_val_if_fail (g_utf8_validate (address, -1, NULL), NULL); - /* simplistic --> remove from display name */ + g_strchug (address); /* remove leading whitespace */ + + /* from display name */ cursor = g_strstr_len (address, strlen(address), "<"); + if (cursor == address) /* there's nothing else? leave it */ + return address; 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), "("); + if (cursor == address) /* there's nothing else? leave it */ + return address; if (cursor) cursor[0]='\0'; - + + g_strchomp (address); /* remove trailing whitespace */ + return address; } diff --git a/src/modest-text-utils.h b/src/modest-text-utils.h index 05a4b9b..d85db84 100644 --- a/src/modest-text-utils.h +++ b/src/modest-text-utils.h @@ -34,6 +34,7 @@ #define __MODEST_TEXT_UTILS_H__ #include +#include /** * modest_text_utils_derived_subject: @@ -145,8 +146,9 @@ size_t modest_text_utils_strftime(char *s, size_t max, const char *fmt, const * @address: original address (UTF8 string) * * make a 'display address' from an address: - * "Foo Bar (Bla)" --> "Foo Bar" - * the change is in-place + * "Foo Bar (Bla)" --> "Foo Bar" + * ie. removes "<...>" and "(...)" parts + * the change is in-place; removes leading/trailing whitespace * * Returns: the new address. The string is *not* newly allocated. * NULL in case of error