summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-05-01 20:51:57 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-05-01 20:51:57 +0300
commit62db89e3dca29f9b931c62b25014955a4ede36c0 (patch)
tree282c09695c8eed086e0d342a34d4a3d2b94add40
parent17e7050b820314f268996c7f06ae9344a5f4f5c2 (diff)
downloadmailutils-62db89e3dca29f9b931c62b25014955a4ede36c0.tar.gz
mailutils-62db89e3dca29f9b931c62b25014955a4ede36c0.tar.bz2
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.
-rw-r--r--mailbox/rfc2047.c1
-rw-r--r--mailbox/stream.c2
-rw-r--r--mailbox/streamref.c30
3 files changed, 30 insertions, 3 deletions
diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index a5f61b417..df19d9fe8 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -162,6 +162,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)
diff --git a/mailbox/stream.c b/mailbox/stream.c
index 21e4fec54..4e74caf02 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -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;
diff --git a/mailbox/streamref.c b/mailbox/streamref.c
index 0cad3faf7..de5fec8f9 100644
--- a/mailbox/streamref.c
+++ b/mailbox/streamref.c
@@ -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

Return to:

Send suggestions and report system problems to the System administrator.