[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-46
From: |
Daniele Forsi |
Subject: |
[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-463-g3795eb7 |
Date: |
Tue, 16 Apr 2013 14:43:02 +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 "libgnokii and core programs".
The branch, master has been updated
via 3795eb73e6f03a959db6908d31181b04a3fbb7de (commit)
from c4cd4e8be89b84fa6f70a2ec08599ef4b5b53120 (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.git/commit/?id=3795eb73e6f03a959db6908d31181b04a3fbb7de
commit 3795eb73e6f03a959db6908d31181b04a3fbb7de
Author: Daniele Forsi <address@hidden>
Date: Tue Apr 16 10:19:24 2013 +0200
Fix conversion to UCS-2
Make char_mbtowc() more similar to the symmetric function char_wctomb()
by hardcoding the length of the buffer containing the wchar_t (we're
processing one wchar_t at a time anyway in both functions) and handle
multibyte characters in char_ucs2_encode().
We can't pass "1" as input length if the current position in the source
buffer is the start of a multibyte character, such as accented letters
in UTF-8, so we need to let char_mbtowc() process as many bytes are
needed (and present in the buffer) but since the only user of
char_mbtowc() always passes a destination buffer sized to contain only
one wchar_t, the length of the output buffer must be of fixed size.
Test case:
echo -e "BEGIN:VCARD\nFN:Régine\nTEL;TYPE=PREF,VOICE:0000\nEND:VCARD\n" |
gnokii --phone fake --writephonebook --vcard --overwrite
Correct output, after this fix:
AT+CPBW=1,"0030003000300030",129,"005200E900670069006E0065"
Wrong output, before this fix:
AT+CPBW=1,"0030003000300030",129,"0052"
diff --git a/common/gsm-encoding.c b/common/gsm-encoding.c
index eee75a7..8a22d13 100644
--- a/common/gsm-encoding.c
+++ b/common/gsm-encoding.c
@@ -246,9 +246,8 @@ static int char_mbtowc(wchar_t *dst, const char *src, int
maxlen, MBSTATE *mbs)
pin = (char *)src;
pout = (char *)dst;
- /* Let's assume that we have at most 4-bytes wide characters */
inlen = maxlen;
- outlen = maxlen * sizeof(wchar_t);
+ outlen = sizeof(wchar_t);
cd = iconv_open("WCHAR_T", gn_char_get_encoding());
if (cd == (iconv_t)-1)
@@ -922,12 +921,13 @@ size_t char_ucs2_encode(char *dest, size_t dest_len,
const char *src, size_t len
MBSTATE mbs;
MBSTATE_ENC_CLEAR(mbs);
- for (i = 0, o_len = 0; i < len && o_len < dest_len / UCS2_SIZE;
o_len++, i++) {
+ for (i = 0, o_len = 0; i < len && o_len < dest_len / UCS2_SIZE;
o_len++, i += length) {
/*
- * We read input by convertible chunks. 'length' is length of
- * the read chunk.
+ * We need to pass the number of bytes remaining in the source
+ * buffer so the function can read as many are needed to decode
+ * a possibly multibyte character and return how many were used.
*/
- length = char_uni_alphabet_encode(src + i, 1, &wc, &mbs);
+ length = char_uni_alphabet_encode(src + i, len - i, &wc, &mbs);
/* We stop reading after first unreadable input */
if (length < 1)
return o_len * UCS2_SIZE;
-----------------------------------------------------------------------
Summary of changes:
common/gsm-encoding.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
hooks/post-receive
--
libgnokii and core programs
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-463-g3795eb7,
Daniele Forsi <=