- j = fread(buffer, 1, sizeof(buffer), data_file);
+ uschar * s;
+
+ if (!spool_file_wireformat || source_file_override)
+ j = fread(buffer, 1, sizeof(buffer), data_file);
+ else /* needs CRLF -> NL */
+ if ((s = fgets(buffer, sizeof(buffer), data_file)))
+ {
+ uschar * p = s + Ustrlen(s) - 1;
+
+ if (*p == '\n' && p[-1] == '\r')
+ *--p = '\n';
+ else if (*p == '\r')
+ ungetc(*p--, data_file);
+
+ j = p - buffer;
+ }
+ else
+ j = 0;