- c = (cnt < i ? cnt : i);
- if (msg_style != MS_DEFAULT && c > 1) {
- /*
- * packed maildrop - only take up to the (possible)
- * start of the next message. This "matchc" should
- * probably be a Boyer-Moore matcher for non-vaxen,
- * particularly since we have the alignment table
- * all built for the end-of-buffer test (next).
- * But our vax timings indicate that the "matchc"
- * instruction is 50% faster than a carefully coded
- * B.M. matcher for most strings. (So much for elegant
- * algorithms vs. brute force.) Since I (currently)
- * run MH on a vax, we use the matchc instruction. --vj
- */
- if ((ep = matchc( fdelimlen, fdelim, c, bp )))
- c = ep - bp + 1;
- else {
- /*
- * There's no delim in the buffer but there may be
- * a partial one at the end. If so, we want to leave
- * it so the "eom" check on the next call picks it up.
- * Use a modified Boyer-Moore matcher to make this
- * check relatively cheap. The first "if" figures
- * out what position in the pattern matches the last
- * character in the buffer. The inner "while" matches
- * the pattern against the buffer, backwards starting
- * at that position. Note that unless the buffer
- * ends with one of the characters in the pattern
- * (excluding the first and last), we do only one test.
- */
- ep = bp + c - 1;
- if ((sp = pat_map[*ep])) {
- do {
- cp = sp;
- while (*--ep == *--cp)
- ;
- if (cp < fdelim) {
- if (ep >= bp)
- /*
- * ep < bp means that all the buffer
- * contains is a prefix of delim.
- * If this prefix is really a delim, the
- * m_eom call at entry should have found
- * it. Thus it's not a delim and we can
- * take all of it.
- */
- c = (ep - bp) + 2;
- break;
+ c = (cnt < i ? cnt : i);
+ if (msg_style != MS_DEFAULT && c > 1) {
+ /*
+ * packed maildrop - only take up to the (possible)
+ * start of the next message. This "matchc" should
+ * probably be a Boyer-Moore matcher for non-vaxen,
+ * particularly since we have the alignment table
+ * all built for the end-of-buffer test (next).
+ * But our vax timings indicate that the "matchc"
+ * instruction is 50% faster than a carefully coded
+ * B.M. matcher for most strings. (So much for elegant
+ * algorithms vs. brute force.) Since I (currently)
+ * run MH on a vax, we use the matchc instruction. --vj
+ */
+ if ((ep = matchc( fdelimlen, fdelim, c, bp )))
+ c = ep - bp + 1;
+ else {
+ /*
+ * There's no delim in the buffer but there may be
+ * a partial one at the end. If so, we want to leave
+ * it so the "eom" check on the next call picks it up.
+ * Use a modified Boyer-Moore matcher to make this
+ * check relatively cheap. The first "if" figures
+ * out what position in the pattern matches the last
+ * character in the buffer. The inner "while" matches
+ * the pattern against the buffer, backwards starting
+ * at that position. Note that unless the buffer
+ * ends with one of the characters in the pattern
+ * (excluding the first and last), we do only one test.
+ */
+ ep = bp + c - 1;
+ if ((sp = pat_map[*ep])) {
+ do {
+ /* This if() is true unless (a) the buffer is too
+ * small to contain this delimiter prefix, or
+ * (b) it contains exactly enough chars for the
+ * delimiter prefix.
+ * For case (a) obviously we aren't going to match.
+ * For case (b), if the buffer really contained exactly
+ * a delim prefix, then the m_eom call at entry
+ * should have found it. Thus it's not a delim
+ * and we know we won't get a match.
+ */
+ if (((sp - fdelim) + 2) <= c) {
+ cp = sp;
+ /* Unfortunately although fdelim has a preceding NUL
+ * we can't use this as a sentinel in case the buffer
+ * contains a NUL in exactly the wrong place (this
+ * would cause us to run off the front of fdelim).
+ */
+ while (*--ep == *--cp)
+ if (cp < fdelim)
+ break;
+ if (cp < fdelim) {
+ /* we matched the entire delim prefix,
+ * so only take the buffer up to there.
+ * we know ep >= bp -- check above prevents underrun
+ */
+ c = (ep - bp) + 2;
+ break;
+ }
+ }
+ /* try matching one less char of delim string */
+ ep = bp + c - 1;
+ } while (--sp > fdelim);
+ }
+ }