- /* next is set to 1 when we were close enough to desired interval */
- next = write_stats(*curr, USE_SA_FILE, cnt, tm_start.use, tm_end.use,
- *reset, act_id, reset_cd);
- reset_cd = 0;
- if (next && (*cnt > 0)) {
- (*cnt)--;
+ if (*eosaf || (rtype == R_RESTART))
+ /* This is EOF or we have met a LINUX RESTART record: Stop now */
+ break;
+
+ if (rtype != R_COMMENT) {
+ /* Read the extra fields since it's not a special record */
+ if (read_file_stat_bunch(act, *curr, ifd, file_hdr.sa_act_nr, file_actlst,
+ endian_mismatch, arch_64, file, file_magic, UEOF_STOP))
+ /* Error or unexpected EOF */
+ break;
+ }
+ else {
+ /* Display comment */
+ next = print_special_record(&record_hdr[*curr], flags + S_F_LOCAL_TIME,
+ &tm_start, &tm_end, R_COMMENT, ifd,
+ &rectime, file, 0,
+ file_magic, &file_hdr, act, &sar_fmt,
+ endian_mismatch, arch_64);
+ if (next && lines) {
+ /*
+ * A line of comment was actually displayed: Count it in the
+ * total number of displayed lines.
+ * If no lines of stats had been previously displayed, ignore it
+ * to make sure the header line will be displayed.
+ */
+ lines++;