}
static void clear_progress(void)
{ clear_progress_internal(); fflush(stdout); }
+#ifdef DEBUG
+static void debug_clear_progress(void)
+ { if (progresslen) { putchar('\n'); progresslen = 0; } }
+#endif
static void vappend_progress(const char *fmt, va_list ap)
{ progresslen += vprintf(fmt, ap); }
__attribute__((format(printf, 1, 2)))
va_list ap;
va_start(ap, what);
- clear_progress();
+ debug_clear_progress();
printf(";; recovery buffer (");
vprintf(what, ap);
printf("): "
ssize_t n;
#ifdef DEBUG
- clear_progress();
+ debug_clear_progress();
show_recovery_buffer_map(r, "begin(%"PRIuSEC", %"PRIuSEC")", pos, want);
#endif
#ifdef DEBUG
printf(";; read high (%"PRIuSEC"@%"PRIuSEC", %"PRIuSEC")",
r->pos + pp, pp, nn);
-fflush(stdout);
+ fflush(stdout);
#endif
n = recovery_read_sectors(r, pos + pp, pp, nn);
#ifdef DEBUG
for (i = 0; i < 4; i++) {
n = recovery_read(&r, pos, want);
#ifdef DEBUG
- clear_progress();
+ debug_clear_progress();
printf(";; [retry] try reading %"PRIuSEC" .. %"PRIuSEC" -> %zd\n",
pos, pos + want, n);
#endif
want = run_length_wanted(pos, step, sz, end);
n = recovery_read(&r, pos, want);
#ifdef DEBUG
- clear_progress();
+ debug_clear_progress();
printf(";; [bound] try reading %"PRIuSEC" .. %"PRIuSEC" -> %zd\n",
pos, pos + want, n);
#endif
want = run_length_wanted(pos, step, sz, end);
n = recovery_read(&r, pos, want);
#ifdef DEBUG
- clear_progress();
+ debug_clear_progress();
printf(";; [limit] try reading %"PRIuSEC" .. %"PRIuSEC" -> %zd\n",
pos, pos + want, n);
#endif
n = r.pos + r.end - good;
rearrange_sectors(&r, 0, good - r.pos, n);
}
+#ifdef DEBUG
+ show_recovery_buffer_map(&r, "returning %zd good sectors at %"PRIuSEC"",
+ n, good);
+#endif
return (n);
}
if (f&f_write) emit(pos, ev->pos);
pos = ev->pos;
#ifdef DEBUG
- clear_progress();
+ debug_clear_progress();
printf(";;\n");
#endif
}
set_live(ev->file);
#ifdef DEBUG
store_filename(fn, filetab.v[ev->file].id);
- clear_progress();
+ debug_clear_progress();
printf(";; %8"PRIuSEC": begin `%s'\n", pos, fn);
#endif
break;
"(sector %"PRIuSEC") in output file `%s'",
ev->pos, outfile);
#ifdef DEBUG
- clear_progress();
+ debug_clear_progress();
printf(";; %8"PRIuSEC": begin write\n", pos);
#endif
f |= f_write;
case EV_STOP:
f &= ~f_write;
#ifdef DEBUG
- clear_progress();
+ debug_clear_progress();
printf(";; %8"PRIuSEC": end write\n", pos);
#endif
break;
clear_live(ev->file);
#ifdef DEBUG
store_filename(fn, filetab.v[ev->file].id);
- clear_progress();
+ debug_clear_progress();
printf(";; %8"PRIuSEC": end `%s'\n", pos, fn);
#endif
break;