From 622b33900419f41143600dc9e65f2a8e8ab15219 Mon Sep 17 00:00:00 2001 From: Rafal Michalski Date: Thu, 22 Sep 2011 09:52:48 +0200 Subject: [PATCH] obexd: Simplify vCard's phone number printing Previously, it was trynig to create string (by snprintf function and stored in "buf" buffer) containing "%s" formatting piece for "vcard_printf" function. In this case "\%" is not valid escape sequence (it is "%%" for percent character) - backslash is ignored, so sequence "\%s" is treated as "%s" and replaced by string for "number" field when snprintf function is executed. Hence "vcard_printf" function has nothing to do with "number" field, since "buf" does not contain any "%s" formatting sequence. This patch make simplification for printing phone number field by avoiding storing formatting pieces (for instance "%%s"). Now string for phone number field is stored directly in "field" buffer (common with Quoted Printable encoding) and simply passed to "vcard_printf" function. --- obexd/plugins/vcard.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c index 307230640..f1d9edc50 100644 --- a/obexd/plugins/vcard.c +++ b/obexd/plugins/vcard.c @@ -450,17 +450,15 @@ static void vcard_printf_number(GString *vcards, uint8_t format, if ((type == TYPE_INTERNATIONAL) && (number[0] != '+')) intl = "+"; + snprintf(field, sizeof(field), "%s%s", intl, number); + if (select_qp_encoding(format, number, NULL)) { snprintf(buf, sizeof(buf), "TEL;%s", category_string); - snprintf(field, sizeof(field), "%s%s", intl, number); vcard_qp_print_encoded(vcards, buf, field, NULL); return; } - snprintf(buf, sizeof(buf), "TEL;%s:%s\%s", category_string, - intl, number); - - vcard_printf(vcards, buf, number); + vcard_printf(vcards, "TEL;%s:%s", category_string, field); } static void vcard_printf_tag(GString *vcards, uint8_t format, -- 2.47.3