changeset 289:c020e1168cc3 HEAD

Ignore empty lines at beginning of mbox file.
author Timo Sirainen <tss@iki.fi>
date Sun, 22 Sep 2002 12:27:21 +0300
parents 0d75aa8b7344
children 3dcc2275b4ca
files src/lib-index/mbox/mbox-append.c src/lib-index/mbox/mbox-fsck.c src/lib-index/mbox/mbox-index.c src/lib-index/mbox/mbox-index.h src/lib-index/mbox/mbox-rebuild.c
diffstat 5 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mbox/mbox-append.c	Sat Sep 21 09:36:18 2002 +0300
+++ b/src/lib-index/mbox/mbox-append.c	Sun Sep 22 12:27:21 2002 +0300
@@ -168,8 +168,7 @@
 
 int mbox_index_append(MailIndex *index, IOBuffer *inbuf)
 {
-	if (inbuf->offset == inbuf->size ||
-	    inbuf->offset+1 == inbuf->size) {
+	if (inbuf->offset == inbuf->size) {
 		/* no new data */
 		return TRUE;
 	}
--- a/src/lib-index/mbox/mbox-fsck.c	Sat Sep 21 09:36:18 2002 +0300
+++ b/src/lib-index/mbox/mbox-fsck.c	Sun Sep 22 12:27:21 2002 +0300
@@ -199,11 +199,7 @@
 	if (!index->set_lock(index, MAIL_LOCK_EXCLUSIVE))
 		return FALSE;
 
-	/* skip empty lines at beginning */
-	while (io_buffer_read_data_blocking(inbuf, &data, &size, 0) > 0 &&
-	       (data[0] == '\r' || data[0] == '\n')) {
-		io_buffer_skip(inbuf, 1);
-	}
+	mbox_skip_empty_lines(inbuf);
 
 	/* first make sure we start with a "From " line. If file is too
 	   small, we'll just treat it as empty mbox file. */
--- a/src/lib-index/mbox/mbox-index.c	Sat Sep 21 09:36:18 2002 +0300
+++ b/src/lib-index/mbox/mbox-index.c	Sun Sep 22 12:27:21 2002 +0300
@@ -302,6 +302,18 @@
 	return TRUE;
 }
 
+void mbox_skip_empty_lines(IOBuffer *inbuf)
+{
+	unsigned char *data;
+	size_t size;
+
+	/* skip empty lines at beginning */
+	while (io_buffer_read_data_blocking(inbuf, &data, &size, 0) > 0 &&
+	       (data[0] == '\r' || data[0] == '\n')) {
+		io_buffer_skip(inbuf, 1);
+	}
+}
+
 int mbox_mail_get_start_offset(MailIndex *index, MailIndexRecord *rec,
 			       uoff_t *offset)
 {
--- a/src/lib-index/mbox/mbox-index.h	Sat Sep 21 09:36:18 2002 +0300
+++ b/src/lib-index/mbox/mbox-index.h	Sun Sep 22 12:27:21 2002 +0300
@@ -25,6 +25,7 @@
 			 void (*func)(const char *, size_t, int, void *),
 			 void *context);
 int mbox_skip_crlf(IOBuffer *inbuf);
+void mbox_skip_empty_lines(IOBuffer *inbuf);
 int mbox_mail_get_start_offset(MailIndex *index, MailIndexRecord *rec,
 			       uoff_t *offset);
 
--- a/src/lib-index/mbox/mbox-rebuild.c	Sat Sep 21 09:36:18 2002 +0300
+++ b/src/lib-index/mbox/mbox-rebuild.c	Sun Sep 22 12:27:21 2002 +0300
@@ -57,6 +57,7 @@
 
 	inbuf = io_buffer_create_mmap(fd, default_pool,
 				      MAIL_MMAP_BLOCK_SIZE, 0);
+	mbox_skip_empty_lines(inbuf);
 	failed = !mbox_index_append(index, inbuf);
 
 	(void)mbox_unlock(index, index->mbox_path, fd);