(name[0] == '.' && name[1] != '/');
}
-int is_a_leading_from_line(char *s) {
- return strncmp(s, "From ", 5) == 0 &&
- regexec(&leading_from_line_regexp, s, 0, 0, 0) == 0;
+int is_a_leading_from_line(int last_mbox_line_was_empty, char *mbox_line) {
+ return
+
+ /*
+
+ The mbox man page in qmail documentation states:
+
+ > The reader should not attempt to take advantage of the fact
+ > that every From_ line (past the beginning of the file) is
+ > preceded by a blank line.
+
+ */
+
+ /* last_mbox_line_was_empty && */
+ strncmp(mbox_line, "From ", 5) == 0 &&
+ regexec(&leading_from_line_regexp, mbox_line, 0, 0, 0) == 0;
}
int mbox_line_match_search(struct search_condition *condition,
}
if(!fgets(raw_mbox_line, BUFFER_SIZE, mail_file) ||
- (last_mbox_line_was_empty &&
- is_a_leading_from_line(raw_mbox_line)))
+ (is_a_leading_from_line(last_mbox_line_was_empty, raw_mbox_line)))
break;
}
}
fprintf(output_file, "%s", raw_mbox_line);
while(1) {
if(!fgets(raw_mbox_line, BUFFER_SIZE, mail_file) ||
- (last_mbox_line_was_empty &&
- is_a_leading_from_line(raw_mbox_line))
+ (is_a_leading_from_line(last_mbox_line_was_empty, raw_mbox_line))
)
break;
last_mbox_line_was_empty = (raw_mbox_line[0] == '\n');
last_mbox_line_was_empty = 1;
while(fgets(raw_mbox_line, BUFFER_SIZE, file)) {
- if(last_mbox_line_was_empty &&
- is_a_leading_from_line(raw_mbox_line)) {
+ if(is_a_leading_from_line(last_mbox_line_was_empty, raw_mbox_line)) {
if(in_header) {
fprintf(stderr,
"Got a ^\"From \" in the header in %s:%lu.\n",