[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] Additional programs and language bindings branch, master, updated.
From: |
Daniele Forsi |
Subject: |
[SCM] Additional programs and language bindings branch, master, updated. 1ac2239de83460241edab15c85eab17bedce4b44 |
Date: |
Fri, 26 Apr 2013 10:12:01 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Additional programs and language bindings".
The branch, master has been updated
via 1ac2239de83460241edab15c85eab17bedce4b44 (commit)
from c9f81a0de41b653505e65f6b2a8a067ab33e4308 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii/gnokii-extras.git/commit/?id=1ac2239de83460241edab15c85eab17bedce4b44
commit 1ac2239de83460241edab15c85eab17bedce4b44
Author: Daniele Forsi <address@hidden>
Date: Fri Apr 26 12:11:03 2013 +0200
Do not return an error at EOF
An error is returned by gn_vcard2phonebook() if the input file contains
an empty line after the last END:VCARD which is the case for files created
by --readphonebook.
diff --git a/snippets/phonebook/phonebook_convert.c
b/snippets/phonebook/phonebook_convert.c
index 3ddf012..f7686a1 100644
--- a/snippets/phonebook/phonebook_convert.c
+++ b/snippets/phonebook/phonebook_convert.c
@@ -62,7 +62,7 @@ int str2type(const char *str) {
int main(int argc, char *argv[]) {
gn_error error = GN_ERR_NONE;
- int from_type, to_type;
+ int from_type, to_type, c;
gn_phonebook_entry entry;
char buffer[MAX_INPUT_LINE_LEN];
@@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
return -1;
}
- for (;;) {
+ while (!feof(stdin)) {
/* set default values which can be overriden by the conversion
functions */
memset(&entry, 0, sizeof(gn_phonebook_entry));
@@ -89,11 +89,10 @@ int main(int argc, char *argv[]) {
error = gn_file_phonebook_raw_parse(&entry,
buffer);
break;
case TYPE_VCARD:
- if (gn_vcard2phonebook(stdin, &entry))
+ if (gn_vcard2phonebook(stdin, &entry) < 0)
error = GN_ERR_WRONGDATAFORMAT;
break;
}
- if (feof(stdin)) return 0;
if (error != GN_ERR_NONE) break;
/* add here code to validate the entry, if needed */
@@ -109,11 +108,17 @@ int main(int argc, char *argv[]) {
break;
case TYPE_VCARD:
snprintf(buffer, sizeof(buffer), "%s%d",
gn_memory_type2str(entry.memory_type), entry.location);
- if (gn_phonebook2vcard(stdout, &entry, buffer))
+ if (gn_phonebook2vcard(stdout, &entry, buffer) < 0)
error = GN_ERR_UNKNOWN;
break;
}
if (error != GN_ERR_NONE) break;
+
+ /* gn_vcard2phonebook() gn_ldif2phonebook() return an error if
input file contains trailing empty lines */
+ do {
+ c = fgetc(stdin);
+ } while (c == '\r' || c == '\n');
+ ungetc(c, stdin);
}
if (error != GN_ERR_NONE) {
-----------------------------------------------------------------------
Summary of changes:
snippets/phonebook/phonebook_convert.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
hooks/post-receive
--
Additional programs and language bindings
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] Additional programs and language bindings branch, master, updated. 1ac2239de83460241edab15c85eab17bedce4b44,
Daniele Forsi <=