dvd-sector-copy.c: Just a light reformatting.
[dvdrip] / dvd-sector-copy.c
index 7b7e674..f757e49 100644 (file)
@@ -1,7 +1,5 @@
 #include "lib.h"
 
-static int status = 0;
-
 static void usage(FILE *fp)
 {
   fprintf(fp,
@@ -437,11 +435,12 @@ static void record_bad_sectors(secaddr bad_lo, secaddr bad_hi)
   if (!mapfile) return;
 
   open_file_on_demand(mapfile, &mapfp, "bad-sector region map");
-  fprintf(mapfp, "%"PRIuSEC" %"PRIuSEC"", bad_lo, bad_hi);
+  fprintf(mapfp, "%"PRIuSEC" %"PRIuSEC" # %"PRIuSEC" sectors",
+         bad_lo, bad_hi, bad_hi - bad_lo);
 
   if (file && id_kind(file->id) != RAW) {
     store_filename(fn, file->id);
-    fprintf(mapfp, " # `%s' %"PRIuSEC" .. %"PRIuSEC" of %"PRIuSEC"",
+    fprintf(mapfp, "; `%s' %"PRIuSEC" .. %"PRIuSEC" of %"PRIuSEC"",
            fn, bad_lo - file->start, bad_hi - file->start,
            file->end - file->start);
   }
@@ -1210,8 +1209,7 @@ int main(int argc, char *argv[])
     ev = &eventq.v[i];
     switch (ev->ev) {
       case EV_WRITE: start = ev->pos; f |= f_write; break;
-      case EV_STOP:
-       nsectors += ev->pos - start; f &= ~f_write; break;
+      case EV_STOP: nsectors += ev->pos - start; f &= ~f_write; break;
     }
     if (ev->pos >= limit) break;
     if (f&f_fixup) start = ev->pos;
@@ -1228,7 +1226,9 @@ int main(int argc, char *argv[])
 
   copy_progress.render = render_copy_progress;
   progress_additem(&progress, &copy_progress);
-  if (nsectors != limit) {
+  if (nsectors == limit - start)
+    { ndone = start; nsectors = limit; }
+  else {
     disc_progress.render = render_disc_progress;
     progress_additem(&progress, &disc_progress);
   }
@@ -1297,6 +1297,7 @@ int main(int argc, char *argv[])
 
   if (f&f_stats) {
     gettimeofday(&tv1, 0); t = tvdiff(&tv0, &tv1);
+    if (nsectors == limit - start) { ndone -= start; nsectors -= start; }
     tot = scale_bytes((double)nsectors*SECTORSZ, &totunit);
     rate = scale_bytes((double)nsectors*SECTORSZ/t, &rateunit);
     moan("all done: %.1f %sB in %s -- %.1f %sB/s",
@@ -1316,5 +1317,5 @@ int main(int argc, char *argv[])
 #undef f_stats
 #undef f_write
 
-  return (status);
+  return (0);
 }