From: Rafal Michalski <michalski.raf@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Rafal Michalski <michalski.raf@gmail.com>
Subject: [PATCH obexd 4/4] Code clean-up: Simplify vCard's phone number printing
Date: Thu, 22 Sep 2011 09:52:48 +0200 [thread overview]
Message-ID: <1316677968-3494-4-git-send-email-michalski.raf@gmail.com> (raw)
In-Reply-To: <1316677968-3494-3-git-send-email-michalski.raf@gmail.com>
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.
---
plugins/vcard.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 901a2ac..5b581fb 100644
--- a/plugins/vcard.c
+++ b/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,
--
1.6.3.3
next prev parent reply other threads:[~2011-09-22 7:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-22 7:52 [PATCH obexd 1/4] Code clean-up: Remove unnecessary empty lines Rafal Michalski
2011-09-22 7:52 ` [PATCH obexd 2/4] Code clean-up: Remove unnecessary character in comment Rafal Michalski
2011-09-22 7:52 ` [PATCH obexd 3/4] Code clean-up: Remove magic number indicating size of buffer Rafal Michalski
2011-09-22 7:52 ` Rafal Michalski [this message]
2011-09-27 9:49 ` [PATCH obexd 1/4] Code clean-up: Remove unnecessary empty lines Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1316677968-3494-4-git-send-email-michalski.raf@gmail.com \
--to=michalski.raf@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).