From 0c57d01df43a4d9d02456d694c2a0cd6cb80a637 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Droz?= Date: Sun, 23 Sep 2012 17:21:31 +0200 Subject: [PATCH] vCard parser: use item_fput() to store phone numbers into the right fields --- filter.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) 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); -- 2.39.2