From: Raphaƫl Droz Date: Sun, 23 Sep 2012 15:21:31 +0000 (+0200) Subject: vCard parser: use item_fput() to store phone numbers into the right fields X-Git-Tag: upstream/0.6.1~2^2~62 X-Git-Url: https://git.deb.at/w?p=pkg%2Fabook.git;a=commitdiff_plain;h=0c57d01df43a4d9d02456d694c2a0cd6cb80a637 vCard parser: use item_fput() to store phone numbers into the right fields --- diff --git a/filter.c b/filter.c index 7966f7e..a22d69e 100644 --- a/filter.c +++ b/filter.c @@ -1509,32 +1509,25 @@ vcard_parse_name(list_item item, char *line) static void vcard_parse_phone(list_item item, char *line) { - int index = 8; char *type = vcard_get_line_element(line, VCARD_KEY_ATTRIBUTE); char *value = vcard_get_line_element(line, VCARD_VALUE); /* set the standard number */ - if (!type) { - item[index] = value; - } + if (!type) item_fput(item, PHONE, value); /* * see rfc2426 section 3.3.1 * Note: we probably support both vCard 2 and 3 */ else { - if (strcasestr(type, "home") != NULL) { - item[index] = xstrdup(value); - } - if (strcasestr(type, "work") != NULL) { - item[index+1] = xstrdup(value); - } - if (strcasestr(type, "fax") != NULL) { - item[index+2] = xstrdup(value); - } - if (strcasestr(type, "cell") != NULL) { - item[index+3] = xstrdup(value); - } + if (strcasestr(type, "home") != NULL) + item_fput(item, PHONE, xstrdup(value)); + else if (strcasestr(type, "work") != NULL) + item_fput(item, WORKPHONE, xstrdup(value)); + else if (strcasestr(type, "fax") != NULL) + item_fput(item, FAX, xstrdup(value)); + else if (strcasestr(type, "cell") != NULL) + item_fput(item, MOBILEPHONE, xstrdup(value)); xfree(type); xfree(value);