aboutsummaryrefslogtreecommitdiff
path: root/lib/common.vala
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common.vala')
-rw-r--r--lib/common.vala16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/common.vala b/lib/common.vala
index 4d8b9add..9824bc26 100644
--- a/lib/common.vala
+++ b/lib/common.vala
@@ -16,18 +16,22 @@
* Authors: William Hua <william.hua@canonical.com>
*/
-string get_abbreviation (string name) {
+string? abbreviate (string? name) {
var index = 0;
unichar first;
unichar second;
- if (name.get_next_char (ref index, out first)) {
- if (name.get_next_char (ref index, out second)) {
- return @"$((!) first.toupper ().to_string ())$((!) second.to_string ())";
+ if (name != null) {
+ if (((!) name).get_next_char (ref index, out first)) {
+ if (((!) name).get_next_char (ref index, out second)) {
+ return @"$((!) first.toupper ().to_string ())$((!) second.to_string ())";
+ } else {
+ return first.toupper ().to_string ();
+ }
} else {
- return (!) first.toupper ().to_string ();
+ return "";
}
} else {
- return "";
+ return null;
}
}