diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-09-09 17:47:27 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-09-09 17:47:27 +0000 |
commit | 03b3c04755082cf45dccf944b412d4b79aeabb72 (patch) | |
tree | 72ff6fe9d3c3bbc4bac27bdcd317067fdfb7ecdf /src/utils.c | |
parent | b7f625ed8003197cd9d0a81240aea944860c8dc3 (diff) | |
parent | 2bf6740a420f35942e9f74b7f7ef566de0ba736b (diff) | |
download | ayatana-indicator-datetime-03b3c04755082cf45dccf944b412d4b79aeabb72.tar.gz ayatana-indicator-datetime-03b3c04755082cf45dccf944b412d4b79aeabb72.tar.bz2 ayatana-indicator-datetime-03b3c04755082cf45dccf944b412d4b79aeabb72.zip |
name says it all; this branch is for improving indicator-datetime test coverage.
Approved by Ted Gould, PS Jenkins bot.
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/utils.c b/src/utils.c index 1c3626d..9b0f24f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -53,32 +53,41 @@ is_locale_12h (void) void split_settings_location (const gchar * location, gchar ** zone, gchar ** name) { - gchar * location_dup = g_strdup (location); - gchar * first = strchr (location_dup, ' '); + gchar * location_dup; + gchar * first; - if (first) { - first[0] = 0; - } + location_dup = g_strdup (location); + g_strstrip (location_dup); - if (zone) { - *zone = location_dup; - } + if ((first = strchr (location_dup, ' '))) + *first = '\0'; - if (name) { - gchar * after = first ? g_strstrip (first + 1) : NULL; - if (after == NULL || after[0] == 0) { - /* Make up name from zone */ - gchar * chr = strrchr (location_dup, '/'); - after = g_strdup (chr ? chr + 1 : location_dup); - while ((chr = strchr (after, '_')) != NULL) { /* and turn underscores to spaces */ - *chr = ' '; - } - *name = after; + if (zone != NULL) + { + *zone = location_dup; } - else { - *name = g_strdup (after); + + if (name != NULL) + { + gchar * after = first ? g_strstrip (first + 1) : NULL; + + if (after && *after) + { + *name = g_strdup (after); + } + else /* make the name from zone */ + { + gchar * chr = strrchr (location_dup, '/'); + after = g_strdup (chr ? chr + 1 : location_dup); + + /* replace underscores with spaces */ + for (chr=after; chr && *chr; chr++) + if (*chr == '_') + *chr = ' '; + + *name = after; + } } - } } gchar * |