dvd-sector-copy.c: Leave progress report visible before debugging.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 18 Feb 2022 23:00:18 +0000 (23:00 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 18 Feb 2022 23:00:54 +0000 (23:00 +0000)
dvd-sector-copy.c

index 1e4dc07..4e5f97b 100644 (file)
@@ -297,6 +297,10 @@ static void clear_progress_internal(void)
 }
 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)))
@@ -511,7 +515,7 @@ static void show_recovery_buffer_map(const struct recoverybuf *r,
   va_list ap;
 
   va_start(ap, what);
-  clear_progress();
+  debug_clear_progress();
   printf(";; recovery buffer (");
   vprintf(what, ap);
   printf("): "
@@ -544,7 +548,7 @@ static ssize_t recovery_read(struct recoverybuf *r,
   ssize_t n;
 
 #ifdef DEBUG
-  clear_progress();
+  debug_clear_progress();
   show_recovery_buffer_map(r, "begin(%"PRIuSEC", %"PRIuSEC")", pos, want);
 #endif
 
@@ -661,7 +665,7 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end,
   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
@@ -685,7 +689,7 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end,
     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
@@ -702,7 +706,7 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end,
     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
@@ -1121,7 +1125,7 @@ int main(int argc, char *argv[])
       if (f&f_write) emit(pos, ev->pos);
       pos = ev->pos;
 #ifdef DEBUG
-      clear_progress();
+      debug_clear_progress();
       printf(";;\n");
 #endif
     }
@@ -1130,7 +1134,7 @@ int main(int argc, char *argv[])
        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;
@@ -1142,7 +1146,7 @@ int main(int argc, char *argv[])
                      "(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;
@@ -1150,7 +1154,7 @@ int main(int argc, char *argv[])
       case EV_STOP:
        f &= ~f_write;
 #ifdef DEBUG
-       clear_progress();
+       debug_clear_progress();
        printf(";; %8"PRIuSEC": end write\n", pos);
 #endif
        break;
@@ -1158,7 +1162,7 @@ int main(int argc, char *argv[])
        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;