summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Varshavchik2018-07-13 20:18:57 -0400
committerSam Varshavchik2018-07-13 20:43:16 -0400
commit83b8a17c2dbb0feccc7c1c02d7d170ef84880126 (patch)
treea027bbee394867f277d5174b1af374b5900f7582
parentfdc3f1b75ed5dbded07c69c1000f31bb7c74f0e0 (diff)
downloadcourier-libs-83b8a17c2dbb0feccc7c1c02d7d170ef84880126.tar.bz2
courier-unicode: update the internal x-smap-modutf8 encoding
-rw-r--r--unicode/Makefile.am2
-rw-r--r--unicode/courier-unicode.h.in2
-rw-r--r--unicode/unicode.c20
3 files changed, 14 insertions, 10 deletions
diff --git a/unicode/Makefile.am b/unicode/Makefile.am
index bb46ae6..0f6784e 100644
--- a/unicode/Makefile.am
+++ b/unicode/Makefile.am
@@ -167,7 +167,7 @@ check-am: unicodetest
test "`./unicodetest 'foobааааааr'`" = "foob&BDAEMAQwBDAEMAQw-r"
test "`./unicodetest 'foobаaаr'`" = "foob&BDA-a&BDA-r"
test "`./unicodetest 'foobааaааr'`" = "foob&BDAEMA-a&BDAEMA-r"
- test "`./unicodetest --smaputf8 'hello world'`" = 'hello\040world'
+ test "`./unicodetest --smaputf8 'hello world'`" = 'hello world'
test "`./unicodetest --smaputf8 'hello\\\\world'`" = 'hello\134\134world'
test "`./unicodetest --smaputf8 ':hello:world:'`" = '\072hello\072world\072'
n="aaaaaaaa"; n="$$n$$n$$n$$n"; n="$$n$$n$$n$$n"; n="$$n$$n$$n$$n"; n="$$n$$n"; n="`echo $$n | cut -c1-1023`"; test "`./unicodetest $$n`" = "$$n"
diff --git a/unicode/courier-unicode.h.in b/unicode/courier-unicode.h.in
index 7c6a00d..32d7f0d 100644
--- a/unicode/courier-unicode.h.in
+++ b/unicode/courier-unicode.h.in
@@ -993,7 +993,7 @@ extern const char unicode_u_ucs2_native[];
** However, to support SMAP we will still need to encode/decode some
** special characters.
**
-** The characters U+0000-U+0020 (including space), and ./~:\
+** The characters U+0000-U+001F, and ./~:\
**
** They are encoded as a backslash followed by three octal digits.
*/
diff --git a/unicode/unicode.c b/unicode/unicode.c
index 2cf5856..82d5c21 100644
--- a/unicode/unicode.c
+++ b/unicode/unicode.c
@@ -309,8 +309,8 @@ unicode_convert_init(const char *src_chset,
memset(toutf7, 0, sizeof(*toutf7));
- h=init_nottoimaputf7(src_chset, unicode_u_ucs2_native,
- do_convert_toutf7, toutf7);
+ h=unicode_convert_init(src_chset, unicode_u_ucs2_native,
+ do_convert_toutf7, toutf7);
if (!h)
{
free(toutf7);
@@ -482,9 +482,9 @@ init_nottoimaputf7(const char *src_chset,
memset(toutf8, 0, sizeof(*toutf8));
- h=init_nottosmaputf8(src_chset, "utf-8",
- do_convert_tosmaputf8,
- toutf8);
+ h=unicode_convert_init(src_chset, "utf-8",
+ do_convert_tosmaputf8,
+ toutf8);
if (!h)
{
free(toutf8);
@@ -511,6 +511,9 @@ static int deinit_tosmaputf8(void *ptr, int *errptr)
/* Flush out the downstream stack */
rc=(*toutf8->hdr.next->deinit_handler)(toutf8->hdr.next->ptr, errptr);
+ if (toutf8->errflag && rc == 0)
+ rc=toutf8->errflag;
+
free(toutf8);
return rc;
}
@@ -529,7 +532,8 @@ static int do_convert_tosmaputf8(const char *text, size_t cnt, void *arg)
return toutf8->errflag;
for (i=0; i<cnt; ++i)
- if (strchr(" ./~:\\", text[i]))
+ if ((unsigned char)text[i] < ' ' ||
+ strchr("./~:\\", text[i]))
break;
if (i)
{
@@ -669,7 +673,7 @@ init_nottosmaputf8(const char *src_chset,
/* Create a stack for converting UCS-2 to the dest charset */
- h=init_notfromimaputf7(unicode_u_ucs2_native, dst_chset,
+ h=unicode_convert_init(unicode_u_ucs2_native, dst_chset,
output_func, convert_arg);
if (!h)
@@ -863,7 +867,7 @@ init_notfromimaputf7(const char *src_chset,
/* Create a stack for converting UTF-8 to the dest charset */
- h=init_notfromimaputf7("utf-8", dst_chset,
+ h=unicode_convert_init("utf-8", dst_chset,
output_func, convert_arg);
if (!h)