Code clean-up: Remove unnecessary empty lines
PATCH 1/4 Code clean-up: Remove unnecessary empty lines
This patch removes unnecessary empty lines.
--- plugins/phonebook-tracker.c | 1 - plugins/vcard.c | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
plugins/phonebook-tracker.c +0 -1
@@ -1003,7 +1003,6 @@ static void add_affiliation(char **field, const char *value)static void contact_init (struct phonebook_contact *contact,const char **reply) { - contact->fullname =g_strdup (reply[COL_FULL_NAME ]); contact->family =g_strdup (reply[COL_FAMILY_NAME ]); contact->given =g_strdup (reply[COL_GIVEN_NAME ]);
plugins/vcard.c +0 -1
@@ -825,7 +825,6 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,vcard_printf_end (vcards); } -static void field_free (gpointer data) {struct phonebook_field *field = data;
Signature · 1 line
1.6.3.3
PATCH 2/4 Code clean-up: Remove unnecessary character in comment
This patch removes unnecessary comment's character.
--- plugins/vcard.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/vcard.c +1 -1
@@ -681,7 +681,7 @@ static void vcard_printf_address(GString *vcards, uint8_t format,g_strlcat (fields, field_esc, len);if (l->next) -/* not addding ';' after last addr field */ +/* not adding ';' after last addr field */ g_strlcat (fields,";" , len); }
Signature · 1 line
1.6.3.3
PATCH 3/4 Code clean-up: Remove magic number indicating size of buffer
This patch removes "magic number" indicating buffer's size in "vcard_printf_number" function and replace it by value defined under LEN_MAX. Now it would be consistent with the rest of code, since all functions from vcard_prinf_* family use LEN_MAX to indicate size of buffer which may store some vCard's field content.
--- plugins/vcard.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/vcard.c +1 -1
@@ -406,7 +406,7 @@ static void vcard_printf_number(GString *vcards, uint8_t format, enum phonebook_number_type category) {const char *intl ="" , *category_string ="" ; -char buf[128 ], field[LEN_MAX ]; +char buf[LEN_MAX ], field[LEN_MAX ];/* TEL is a mandatory field, include even if empty */ if (!number || !strlen (number) || !type) {
Signature · 1 line
1.6.3.3
PATCH 4/4 Code clean-up: 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.
--- plugins/vcard.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
plugins/vcard.c +3 -5
@@ -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,
Signature · 1 line
1.6.3.3
Hi Rafal,
Quoted 5 lines · Rafal Michalski
This patch removes unnecessary empty lines.
--- plugins/phonebook-tracker.c | 1 - plugins/vcard.c | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
All four patches applied. Thanks.
Johan