Commit 1dc5c3b2 1dc5c3b255cf2ba5f97b5984d7f8480497a37d06 by Sergey Poznyakoff

Updated call to filter_iconv_create()

1 parent c563f0a8
...@@ -42,7 +42,7 @@ main (int argc, char **argv) ...@@ -42,7 +42,7 @@ main (int argc, char **argv)
42 rc = stdio_stream_create (&in, stdin, 0); 42 rc = stdio_stream_create (&in, stdin, 0);
43 assert (rc == 0); 43 assert (rc == 0);
44 assert (stream_open (in) == 0); 44 assert (stream_open (in) == 0);
45 assert (filter_iconv_create (&cvt, in, argv[1], argv[2], 0) == 0); 45 assert (filter_iconv_create (&cvt, in, argv[1], argv[2], 0, mu_fallback_none) == 0);
46 assert (stream_open (cvt) == 0); 46 assert (stream_open (cvt) == 0);
47 47
48 rc = stdio_stream_create (&out, stdout, 0); 48 rc = stdio_stream_create (&out, stdout, 0);
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
27 #include <mailutils/filter.h> 27 #include <mailutils/filter.h>
28 #include <mailutils/errno.h> 28 #include <mailutils/errno.h>
29 29
30 enum mu_iconv_fallback_mode rfc2047_fallback_mode = mu_fallback_copy_octal;
31
30 int 32 int
31 rfc2047_decode (const char *tocode, const char *input, char **ptostr) 33 rfc2047_decode (const char *tocode, const char *input, char **ptostr)
32 { 34 {
...@@ -121,14 +123,30 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr) ...@@ -121,14 +123,30 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
121 if (status != 0) 123 if (status != 0)
122 break; 124 break;
123 125
124 status = filter_iconv_create (&cvt, filter, fromcode, tocode, 0); 126 status = filter_iconv_create (&cvt, filter, fromcode, tocode,
127 MU_STREAM_NO_CLOSE,
128 rfc2047_fallback_mode);
125 if (status) 129 if (status)
130 {
126 cvt = filter; 131 cvt = filter;
132 /* Note: the filter stream is already open! */
133 }
134 else
135 {
127 if (stream_open (cvt)) 136 if (stream_open (cvt))
128 { 137 {
129 stream_destroy (cvt, stream_get_owner (cvt)); 138 stream_destroy (&cvt, stream_get_owner (cvt));
130 cvt = filter; 139 cvt = filter;
131 } 140 }
141 else
142 {
143 int flags;
144 stream_get_flags (cvt, &flags);
145 flags &= ~MU_STREAM_NO_CLOSE;
146 stream_set_flags (cvt, flags);
147 }
148 }
149
132 while (stream_sequential_read (cvt, buffer + bufpos, 150 while (stream_sequential_read (cvt, buffer + bufpos,
133 bufsize - bufpos, 151 bufsize - bufpos,
134 &nbytes) == 0 && nbytes) 152 &nbytes) == 0 && nbytes)
......