# HG changeset patch # User Timo Sirainen # Date 1032686841 -10800 # Node ID c020e1168cc3e5eb19554e61ea12d15f39ad96db # Parent 0d75aa8b73447d6a394a649d71ecf006705459b1 Ignore empty lines at beginning of mbox file. diff -r 0d75aa8b7344 -r c020e1168cc3 src/lib-index/mbox/mbox-append.c --- 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; } diff -r 0d75aa8b7344 -r c020e1168cc3 src/lib-index/mbox/mbox-fsck.c --- 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. */ diff -r 0d75aa8b7344 -r c020e1168cc3 src/lib-index/mbox/mbox-index.c --- 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) { diff -r 0d75aa8b7344 -r c020e1168cc3 src/lib-index/mbox/mbox-index.h --- 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); diff -r 0d75aa8b7344 -r c020e1168cc3 src/lib-index/mbox/mbox-rebuild.c --- 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);