From 0e3bb46532e1858f2cfee808bd66efa225cb2d94 Mon Sep 17 00:00:00 2001 From: William Hua Date: Wed, 7 Aug 2013 15:11:32 -0400 Subject: Split useful code into separate Source object. --- lib/common.vala | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/common.vala') 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 */ -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; } } -- cgit v1.2.3