Commit 3fefeaa4 3fefeaa458075ca20381284950b32f6afdccfffe by Sergey Poznyakoff

Bugfixes.

* mailbox/rfc2047.c (mu_rfc2047_decode): Rewind in_stream.
* mailbox/stream.c (_stream_scandelim): Break the loop when
the delimiter is found.
* mailbox/streamref.c (_streamref_readdelim): Take into account
the abridgement.
1 parent f96ce94e
......@@ -163,6 +163,7 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr)
mu_memory_stream_create (&in_stream, 0);
mu_stream_write (in_stream, encoded_text, size, NULL);
mu_stream_seek (in_stream, 0, MU_SEEK_SET, NULL);
status = mu_decode_filter (&filter, in_stream, filter_type, fromcode,
tocode);
if (status != 0)
......
......@@ -563,6 +563,8 @@ _stream_scandelim (mu_stream_t stream, char *buf, size_t size, int delim,
buf += len;
size -= len;
nread += len;
if (p) /* Delimiter found */
break;
}
*buf = 0;
*pnread = nread;
......
......@@ -73,9 +73,33 @@ _streamref_readdelim (struct _mu_stream *str, char *buf, size_t bufsize,
int delim, size_t *pnread)
{
struct _mu_streamref *sp = (struct _mu_streamref *)str;
return streamref_return (sp, mu_stream_readdelim (sp->transport,
buf, bufsize,
delim, pnread));
int rc;
size_t nread;
mu_off_t off;
rc = mu_stream_seek (sp->transport, sp->offset, MU_SEEK_SET, &off);
if (rc == 0)
{
if (sp->end)
{
size_t size = sp->end - off + 2; /* extra 1 to account for \0 */
if (size < bufsize)
bufsize = size;
}
rc = mu_stream_readdelim (sp->transport, buf, bufsize, delim, &nread);
if (rc == 0)
{
sp->offset += nread;
*pnread = nread;
}
}
else if (rc == ESPIPE)
{
*pnread = 0;
mu_stream_clearerr (sp->transport);
return 0;
}
return streamref_return (sp, rc);
}
static int
......